0) {
+ ret += "," + newline + pad(indentLevel);
+ }
+ else {
+ ret += newline + pad(indentLevel);
+ }
+ ret += string(o[i],level+1,indentLevel-0+indent);
+ }
+ if (i > 0) {
+ ret += newline + pad(indentLevel-indent);
+ }
+ ret += "]";
+ return ret;
+ }
+ else {
+ // OBJECT
+ if (maxDepth != -1 && level > maxDepth) {
+ return "{ ... }";
+ }
+ ret = "{";
+ var count = 0;
+ for (i in o) {
+ if (o==object && properties!=null && properties[i]!=1) {
+ // do nothing with this node
+ }
+ else {
+ if (typeof(o[i]) != "unknown") {
+ var processAttribute = true;
+ // Check if this is a DOM object, and if so, if we have to limit properties to look at
+ if (o.ownerDocument|| o.tagName || (o.nodeType && o.nodeName)) {
+ processAttribute = false;
+ if (i=="tagName" || i=="nodeName" || i=="nodeType" || i=="id" || i=="className") {
+ processAttribute = true;
+ }
+ }
+ if (processAttribute) {
+ if (count++>0) {
+ ret += "," + newline + pad(indentLevel);
+ }
+ else {
+ ret += newline + pad(indentLevel);
+ }
+ ret += "'" + i + "' => " + string(o[i],level+1,indentLevel-0+i.length+6+indent);
+ }
+ }
+ }
+ }
+ if (count > 0) {
+ ret += newline + pad(indentLevel-indent);
+ }
+ ret += "}";
+ return ret;
+ }
+ }
+ };
+
+ string.popup = function(o) {
+ var w = window.open("about:blank");
+ w.document.open();
+ w.document.writeln("");
+ w.document.writeln(string(o,args(arguments,1)));
+ w.document.writeln("");
+ w.document.close();
+ };
+
+ string.alert = function(o) {
+ alert(string(o,args(arguments,1)));
+ };
+
+ string.write = function(o) {
+ var argumentsIndex = 1;
+ var d = document;
+ if (arguments.length>1 && arguments[1]==window.document) {
+ d = arguments[1];
+ argumentsIndex = 2;
+ }
+ var temp = indentText;
+ indentText = " ";
+ d.write(string(o,args(arguments,argumentsIndex)));
+ indentText = temp;
+ };
+
+ string.setMaxIterations = function(i) {
+ maxIterations = i;
+ };
+
+ string.setMaxDepth = function(i) {
+ maxDepth = i;
+ };
+
+ string.$VERSION = 1.0;
+
+ return string;
+})();