⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
                        break;                    }        			    var toString = "" + obj;    			    if (toString != "" && toString != "[object Object]" &&                         toString != "[object]")                     {                        // someone went through the trouble of making a better toString(), so                        // use it.  NOTE: check for "" because in IE an XmlNodeList among                        // others will toString() to ""                        output += toString;                        break;                    }        			    // return generic "Obj", plus any obvious ID/name property                    output += "Obj" + this.getIDText(obj);                     				break;    			default: output += "" + obj; // invoke native toString()    			}    		}    		return output;        } catch (e) {            var message = "[Error in echoLeaf: " + e + "]";            output += message;            this.logDebug(message, "Log");            return output;        }            	},    getIDText : function (obj) {        // look for properties that may name the object        // name        var name = obj.name || (isc.isAn.XMLNode(obj) ? obj.getAttribute("name") : null);        if (name != null && !isc.isAn.emptyString(name)) return "{name:" + name + "}";        // ID or id        var ID = obj.ID != null ? obj.ID :                    obj.id != null ? obj.id :                       (isc.isAn.XMLNode(obj) ? obj.getAttribute("id") : null);        if (ID != null && !isc.isAn.emptyString(ID)) return "{ID:" + ID + "}";        // nodeName (HTML DOM)        if (obj.nodeName != null && !isc.isAn.emptyString(obj.nodeName)) {            return "{nodeName:" + obj.nodeName + "}";        }                // title (eg sections)        var title = obj.title || (isc.isAn.XMLNode(obj) ? obj.getAttribute("title") : null);        if (title != null && !isc.isAn.emptyString(title)) return "{title:" + title + "}";        // type (eg validators)        var type = obj.type || (isc.isAn.XMLNode(obj) ? obj.getAttribute("type") : null);        if (type != null && !isc.isAn.emptyString(type)) return "{type:" + type + "}";        // length: handy for recognizing XMLNodeLists and similar objects in IE, which aren't        // Arrays and can't be enumerated         if (obj.length != null) return "{length:" + obj.length + "}";        return "";    },	//>	@method	Log.echo()    // Return a short string representation of any object, suitable for viewing by a developer for    // debugging purposes.    // <P>    // If passed an object containing other objects, echo will not recurse into subobjects,    // summarizing them instead via echoLeaf().    // <P>    // NOTE: echo() is used to generate the output shown in the Log window when evaluating an    // expression.    //     // @param obj (any) object to echo    // @return (string) a short string representation of the object    // 	// @group debug    // @see Log.echoAll()    // @see Log.echoLeaf()    // @visibility external    //<    echo : function (obj, multiLine, longArrays, showFunctions) {        if (obj == null) return this.echoLeaf(obj);        if (multiLine == null) multiLine = true;        if (obj.tagName) return this.echoDOM(obj);        // anything isn't an Array or Object should be handled by echoLeaf.  (Note that typeof        // [] is "object").  Note we pass a flag telling echoLeaf it shouldn't try to shorten        // it's result, since it's going to be the entirety of the output.        if (typeof obj != "object" || isc.isA.Date(obj)) return this.echoLeaf(obj, true);        // echo entire arrays rather than just their properties        if (isc.isAn.Array(obj)) {            var output = (longArrays ? "[\n" : "[");            for (var i = 0; i < obj.length; i++) {                // echo each item either as a leaf or as a full property map                output += (longArrays ? this.echo(obj[i], multiLine) : this.echoLeaf(obj[i]));                if (i + 1 < obj.length) output += (longArrays ? ",\n" : ", ");            }            output += "\n]";            return output;        }                // echo only properties of this instance, as opposed to properties inherited from it's        // superclass if any        var output = "{";		if (obj.getUniqueProperties != null) {            output = obj.getClassName() + "{";            obj = obj.getUniqueProperties();            // avoid a blizzard of function definitions            if (showFunctions == null) showFunctions = false;        }        // if this is not an ISC object, not a DOM element, not atomic (eg String or        // Number), and not an Array, show its functions as it's something unusual where we'd        // like to see everything        if (showFunctions == null) showFunctions = true;        // echo normal objects        var propertyNames;        try {            propertyNames = isc.getKeys(obj);        } catch (e) {            // in IE several XML-related objects through exceptions if you try to for..in on            // them            return this.echoLeaf(obj);        }        if (isc.Browser.isSafari) {                        var isStyle = false,                    styleDecl = "[object CSSStyleDeclaration]";            try {                // many objects JSError on attempts to toString() in Safari                isStyle = (obj + "" == styleDecl);            } catch (e) { }            if (isStyle) {                output = styleDecl + "{\n[standard props only]\n";                propertyNames = isc.getKeys(isc.Canvas._getStylePropertyMask());                  // add 'cssText' as that's not included by default                propertyNames.add("cssText");            }        }                for (var i = 0; i < propertyNames.length; i++) {            var propertyName = propertyNames[i],                value;            try {                // sometimes you can get permission denied on the property access rather than                // on the attempt to toString() the value                value = obj[propertyName];            } catch (e) {                value = "[error accessing property: " + e + "]";            }            if (!showFunctions && isc.isA.Function(value)) continue;            // don't show internal properties when private identifier obfuscation is on            if (propertyName.startsWith("$")) continue;            output += propertyName + ": " + this.echoLeaf(value);            if (i + 1 < propertyNames.length) output += (multiLine ? ",\r" : ", ");        }        output += "}";        return output;    },	//>	@method	Log.echoAll()    // Like echo(), except that if passed an Array, echoAll() will echo() every element of the    // Array.    //    // @param obj  (any)  object to echo    // @return (string) a short string representation of the object    //	// @group debug    // @see echo()    // @visibility external    //<    echoAll : function (obj, multiLine) {        return this.echo(obj, multiLine, true);    },    echoFull : function (obj) {        // use serialize to "pretty print" as JSON        return isc.Comm.serialize(obj, true);    },    // variant of echo that will be compact: one line, don't recurse into arrays    echoShort : function (obj) {        return this.echo(obj, false, false);    },    // various properties we want to ignore when echoing DOM elements    _DOMIgnoreProperties : {        // we rarely care about the text value of a node        outerText: false,        innerText: false,        // IE proprietary crap        parentTextEdit: false,        isTextEdit: false,         parentTextEdit: false,        contentEditable: false,        canHaveHTML: true,         isMultiLine: false,         filters: false,        canHaveChildren: false,        behaviorUrns: false,        sourceIndex: false,         accelerator: false,         textDecorationUnderline: false,        textDecorationNone: false		// security exceptions in Moz		//fullScreen: false, // window.fullScreen		// error in IE6 (maybe other versions).  You cannot compare the values of these        // properties to strings.  If you try (eg window.navigator == "") you get "object does        // not support this property or method", presumably because some native code threw an        // exception trying to compare against a JS string.		//clientInformation: false, // window		//external: false, // window		//navigator: false, // window    },    // echo a DOM Node, avoiding outputting the many constants, functions, and other useless    // things that appear on all DOM Nodes.      // NOTE: in IE, there's no real prototype for DOM elements, so we just suppress things by    // hand.    echoDOM : function (node) {        return this.echoDelta(node, window.Node, node.tagName + this.getIDText(node));    },    echoEvent : function (event) {		// NOTE: in Moz, some of the constants we'd like to omit are on window.KeyEvent and some are		// on window.Event.  window.KeyEvent has more.        return this.echoDelta(event, (isc.Browser.isMoz ? window.KeyEvent : window.Event));    },    echoDelta : function (obj, base, prefix) {        if (obj == null) return null;                if (isc.Browser.isIE && isc.isAn.XMLNode(obj)) {                        var output = "<" + obj.tagName + " [XMLNode] ";            var attrs = obj.attributes;            for (var i = 0; i < attrs.length; i++) {                var attr = attrs[i];                if (i > 0) output += " ";                output += attr.name + "=" + this.echoLeaf(attr.value);            }            output += (i > 0 ? " [" : "") + obj.childNodes.length + " child nodes]>";            return output;        }        var output = (prefix || isc.emptyString) + "{",            propertyNames = isc.getKeys(obj);        for (var i = 0; i < propertyNames.length; i++) {            var propertyName = propertyNames[i];            // skip useless properties found in DOM objects            if (this._DOMIgnoreProperties[propertyName] != null) continue;            // skip properties inherited from base class            if (base != null && base[propertyName] != null) continue;			// omit multi-letter properties in all caps (typically constants)			if (propertyName.length > 3 && propertyName.toUpperCase() == propertyName) continue;            try {    			var value = obj[propertyName];                // skip null/empty values                if (value == null || value == "") continue;                // skip functions                if (isc.isA.Function(value)) continue;                output += propertyName + ": " + this.echoLeaf(obj[propertyName]);            } catch (e) {                output += propertyName + ": " + this.echoLeaf(e);            }            if (i + 1 < propertyNames.length) output += ", ";        }        output += "}";        return output;    },    // echo all the size-related properties of a DOM element.  Won't work in Nav4.    echoElementSize : function (element) {        var undefined;        return this.echo({            scrollLeft : element.scrollLeft,            scrollTop : element.scrollTop,            scrollWidth : element.scrollWidth,            scrollHeight : element.scrollHeight,            clientWidth : undefined,            clientHeight : undefined,            offsetWidth : element.offsetWidth,            offsetHeight : element.offsetHeight,            styleLeft : element.style.left,            styleTop : element.style.top,            styleWidth : element.style.width,            styleHeight : element.style.height,            styleClip : element.style.clip        });    }};// make methods available on any class or instanceisc.Class.addProperties(isc._debugMethods);isc.Class.addClassProperties(isc._debugMethods);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -