// JavaScript Document var SYS=function(){} SYS._print_r=function($v,$left,$ret){ if(typeof $left ===‘undefined‘){ $left = -1; } if(typeof $ret ===‘undefined‘){ $ret = "My"; } $left+=1; if (typeof $v ===‘object‘ ){ return SYS.arrayToString($v,$left,$ret); } return $ret+$v+"\n"; } SYS.arrayToString=function($v,$left,$ret){ $ret+="Array\n"+str_repeat(‘ ‘,$left*4)+"(\n"; for ($key in $v) { $parmret=$ret+str_repeat(‘ ‘,$left*4+2)+"["+$key+"] => "; $ret=SYS.recursionPrintR($v[$key],$left,$parmret) ; } $ret+=str_repeat(‘ ‘,$left*4)+")\n\n"; return $ret; } //递归调用_print_r SYS.recursionPrintR=function($val,$left,$ret){ if (typeof $val ===‘object‘){ return SYS._print_r($val,$left,$ret); } return $ret+‘<div style="border:1px #eee solid; width:auto;padding:5px;‘ +‘ left:‘+($left*50+100)+‘px;position:relative; height:20px; overflow-y:hidden; " ‘ +‘ onClick=" ‘ +‘ " ><span onClick="window.SYS.ch.apply(this.parentNode,[1])">[+]</span><span onClick="window.SYS.ch.apply(this.parentNode,[-1])">[-]</span>‘+$val+‘</div>\n‘; } SYS.print_r=function($v,$left,$ret){ if(typeof $left ===‘undefined‘){ $left = -1; } if(typeof $ret ===‘undefined‘){ $ret = "My"; } return ‘<pre>‘+SYS._print_r($v,$left,$ret)+‘</pre>‘; } SYS.ch=function(sign){ var h=this.style.height; h=(h.replace(/px/, ‘‘)) ; this.style.height=(parseInt(h)+sign*100)+‘px‘ } function str_repeat($str,$num,$cn){ if(typeof $cn ==="undefined"){ $cn = 0 ; } $cn=$cn+1; if($num==0){return "";} else {$temp=$str;} return $num>$cn ? $temp+str_repeat($str,$num,$cn) : $temp; }
注意:这里的不是数组是object.如果要输出数组请把判断类型改为 array
调用:这里的THREE指的是 three.js中的对象
SYS.print_r(THREE)
时间: 2024-10-13 22:24:56