firebug.js
来自「这是一个ajax的例子大家好好的看看就是一个鱼眼的效果」· JavaScript 代码 · 共 1,104 行 · 第 1/3 页
JS
1,104 行
function appendSelector(object, html){ html.push('<span class="objectBox-selector">'); html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>'); if(object.id){ html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>'); } if(object.className){ html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>'); } html.push('</span>'); } function appendNode(node, html){ if(node.nodeType == 1){ html.push( '<div class="objectBox-element">', '<<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>'); for(var i = 0; i < node.attributes.length; ++i){ var attr = node.attributes[i]; if(!attr.specified){ continue; } html.push(' <span class="nodeName">', attr.nodeName.toLowerCase(), '</span>="<span class="nodeValue">', escapeHTML(attr.nodeValue), '</span>"'); } if(node.firstChild){ html.push('></div><div class="nodeChildren">'); for(var child = node.firstChild; child; child = child.nextSibling){ appendNode(child, html); } html.push('</div><div class="objectBox-element"></<span class="nodeTag">', node.nodeName.toLowerCase(), '></span></div>'); }else{ html.push('/></div>'); } }else if (node.nodeType == 3){ html.push('<div class="nodeText">', escapeHTML(node.nodeValue), '</div>'); } } // *************************************************************************** function addEvent(object, name, handler){ if(document.all){ object.attachEvent("on"+name, handler); }else{ object.addEventListener(name, handler, false); } } function removeEvent(object, name, handler){ if(document.all){ object.detachEvent("on"+name, handler); }else{ object.removeEventListener(name, handler, false); } } function cancelEvent(event){ if(document.all){ event.cancelBubble = true; }else{ event.stopPropagation(); } } function onError(msg, href, lineNo){ var lastSlash = href.lastIndexOf("/"); var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1); var html = [ '<span class="errorMessage">', msg, '</span>', '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>' ]; logRow(html, "error"); } //After converting to div instead of iframe, now getting two keydowns right away in IE 6. //Make sure there is a little bit of delay. var onKeyDownTime = (new Date()).getTime(); function onKeyDown(event){ var timestamp = (new Date()).getTime(); if(timestamp > onKeyDownTime + 200){ event = dojo.fixEvent(event); var keys = dojo.keys; var ekc = event.keyCode; onKeyDownTime = timestamp; if(ekc == keys.F12){ toggleConsole(); }else if( (ekc == keys.NUMPAD_ENTER || ekc == 76) && event.shiftKey && (event.metaKey || event.ctrlKey) ){ focusCommandLine(); }else{ return; } cancelEvent(event); } } function onSplitterMouseDown(event){ if(dojo.isSafari || dojo.isOpera){ return; } addEvent(document, "mousemove", onSplitterMouseMove); addEvent(document, "mouseup", onSplitterMouseUp); for(var i = 0; i < frames.length; ++i){ addEvent(frames[i].document, "mousemove", onSplitterMouseMove); addEvent(frames[i].document, "mouseup", onSplitterMouseUp); } } function onSplitterMouseMove(event){ var win = document.all ? event.srcElement.ownerDocument.parentWindow : event.target.ownerDocument.defaultView; var clientY = event.clientY; if(win != win.parent){ clientY += win.frameElement ? win.frameElement.offsetTop : 0; } var height = consoleFrame.offsetTop + consoleFrame.clientHeight; var y = height - clientY; consoleFrame.style.height = y + "px"; layout(); } function onSplitterMouseUp(event){ removeEvent(document, "mousemove", onSplitterMouseMove); removeEvent(document, "mouseup", onSplitterMouseUp); for(var i = 0; i < frames.length; ++i){ removeEvent(frames[i].document, "mousemove", onSplitterMouseMove); removeEvent(frames[i].document, "mouseup", onSplitterMouseUp); } } function onCommandLineKeyDown(event){ if(event.keyCode == 13 && commandLine.value){ addToHistory(commandLine.value); evalCommandLine(); }else if(event.keyCode == 27){ commandLine.value = ""; }else if(event.keyCode == dojo.keys.UP_ARROW || event.charCode == dojo.keys.UP_ARROW){ navigateHistory("older"); }else if(event.keyCode == dojo.keys.DOWN_ARROW || event.charCode == dojo.keys.DOWN_ARROW){ navigateHistory("newer"); }else if(event.keyCode == dojo.keys.HOME || event.charCode == dojo.keys.HOME){ historyPosition = 1; navigateHistory("older"); }else if(event.keyCode == dojo.keys.END || event.charCode == dojo.keys.END){ historyPosition = 999999; navigateHistory("newer"); } } var historyPosition = -1; var historyCommandLine = null; function addToHistory(value){ var history = cookie("firebug_history"); history = (history) ? dojo.fromJson(history) : []; var pos = dojo.indexOf(history, value); if (pos != -1){ history.splice(pos, 1); } history.push(value); cookie("firebug_history", dojo.toJson(history), 30); while(history.length && !cookie("firebug_history")){ history.shift(); cookie("firebug_history", dojo.toJson(history), 30); } historyCommandLine = null; historyPosition = -1; } function navigateHistory(direction){ var history = cookie("firebug_history"); history = (history) ? dojo.fromJson(history) : []; if(!history.length){ return; } if(historyCommandLine === null){ historyCommandLine = commandLine.value; } if(historyPosition == -1){ historyPosition = history.length; } if(direction == "older"){ --historyPosition; if(historyPosition < 0){ historyPosition = 0; } }else if(direction == "newer"){ ++historyPosition; if(historyPosition > history.length){ historyPosition = history.length; } } if(historyPosition == history.length){ commandLine.value = historyCommandLine; historyCommandLine = null; }else{ commandLine.value = history[historyPosition]; } } function cookie(name, value){ var c = document.cookie; if(arguments.length == 1){ var matches = c.match(new RegExp("(?:^|; )" + name + "=([^;]*)")); return matches ? decodeURIComponent(matches[1]) : undefined; // String or undefined }else{ var d = new Date(); d.setMonth(d.getMonth()+1); document.cookie = name + "=" + encodeURIComponent(value) + ((d.toUtcString) ? "; expires=" + d.toUTCString() : ""); } }; function isArray(it){ return it && it instanceof Array || typeof it == "array"; } //*************************************************************************************************** // Print Object Helpers function getAtts(o){ //Get amount of items in an object if(isArray(o)){ return "[array with " + o.length + " slots]"; }else{ var i = 0; for(var nm in o){ i++; } return "{object with " + i + " items}"; } } function printObject(o, i, txt, used){ // Recursively trace object, indenting to represent depth for display in object inspector // TODO: counter to prevent overly complex or looped objects (will probably help with dom nodes) var br = "\n"; // using a <pre>... otherwise we'd need a <br /> var ind = " "; txt = txt || ""; i = i || ind; used = used || []; looking: for(var nm in o){ if(o[nm] === window || o[nm] === document){ continue; }else if(o[nm] && o[nm].nodeType){ if(o[nm].nodeType == 1){ txt += i+nm + " : < "+o[nm].tagName+" id=\""+ o[nm].id+"\" />" + br; }else if(o[nm].nodeType == 3){ txt += i+nm + " : [ TextNode "+o[nm].data + " ]" + br; } }else if(typeof o[nm] == "object" && (o[nm] instanceof String || o[nm] instanceof Number || o[nm] instanceof Boolean)){ txt += i+nm + " : " + o[nm] + br; }else if(typeof(o[nm]) == "object" && o[nm]){ for(var j = 0, seen; seen = used[j]; j++){ if(o[nm] === seen){ txt += i+nm + " : RECURSION" + br; continue looking; } } used.push(o[nm]); txt += i+nm +" -> " + getAtts(o[nm]) + br; txt += printObject(o[nm], i+ind, "", used); }else if(typeof o[nm] == "undefined"){ txt += i+nm + " : undefined" + br; }else if(nm == "toString" && typeof o[nm] == "function"){ var toString = o[nm](); if(typeof toString == "string" && toString.match(/function ?(.*?)\(/)){ toString = escapeHTML(getObjectAbbr(o[nm])); } txt += i+nm +" : " + toString + br; }else{ txt += i+nm +" : "+ escapeHTML(getObjectAbbr(o[nm])) + br; } } txt += br; // keeps data from running to the edge of page return txt; } function getObjectAbbr(obj){ // Gets an abbreviation of an object for display in log // X items in object, including id // X items in an array // TODO: Firebug Sr. actually goes by char count var isError = (obj instanceof Error); var nm = (obj && (obj.id || obj.name || obj.ObjectID || obj.widgetId)); if(!isError && nm){ return "{"+nm+"}"; } var obCnt = 2; var arCnt = 4; var cnt = 0; if(isError){ nm = "[ Error: "+(obj.message || obj.description || obj)+" ]"; }else if(isArray(obj)){ nm = "[" + obj.slice(0,arCnt).join(","); if(obj.length > arCnt){ nm += " ... ("+obj.length+" items)"; } nm += "]"; }else if(typeof obj == "function"){ nm = obj + ""; var reg = /function\s*([^\(]*)(\([^\)]*\))[^\{]*\{/; var m = reg.exec(nm); if(m){ if(!m[1]){ m[1] = "function"; } nm = m[1] + m[2]; }else{ nm = "function()"; } }else if(typeof obj != "object" || typeof obj == "string"){ nm = obj + ""; }else{ nm = "{"; for(var i in obj){ cnt++; if(cnt > obCnt){ break; } nm += i+"="+obj[i]+" "; } nm+="}"; } return nm; } //************************************************************************************* window.onerror = onError; addEvent(document, dojo.isIE || dojo.isSafari ? "keydown" : "keypress", onKeyDown); if( (document.documentElement.getAttribute("debug") == "true")|| (dojo.config.isDebug) ){ toggleConsole(true); }})();}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?