Change depth to count down correctly. Trim long lines.
This commit is contained in:
parent
48617e27bc
commit
4b835baeb9
13
canvas.js
13
canvas.js
|
@ -6,16 +6,21 @@ function debug(str) {
|
|||
|
||||
function dirObj(obj, parent, depth) {
|
||||
var msg = "";
|
||||
if (! depth) { depth=0; }
|
||||
var val = "";
|
||||
if (! depth) { depth=2; }
|
||||
if (! parent) { parent= ""; }
|
||||
|
||||
// Print the properties of the passed-in object
|
||||
for (var i in obj) {
|
||||
if ((depth < 2) && (typeof obj[i] == "object")) {
|
||||
if ((depth > 1) && (typeof obj[i] == "object")) {
|
||||
// Recurse attributes that are objects
|
||||
msg += dirObj(obj[i], parent + "." + i, depth+1);
|
||||
msg += dirObj(obj[i], parent + "." + i, depth-1);
|
||||
} else {
|
||||
msg += parent + "." + i + ": " + obj[i] + "\n";
|
||||
val = new String(obj[i]).replace("\n", " ");
|
||||
if (val.length > 30) {
|
||||
val = val.substr(0,30) + "...";
|
||||
}
|
||||
msg += parent + "." + i + ": " + val + "\n";
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
|
|
Loading…
Reference in New Issue