firebug.js

来自「这是一个ajax的例子大家好好的看看就是一个鱼眼的效果」· JavaScript 代码 · 共 1,104 行 · 第 1/3 页

JS
1,104
字号
			djConfig.debugContainerId = 'fb';					// connecting popup			_firebugWin.console = window.console;			_firebugWin.dojo = window.dojo;		}else{			_firebugDoc = document;			containerHeight = (dojo.config.debugHeight || 300) + "px";		}				var styleElement = _firebugDoc.createElement("link");		styleElement.href = dojo.moduleUrl("dojo._firebug", "firebug.css");		styleElement.rel = "stylesheet";		styleElement.type = "text/css";		var styleParent = _firebugDoc.getElementsByTagName("head");		if(styleParent){			styleParent = styleParent[0];		}		if(!styleParent){			styleParent = _firebugDoc.getElementsByTagName("html")[0];		}		if(dojo.isIE){			window.setTimeout(function(){ styleParent.appendChild(styleElement); }, 0);		}else{			styleParent.appendChild(styleElement);		}				if(dojo.config.debugContainerId){			consoleFrame = _firebugDoc.getElementById(dojo.config.debugContainerId);		}		if(!consoleFrame){			consoleFrame = _firebugDoc.createElement("div");			_firebugDoc.body.appendChild(consoleFrame);		}		consoleFrame.className += " firebug";		consoleFrame.style.height = containerHeight;		consoleFrame.style.display = (frameVisible ? "block" : "none");	  				var closeStr = dojo.config.popup ? "" : '    <a href="#" onclick="console.close(); return false;">Close</a>';		consoleFrame.innerHTML = 			  '<div id="firebugToolbar">'			+ '  <a href="#" onclick="console.clear(); return false;">Clear</a>'			+ '  <span class="firebugToolbarRight">'			+ closeStr			+ '  </span>'			+ '</div>'			+ '<input type="text" id="firebugCommandLine" />'			+ '<div id="firebugLog"></div>'			+ '<div id="objectLog" style="display:none;"></div>';		consoleToolbar = _firebugDoc.getElementById("firebugToolbar");		consoleToolbar.onmousedown = onSplitterMouseDown;		commandLine = _firebugDoc.getElementById("firebugCommandLine");		addEvent(commandLine, "keydown", onCommandLineKeyDown);		addEvent(_firebugDoc, dojo.isIE || dojo.isSafari ? "keydown" : "keypress", onKeyDown);				consoleBody = _firebugDoc.getElementById("firebugLog");		consoleObjectInspector = _firebugDoc.getElementById("objectLog");		layout();		flush();	}	dojo.addOnLoad(createFrame);	function clearFrame(){		_firebugDoc = null;				if(_firebugWin.console){			_firebugWin.console.clear();		}		_firebugWin = null;		consoleFrame = null;		consoleBody = null;		consoleObjectInspector = null;		commandLine = null;		messageQueue = [];		groupStack = [];		timeMap = {};	}	dojo.addOnUnload(clearFrame);	function evalCommandLine(){		var text = commandLine.value;		commandLine.value = "";		logRow([clPrefix, text], "command");				var value;		try{			value = eval(text);		}catch(e){			console.debug(e); // put exception on the console		}		console.log(value);	}		function layout(h){		var height = h ? 			h  - (consoleToolbar.offsetHeight + commandLine.offsetHeight +25 + (h*.01)) + "px" : 			consoleFrame.offsetHeight - (consoleToolbar.offsetHeight + commandLine.offsetHeight) + "px";				consoleBody.style.top = consoleToolbar.offsetHeight + "px";		consoleBody.style.height = height;		consoleObjectInspector.style.height = height;		consoleObjectInspector.style.top = consoleToolbar.offsetHeight + "px";		commandLine.style.bottom = 0;	}		function logRow(message, className, handler){		if(consoleBody){			writeMessage(message, className, handler);		}else{			messageQueue.push([message, className, handler]);		}	}		function flush(){		var queue = messageQueue;		messageQueue = [];				for(var i = 0; i < queue.length; ++i){			writeMessage(queue[i][0], queue[i][1], queue[i][2]);		}	}	function writeMessage(message, className, handler){		var isScrolledToBottom =			consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight;		handler = handler||writeRow;				handler(message, className);				if(isScrolledToBottom){			consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight;		}	}		function appendRow(row){		var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody;		container.appendChild(row);	}	function writeRow(message, className){		var row = consoleBody.ownerDocument.createElement("div");		row.className = "logRow" + (className ? " logRow-"+className : "");		row.innerHTML = message.join("");		appendRow(row);	}	function pushGroup(message, className){		logFormatted(message, className);		//var groupRow = consoleBody.ownerDocument.createElement("div");		//groupRow.className = "logGroup";		var groupRowBox = consoleBody.ownerDocument.createElement("div");		groupRowBox.className = "logGroupBox";		//groupRow.appendChild(groupRowBox);		appendRow(groupRowBox);		groupStack.push(groupRowBox);	}	function popGroup(){		groupStack.pop();	}		// ***************************************************************************	function logFormatted(objects, className){		var html = [];				var format = objects[0];		var objIndex = 0;		if(typeof(format) != "string"){			format = "";			objIndex = -1;		}		var parts = parseFormat(format);				for(var i = 0; i < parts.length; ++i){			var part = parts[i];			if(part && typeof part == "object"){				part.appender(objects[++objIndex], html);			}else{				appendText(part, html);			}		}						var ids = [];		var obs = [];		for(i = objIndex+1; i < objects.length; ++i){			appendText(" ", html);						var object = objects[i];			if(object === undefined || object === null ){				appendNull(object, html);			}else if(typeof(object) == "string"){				appendText(object, html);					}else if(object.nodeType == 9){				appendText("[ XmlDoc ]", html);			}else if(object.nodeType == 1){				// simple tracing of dom nodes				appendText("< "+object.tagName+" id=\""+ object.id+"\" />", html);							}else{				// Create link for object inspector				// need to create an ID for this link, since it is currently text				var id = "_a" + __consoleAnchorId__++;				ids.push(id);				// need to save the object, so the arrays line up				obs.push(object);				var str = '<a id="'+id+'" href="javascript:void(0);">'+getObjectAbbr(object)+'</a>';								appendLink( str , html);			}		}				logRow(html, className);				// Now that the row is inserted in the DOM, loop through all of the links that were just created		for(i=0; i<ids.length; i++){			var btn = _firebugDoc.getElementById(ids[i]);			if(!btn){ continue; }				// store the object in the dom btn for reference later			// avoid parsing these objects unless necessary			btn.obj = obs[i];				_firebugWin.console._connects.push(dojo.connect(btn, "onclick", function(){				// hide rows				consoleBody.style.display = "none";				consoleObjectInspector.style.display = "block";				// create a back button				var bkBtn = '<a href="javascript:console.closeObjectInspector();">&nbsp;<<&nbsp;Back</a>';				try{					printObject(this.obj);				}catch(e){					this.obj = e;				}				consoleObjectInspector.innerHTML = bkBtn + "<pre>" + printObject( this.obj ) + "</pre>";			}));		}	}	function parseFormat(format){		var parts = [];		var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;	  		var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat};		for(var m = reg.exec(format); m; m = reg.exec(format)){			var type = m[8] ? m[8] : m[5];			var appender = type in appenderMap ? appenderMap[type] : appendObject;			var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0);			parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1));			parts.push({appender: appender, precision: precision});			format = format.substr(m.index+m[0].length);		}		parts.push(format);		return parts;	}	function escapeHTML(value){		function replaceChars(ch){			switch(ch){				case "<":					return "&lt;";				case ">":					return "&gt;";				case "&":					return "&amp;";				case "'":					return "&#39;";				case '"':					return "&quot;";			}			return "?";		}		return String(value).replace(/[<>&"']/g, replaceChars);	}	function objectToString(object){		try{			return object+"";		}catch(e){			return null;		}	}	// ***************************************************************************	function appendLink(object, html){		// needed for object links - no HTML escaping		html.push( objectToString(object) );	}		function appendText(object, html){		html.push(escapeHTML(objectToString(object)));	}	function appendNull(object, html){		html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>');	}	function appendString(object, html){		html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)),			'&quot;</span>');	}	function appendInteger(object, html){		html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');	}	function appendFloat(object, html){		html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');	}	function appendFunction(object, html){		html.push('<span class="objectBox-function">', getObjectAbbr(object), '</span>');	}		function appendObject(object, html){		try{			if(object === undefined){				appendNull("undefined", html);			}else if(object === null){				appendNull("null", html);			}else if(typeof object == "string"){				appendString(object, html);			}else if(typeof object == "number"){				appendInteger(object, html);			}else if(typeof object == "function"){				appendFunction(object, html);			}else if(object.nodeType == 1){				appendSelector(object, html);			}else if(typeof object == "object"){				appendObjectFormatted(object, html);			}else{				appendText(object, html);			}		}catch(e){			/* squelch */		}	}			function appendObjectFormatted(object, html){		var text = objectToString(object);		var reObject = /\[object (.*?)\]/;		var m = reObject.exec(text);		html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>');	}	

⌨️ 快捷键说明

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