標籤:style blog os io java ar for div cti
// JavaScript Documentvar 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_rSYS.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)
js 實現 pring_r功能