Commit 4b835bae authored by Joel Martin's avatar Joel Martin

Change depth to count down correctly. Trim long lines.

parent 48617e27
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment