UNPKG

firebug-lite-ie

Version:

Firebug Lite for IE: doing the Firebug way on ancient IE.

1,109 lines 663 kB
(function(){ /************************************************************** * * Firebug Lite 1.4.0a1 * * Copyright (c) 2007, Parakey Inc. * Released under BSD license. * More information: http://getfirebug.com/firebuglite * **************************************************************/ /* * CSS selectors powered by: * * Sizzle CSS Selector Engine - v1.0 * Copyright 2009, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * More information: http://sizzlejs.com/ */ var FBL={}; (function(){var productionDir="http://getfirebug.com/releases/lite/"; var bookmarkletVersion=4; var reNotWhitespace=/[^\s]/; var reSplitFile=/:\/{1,3}(.*?)\/([^\/]*?)\/?($|\?.*)/; this.reJavascript=/\s*javascript:\s*(.*)/; this.reChrome=/chrome:\/\/([^\/]*)\//; this.reFile=/file:\/\/([^\/]*)\//; var userAgent=navigator.userAgent.toLowerCase(); this.isFirefox=/firefox/.test(userAgent); this.isOpera=/opera/.test(userAgent); this.isSafari=/webkit/.test(userAgent); this.isIE=/msie/.test(userAgent)&&!/opera/.test(userAgent); this.isIE6=/msie 6/i.test(navigator.appVersion); this.browserVersion=(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1]; this.isIElt8=this.isIE&&(this.browserVersion-0<8); this.NS=null; this.pixelsPerInch=null; var namespaces=[]; this.ns=function(fn){var ns={}; namespaces.push(fn,ns); return ns }; var FBTrace=null; this.initialize=function(){if(FBL.FBTrace){FBTrace=FBL.FBTrace }else{FBTrace=FBL.FBTrace={} }FBL.Ajax.initialize(); var isChromeContext=window.Firebug&&typeof window.Firebug.SharedEnv=="object"; if(isChromeContext){sharedEnv=window.Firebug.SharedEnv; delete window.Firebug.SharedEnv; FBL.Env=sharedEnv; FBL.Env.isChromeContext=true; FBTrace.messageQueue=FBL.Env.traceMessageQueue }else{FBL.NS=document.documentElement.namespaceURI; FBL.Env.browser=window; FBL.Env.destroy=destroyEnvironment; if(document.documentElement.getAttribute("debug")=="true"){FBL.Env.Options.startOpened=true }findLocation(); var prefs=eval("("+FBL.readCookie("FirebugLite")+")"); if(prefs){FBL.Env.Options.startOpened=prefs.startOpened; FBL.Env.Options.enableTrace=prefs.enableTrace; FBL.Env.Options.enablePersistent=prefs.enablePersistent }if(FBL.isFirefox&&typeof FBL.Env.browser.console=="object"&&FBL.Env.browser.console.firebug&&FBL.Env.Options.disableWhenFirebugActive){return }}if(FBL.Env.isDebugMode){FBL.Env.browser.FBL=FBL }this.isQuiksMode=FBL.Env.browser.document.compatMode=="BackCompat"; this.isIEQuiksMode=this.isIE&&this.isQuiksMode; this.isIEStantandMode=this.isIE&&!this.isQuiksMode; this.noFixedPosition=this.isIE6||this.isIEQuiksMode; if(FBL.Env.Options.enableTrace){FBTrace.initialize() }if(FBTrace.DBG_INITIALIZE&&isChromeContext){FBTrace.sysout("FBL.initialize - persistent application","initialize chrome context") }if(FBTrace.DBG_INITIALIZE){FBTrace.sysout("FBL.initialize",namespaces.length/2+" namespaces BEGIN") }for(var i=0; i<namespaces.length; i+=2){var fn=namespaces[i]; var ns=namespaces[i+1]; fn.apply(ns) }if(FBTrace.DBG_INITIALIZE){FBTrace.sysout("FBL.initialize",namespaces.length/2+" namespaces END"); FBTrace.sysout("FBL waitForDocument","waiting document load") }FBL.Firebug.loadPrefs(prefs); if(FBL.Env.Options.enablePersistent){if(isChromeContext){FBL.FirebugChrome.clone(FBL.Env.FirebugChrome) }else{FBL.Env.FirebugChrome=FBL.FirebugChrome; FBL.Env.traceMessageQueue=FBTrace.messageQueue }}if(FBL.Env.isChromeExtension){var doc=FBL.Env.browser.document; if(!doc.getElementById("FirebugChannel")){var channel=doc.createElement("div"); channel.id="FirebugChannel"; channel.firebugIgnore=true; channel.style.display="none"; doc.documentElement.insertBefore(channel,doc.documentElement.firstChild) }var channelEvent=document.createEvent("Event"); channelEvent.initEvent("FirebugChannelEvent",true,true); this.chromeExtensionDispatch=function(data){channel.innerText=data; channel.dispatchEvent(channelEvent) } }waitForDocument() }; var waitForDocument=function waitForDocument(){var doc=FBL.Env.browser.document; var body=doc.getElementsByTagName("body")[0]; if(body){calculatePixelsPerInch(doc,body); onDocumentLoad() }else{setTimeout(waitForDocument,50) }}; var onDocumentLoad=function onDocumentLoad(){if(FBTrace.DBG_INITIALIZE){FBTrace.sysout("FBL onDocumentLoad","document loaded") }if(FBL.isIE6){fixIE6BackgroundImageCache() }if(FBL.Env.Options.enablePersistent&&FBL.Env.isChromeContext){FBL.Firebug.initialize(); if(!FBL.Env.isDevelopmentMode){sharedEnv.destroy(); sharedEnv=null }}else{FBL.FirebugChrome.create() }}; var sharedEnv; this.Env={Options:{saveCookies:false,saveWindowPosition:false,saveCommandLineHistory:false,startOpened:false,startInNewWindow:false,showIconWhenHidden:true,overrideConsole:true,ignoreFirebugElements:true,disableWhenFirebugActive:true,enableTrace:false,enablePersistent:false},Location:{sourceDir:null,baseDir:null,skinDir:null,skin:null,app:null},skin:"xp",useLocalSkin:false,isDevelopmentMode:false,isDebugMode:false,isChromeContext:false,browser:null,chrome:null}; var destroyEnvironment=function destroyEnvironment(){setTimeout(function(){FBL=null },100) }; var findLocation=function findLocation(){var reFirebugFile=/(firebug-lite(?:-\w+)?(?:\.js|\.jgz))(?:#(.+))?$/; var rePath=/^(.*\/)/; var reProtocol=/^\w+:\/\//; var path=null; var doc=document; var script=doc.getElementById("FirebugLite"); if(script){file=reFirebugFile.exec(script.src); var version=script.getAttribute("FirebugLite"); var number=version?parseInt(version):0; if(!version||!number||number<bookmarkletVersion){FBL.Env.bookmarkletOutdated=true }}else{for(var i=0,s=doc.getElementsByTagName("script"),si; si=s[i]; i++){var file=null; if(si.nodeName.toLowerCase()=="script"&&(file=reFirebugFile.exec(si.src))){script=si; break }}}if(script){script.firebugIgnore=true }if(file){var fileName=file[1]; var fileOptions=file[2]; if(reProtocol.test(script.src)){path=rePath.exec(script.src)[1] }else{var r=rePath.exec(script.src); var src=r?r[1]:script.src; var backDir=/^((?:\.\.\/)+)(.*)/.exec(src); var reLastDir=/^(.*\/)[^\/]+\/$/; path=rePath.exec(location.href)[1]; if(backDir){var j=backDir[1].length/3; var p; while(j-->0){path=reLastDir.exec(path)[1] }path+=backDir[2] }else{if(src.indexOf("/")!=-1){if(/^\.\/./.test(src)){path+=src.substring(2) }else{if(/^\/./.test(src)){var domain=/^(\w+:\/\/[^\/]+)/.exec(path); path=domain[1]+src }else{path+=src }}}}}}FBL.Env.isChromeExtension=script&&script.getAttribute("extension")=="Chrome"; if(FBL.Env.isChromeExtension){path=productionDir; FBL.Env.bookmarkletOutdated=false; script={innerHTML:"{showIconWhenHidden:false}"} }var m=path&&path.match(/([^\/]+)\/$/)||null; if(path&&m){var Env=FBL.Env; Env.useLocalSkin=path.indexOf(location.protocol+"//"+location.host+"/")==0; if(fileName=="firebug-lite-dev.js"){Env.isDevelopmentMode=true; Env.isDebugMode=true }else{if(fileName=="firebug-lite-debug.js"){Env.isDebugMode=true }}if(Env.browser.document.documentElement.getAttribute("debug")=="true"){Env.Options.startOpened=true }if(fileOptions){var options=fileOptions.split(","); for(var i=0,length=options.length; i<length; i++){var option=options[i]; var name,value; if(option.indexOf("=")!=-1){var parts=option.split("="); name=parts[0]; value=eval(unescape(parts[1])) }else{name=option; value=true }if(name=="debug"){Env.isDebugMode=!!value }else{if(name in Env.Options){Env.Options[name]=value }else{Env[name]=value }}}}var innerOptions=FBL.trim(script.innerHTML); if(innerOptions){var innerOptionsObject=eval("("+innerOptions+")"); for(var name in innerOptionsObject){var value=innerOptionsObject[name]; if(name=="debug"){Env.isDebugMode=!!value }else{if(name in Env.Options){Env.Options[name]=value }else{Env[name]=value }}}}if(Env.isDebugMode){Env.Options.startOpened=true; Env.Options.enableTrace=true; Env.Options.disableWhenFirebugActive=false }var loc=Env.Location; var isProductionRelease=path.indexOf(productionDir)!=-1; loc.sourceDir=path; loc.baseDir=path.substr(0,path.length-m[1].length-1); loc.skinDir=(isProductionRelease?path:loc.baseDir)+"skin/"+Env.skin+"/"; loc.skin=loc.skinDir+"firebug.html"; loc.app=path+fileName }else{throw new Error("Firebug Error: Library path not found") }}; this.bind=function(){var args=cloneArray(arguments),fn=args.shift(),object=args.shift(); return function(){return fn.apply(object,arrayInsert(cloneArray(args),0,arguments)) } }; this.bindFixed=function(){var args=cloneArray(arguments),fn=args.shift(),object=args.shift(); return function(){return fn.apply(object,args) } }; this.extend=function(l,r){var newOb={}; for(var n in l){newOb[n]=l[n] }for(var n in r){newOb[n]=r[n] }return newOb }; this.descend=function(prototypeParent,childProperties){function protoSetter(){}protoSetter.prototype=prototypeParent; var newOb=new protoSetter(); for(var n in childProperties){newOb[n]=childProperties[n] }return newOb }; this.append=function(l,r){for(var n in r){l[n]=r[n] }return l }; this.keys=function(map){var keys=[]; try{for(var name in map){keys.push(name) }}catch(exc){}return keys }; this.values=function(map){var values=[]; try{for(var name in map){try{values.push(map[name]) }catch(exc){if(FBTrace.DBG_ERRORS){FBTrace.sysout("lib.values FAILED ",exc) }}}}catch(exc){if(FBTrace.DBG_ERRORS){FBTrace.sysout("lib.values FAILED ",exc) }}return values }; this.remove=function(list,item){for(var i=0; i<list.length; ++i){if(list[i]==item){list.splice(i,1); break }}}; this.sliceArray=function(array,index){var slice=[]; for(var i=index; i<array.length; ++i){slice.push(array[i]) }return slice }; function cloneArray(array,fn){var newArray=[]; if(fn){for(var i=0; i<array.length; ++i){newArray.push(fn(array[i])) }}else{for(var i=0; i<array.length; ++i){newArray.push(array[i]) }}return newArray }function extendArray(array,array2){var newArray=[]; newArray.push.apply(newArray,array); newArray.push.apply(newArray,array2); return newArray }this.extendArray=extendArray; this.cloneArray=cloneArray; function arrayInsert(array,index,other){for(var i=0; i<other.length; ++i){array.splice(i+index,0,other[i]) }return array }this.createStyleSheet=function(doc,url){var style=this.createElement("link"); style.setAttribute("charset","utf-8"); style.firebugIgnore=true; style.setAttribute("rel","stylesheet"); style.setAttribute("type","text/css"); style.setAttribute("href",url); return style }; this.addStyleSheet=function(doc,style){var heads=doc.getElementsByTagName("head"); if(heads.length){heads[0].appendChild(style) }else{doc.documentElement.appendChild(style) }}; this.appendStylesheet=function(doc,uri){if(this.$(uri,doc)){return }var styleSheet=this.createStyleSheet(doc,uri); styleSheet.setAttribute("id",uri); this.addStyleSheet(doc,styleSheet) }; this.addScript=function(doc,id,src){var element=doc.createElementNS("http://www.w3.org/1999/xhtml","html:script"); element.setAttribute("type","text/javascript"); element.setAttribute("id",id); if(!FBTrace.DBG_CONSOLE){FBL.unwrapObject(element).firebugIgnore=true }element.innerHTML=src; if(doc.documentElement){doc.documentElement.appendChild(element) }else{if(FBTrace.DBG_ERRORS){FBTrace.sysout("lib.addScript doc has no documentElement:",doc) }}return element }; this.getStyle=this.isIE?function(el,name){return el.currentStyle[name]||el.style[name]||undefined }:function(el,name){return el.ownerDocument.defaultView.getComputedStyle(el,null)[name]||el.style[name]||undefined }; var entityConversionLists=this.entityConversionLists={normal:{whitespace:{"\t":"\u200c\u2192","\n":"\u200c\u00b6","\r":"\u200c\u00ac"," ":"\u200c\u00b7"}},reverse:{whitespace:{"&Tab;":"\t","&NewLine;":"\n","\u200c\u2192":"\t","\u200c\u00b6":"\n","\u200c\u00ac":"\r","\u200c\u00b7":" "}}}; var normal=entityConversionLists.normal,reverse=entityConversionLists.reverse; function addEntityMapToList(ccode,entity){var lists=Array.prototype.slice.call(arguments,2),len=lists.length,ch=String.fromCharCode(ccode); for(var i=0; i<len; i++){var list=lists[i]; normal[list]=normal[list]||{}; normal[list][ch]="&"+entity+";"; reverse[list]=reverse[list]||{}; reverse[list]["&"+entity+";"]=ch }}var e=addEntityMapToList,white="whitespace",text="text",attr="attributes",css="css",editor="editor"; e(34,"quot",attr,css); e(38,"amp",attr,text,css); e(39,"apos",css); e(60,"lt",attr,text,css); e(62,"gt",attr,text,css); e(169,"copy",text,editor); e(174,"reg",text,editor); e(8482,"trade",text,editor); e(8210,"#8210",attr,text,editor); e(8211,"ndash",attr,text,editor); e(8212,"mdash",attr,text,editor); e(8213,"#8213",attr,text,editor); e(160,"nbsp",attr,text,white,editor); e(8194,"ensp",attr,text,white,editor); e(8195,"emsp",attr,text,white,editor); e(8201,"thinsp",attr,text,white,editor); e(8204,"zwnj",attr,text,white,editor); e(8205,"zwj",attr,text,white,editor); e(8206,"lrm",attr,text,white,editor); e(8207,"rlm",attr,text,white,editor); e(8203,"#8203",attr,text,white,editor); var entityConversionRegexes={normal:{},reverse:{}}; var escapeEntitiesRegEx={normal:function(list){var chars=[]; for(var ch in list){chars.push(ch) }return new RegExp("(["+chars.join("")+"])","gm") },reverse:function(list){var chars=[]; for(var ch in list){chars.push(ch) }return new RegExp("("+chars.join("|")+")","gm") }}; function getEscapeRegexp(direction,lists){var name="",re; var groups=[].concat(lists); for(i=0; i<groups.length; i++){name+=groups[i].group }re=entityConversionRegexes[direction][name]; if(!re){var list={}; if(groups.length>1){for(var i=0; i<groups.length; i++){var aList=entityConversionLists[direction][groups[i].group]; for(var item in aList){list[item]=aList[item] }}}else{if(groups.length==1){list=entityConversionLists[direction][groups[0].group] }else{list={} }}re=entityConversionRegexes[direction][name]=escapeEntitiesRegEx[direction](list) }return re }function createSimpleEscape(name,direction){return function(value){var list=entityConversionLists[direction][name]; return String(value).replace(getEscapeRegexp(direction,{group:name,list:list}),function(ch){return list[ch] }) } }function escapeGroupsForEntities(str,lists){lists=[].concat(lists); var re=getEscapeRegexp("normal",lists),split=String(str).split(re),len=split.length,results=[],cur,r,i,ri=0,l,list,last=""; if(!len){return[{str:String(str),group:"",name:""}] }for(i=0; i<len; i++){cur=split[i]; if(cur==""){continue }for(l=0; l<lists.length; l++){list=lists[l]; r=entityConversionLists.normal[list.group][cur]; if(r){results[ri]={str:r,"class":list["class"],extra:list.extra[cur]?list["class"]+list.extra[cur]:""}; break }}if(!r){results[ri]={str:cur,"class":"",extra:""} }ri++ }return results }this.escapeGroupsForEntities=escapeGroupsForEntities; function unescapeEntities(str,lists){var re=getEscapeRegexp("reverse",lists),split=String(str).split(re),len=split.length,results=[],cur,r,i,ri=0,l,list; if(!len){return str }lists=[].concat(lists); for(i=0; i<len; i++){cur=split[i]; if(cur==""){continue }for(l=0; l<lists.length; l++){list=lists[l]; r=entityConversionLists.reverse[list.group][cur]; if(r){results[ri]=r; break }}if(!r){results[ri]=cur }ri++ }return results.join("")||"" }var escapeForTextNode=this.escapeForTextNode=createSimpleEscape("text","normal"); var escapeForHtmlEditor=this.escapeForHtmlEditor=createSimpleEscape("editor","normal"); var escapeForElementAttribute=this.escapeForElementAttribute=createSimpleEscape("attributes","normal"); var escapeForCss=this.escapeForCss=createSimpleEscape("css","normal"); var escapeForSourceLine=this.escapeForSourceLine=createSimpleEscape("text","normal"); var unescapeWhitespace=createSimpleEscape("whitespace","reverse"); this.unescapeForTextNode=function(str){if(Firebug.showTextNodesWithWhitespace){str=unescapeWhitespace(str) }if(!Firebug.showTextNodesWithEntities){str=escapeForElementAttribute(str) }return str }; this.escapeNewLines=function(value){return value.replace(/\r/g,"\\r").replace(/\n/g,"\\n") }; this.stripNewLines=function(value){return typeof(value)=="string"?value.replace(/[\r\n]/g," "):value }; this.escapeJS=function(value){return value.replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace('"','\\"',"g") }; function escapeHTMLAttribute(value){function replaceChars(ch){switch(ch){case"&":return"&amp;"; case"'":return apos; case'"':return quot }return"?" }var apos="&#39;",quot="&quot;",around='"'; if(value.indexOf('"')==-1){quot='"'; apos="'" }else{if(value.indexOf("'")==-1){quot='"'; around="'" }}return around+(String(value).replace(/[&'"]/g,replaceChars))+around }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) }this.escapeHTML=escapeHTML; this.cropString=function(text,limit){text=text+""; if(!limit){var halfLimit=50 }else{var halfLimit=limit/2 }if(text.length>limit){return this.escapeNewLines(text.substr(0,halfLimit)+"..."+text.substr(text.length-halfLimit)) }else{return this.escapeNewLines(text) }}; this.isWhitespace=function(text){return !reNotWhitespace.exec(text) }; this.splitLines=function(text){var reSplitLines2=/.*(:?\r\n|\n|\r)?/mg; var lines; if(text.match){lines=text.match(reSplitLines2) }else{var str=text+""; lines=str.match(reSplitLines2) }lines.pop(); return lines }; this.safeToString=function(ob){if(this.isIE){return ob+"" }try{if(ob&&"toString" in ob&&typeof ob.toString=="function"){return ob.toString() }}catch(exc){return ob+"" }}; this.hasProperties=function(ob){try{for(var name in ob){return true }}catch(exc){}return false }; var reTrim=/^\s+|\s+$/g; this.trim=function(s){return s.replace(reTrim,"") }; this.emptyFn=function(){}; this.isVisible=function(elt){return this.getStyle(elt,"visibility")!="hidden"&&(elt.offsetWidth>0||elt.offsetHeight>0||elt.tagName in invisibleTags||elt.namespaceURI=="http://www.w3.org/2000/svg"||elt.namespaceURI=="http://www.w3.org/1998/Math/MathML") }; this.collapse=function(elt,collapsed){if(this.isIElt8){if(collapsed){this.setClass(elt,"collapsed") }else{this.removeClass(elt,"collapsed") }}else{elt.setAttribute("collapsed",collapsed?"true":"false") }}; this.obscure=function(elt,obscured){if(obscured){this.setClass(elt,"obscured") }else{this.removeClass(elt,"obscured") }}; this.hide=function(elt,hidden){elt.style.visibility=hidden?"hidden":"visible" }; this.clearNode=function(node){var nodeName=" "+node.nodeName.toLowerCase()+" "; var ignoreTags=" table tbody thead tfoot th tr td "; if(this.isIE&&ignoreTags.indexOf(nodeName)!=-1){this.eraseNode(node) }else{node.innerHTML="" }}; this.eraseNode=function(node){while(node.lastChild){node.removeChild(node.lastChild) }}; this.iterateWindows=function(win,handler){if(!win||!win.document){return }handler(win); if(win==top||!win.frames){return }for(var i=0; i<win.frames.length; ++i){var subWin=win.frames[i]; if(subWin!=win){this.iterateWindows(subWin,handler) }}}; this.getRootWindow=function(win){for(; win; win=win.parent){if(!win.parent||win==win.parent||!this.instanceOf(win.parent,"Window")){return win }}return null }; this.getClientOffset=function(elt){var addOffset=function addOffset(elt,coords,view){var p=elt.offsetParent; var style=isIE?elt.currentStyle:view.getComputedStyle(elt,""); if(elt.offsetLeft){coords.x+=elt.offsetLeft+parseInt(style.borderLeftWidth) }if(elt.offsetTop){coords.y+=elt.offsetTop+parseInt(style.borderTopWidth) }if(p){if(p.nodeType==1){addOffset(p,coords,view) }}else{var otherView=isIE?elt.ownerDocument.parentWindow:elt.ownerDocument.defaultView; if(otherView.frameElement){addOffset(otherView.frameElement,coords,otherView) }}}; var isIE=this.isIE; var coords={x:0,y:0}; if(elt){var view=isIE?elt.ownerDocument.parentWindow:elt.ownerDocument.defaultView; addOffset(elt,coords,view) }return coords }; this.getViewOffset=function(elt,singleFrame){function addOffset(elt,coords,view){var p=elt.offsetParent; coords.x+=elt.offsetLeft-(p?p.scrollLeft:0); coords.y+=elt.offsetTop-(p?p.scrollTop:0); if(p){if(p.nodeType==1){var parentStyle=view.getComputedStyle(p,""); if(parentStyle.position!="static"){coords.x+=parseInt(parentStyle.borderLeftWidth); coords.y+=parseInt(parentStyle.borderTopWidth); if(p.localName=="TABLE"){coords.x+=parseInt(parentStyle.paddingLeft); coords.y+=parseInt(parentStyle.paddingTop) }else{if(p.localName=="BODY"){var style=view.getComputedStyle(elt,""); coords.x+=parseInt(style.marginLeft); coords.y+=parseInt(style.marginTop) }}}else{if(p.localName=="BODY"){coords.x+=parseInt(parentStyle.borderLeftWidth); coords.y+=parseInt(parentStyle.borderTopWidth) }}var parent=elt.parentNode; while(p!=parent){coords.x-=parent.scrollLeft; coords.y-=parent.scrollTop; parent=parent.parentNode }addOffset(p,coords,view) }}else{if(elt.localName=="BODY"){var style=view.getComputedStyle(elt,""); coords.x+=parseInt(style.borderLeftWidth); coords.y+=parseInt(style.borderTopWidth); var htmlStyle=view.getComputedStyle(elt.parentNode,""); coords.x-=parseInt(htmlStyle.paddingLeft); coords.y-=parseInt(htmlStyle.paddingTop) }if(elt.scrollLeft){coords.x+=elt.scrollLeft }if(elt.scrollTop){coords.y+=elt.scrollTop }var win=elt.ownerDocument.defaultView; if(win&&(!singleFrame&&win.frameElement)){addOffset(win.frameElement,coords,win) }}}var coords={x:0,y:0}; if(elt){addOffset(elt,coords,elt.ownerDocument.defaultView) }return coords }; this.getLTRBWH=function(elt){var bcrect,dims={left:0,top:0,right:0,bottom:0,width:0,height:0}; if(elt){bcrect=elt.getBoundingClientRect(); dims.left=bcrect.left; dims.top=bcrect.top; dims.right=bcrect.right; dims.bottom=bcrect.bottom; if(bcrect.width){dims.width=bcrect.width; dims.height=bcrect.height }else{dims.width=dims.right-dims.left; dims.height=dims.bottom-dims.top }}return dims }; this.applyBodyOffsets=function(elt,clientRect){var od=elt.ownerDocument; if(!od.body){return clientRect }var style=od.defaultView.getComputedStyle(od.body,null); var pos=style.getPropertyValue("position"); if(pos==="absolute"||pos==="relative"){var borderLeft=parseInt(style.getPropertyValue("border-left-width").replace("px",""),10)||0; var borderTop=parseInt(style.getPropertyValue("border-top-width").replace("px",""),10)||0; var paddingLeft=parseInt(style.getPropertyValue("padding-left").replace("px",""),10)||0; var paddingTop=parseInt(style.getPropertyValue("padding-top").replace("px",""),10)||0; var marginLeft=parseInt(style.getPropertyValue("margin-left").replace("px",""),10)||0; var marginTop=parseInt(style.getPropertyValue("margin-top").replace("px",""),10)||0; var offsetX=borderLeft+paddingLeft+marginLeft; var offsetY=borderTop+paddingTop+marginTop; clientRect.left-=offsetX; clientRect.top-=offsetY; clientRect.right-=offsetX; clientRect.bottom-=offsetY }return clientRect }; this.getOffsetSize=function(elt){return{width:elt.offsetWidth,height:elt.offsetHeight} }; this.getOverflowParent=function(element){for(var scrollParent=element.parentNode; scrollParent; scrollParent=scrollParent.offsetParent){if(scrollParent.scrollHeight>scrollParent.offsetHeight){return scrollParent }}}; this.isScrolledToBottom=function(element){var onBottom=(element.scrollTop+element.offsetHeight)==element.scrollHeight; if(FBTrace.DBG_CONSOLE){FBTrace.sysout("isScrolledToBottom offsetHeight: "+element.offsetHeight+" onBottom:"+onBottom) }return onBottom }; this.scrollToBottom=function(element){element.scrollTop=element.scrollHeight; if(FBTrace.DBG_CONSOLE){FBTrace.sysout("scrollToBottom reset scrollTop "+element.scrollTop+" = "+element.scrollHeight); if(element.scrollHeight==element.offsetHeight){FBTrace.sysout("scrollToBottom attempt to scroll non-scrollable element "+element,element) }}return(element.scrollTop==element.scrollHeight) }; this.move=function(element,x,y){element.style.left=x+"px"; element.style.top=y+"px" }; this.resize=function(element,w,h){element.style.width=w+"px"; element.style.height=h+"px" }; this.linesIntoCenterView=function(element,scrollBox){if(!scrollBox){scrollBox=this.getOverflowParent(element) }if(!scrollBox){return }var offset=this.getClientOffset(element); var topSpace=offset.y-scrollBox.scrollTop; var bottomSpace=(scrollBox.scrollTop+scrollBox.clientHeight)-(offset.y+element.offsetHeight); if(topSpace<0||bottomSpace<0){var split=(scrollBox.clientHeight/2); var centerY=offset.y-split; scrollBox.scrollTop=centerY; topSpace=split; bottomSpace=split-element.offsetHeight }return{before:Math.round((topSpace/element.offsetHeight)+0.5),after:Math.round((bottomSpace/element.offsetHeight)+0.5)} }; this.scrollIntoCenterView=function(element,scrollBox,notX,notY){if(!element){return }if(!scrollBox){scrollBox=this.getOverflowParent(element) }if(!scrollBox){return }var offset=this.getClientOffset(element); if(!notY){var topSpace=offset.y-scrollBox.scrollTop; var bottomSpace=(scrollBox.scrollTop+scrollBox.clientHeight)-(offset.y+element.offsetHeight); if(topSpace<0||bottomSpace<0){var centerY=offset.y-(scrollBox.clientHeight/2); scrollBox.scrollTop=centerY }}if(!notX){var leftSpace=offset.x-scrollBox.scrollLeft; var rightSpace=(scrollBox.scrollLeft+scrollBox.clientWidth)-(offset.x+element.clientWidth); if(leftSpace<0||rightSpace<0){var centerX=offset.x-(scrollBox.clientWidth/2); scrollBox.scrollLeft=centerX }}if(FBTrace.DBG_SOURCEFILES){FBTrace.sysout("lib.scrollIntoCenterView ","Element:"+element.innerHTML) }}; var cssKeywordMap=null; var cssPropNames=null; var cssColorNames=null; var imageRules=null; this.getCSSKeywordsByProperty=function(propName){if(!cssKeywordMap){cssKeywordMap={}; for(var name in this.cssInfo){var list=[]; var types=this.cssInfo[name]; for(var i=0; i<types.length; ++i){var keywords=this.cssKeywords[types[i]]; if(keywords){list.push.apply(list,keywords) }}cssKeywordMap[name]=list }}return propName in cssKeywordMap?cssKeywordMap[propName]:[] }; this.getCSSPropertyNames=function(){if(!cssPropNames){cssPropNames=[]; for(var name in this.cssInfo){cssPropNames.push(name) }}return cssPropNames }; this.isColorKeyword=function(keyword){if(keyword=="transparent"){return false }if(!cssColorNames){cssColorNames=[]; var colors=this.cssKeywords.color; for(var i=0; i<colors.length; ++i){cssColorNames.push(colors[i].toLowerCase()) }var systemColors=this.cssKeywords.systemColor; for(var i=0; i<systemColors.length; ++i){cssColorNames.push(systemColors[i].toLowerCase()) }}return cssColorNames.indexOf?cssColorNames.indexOf(keyword.toLowerCase())!=-1:(" "+cssColorNames.join(" ")+" ").indexOf(" "+keyword.toLowerCase()+" ")!=-1 }; this.isImageRule=function(rule){if(!imageRules){imageRules=[]; for(var i in this.cssInfo){var r=i.toLowerCase(); var suffix="image"; if(r.match(suffix+"$")==suffix||r=="background"){imageRules.push(r) }}}return imageRules.indexOf?imageRules.indexOf(rule.toLowerCase())!=-1:(" "+imageRules.join(" ")+" ").indexOf(" "+rule.toLowerCase()+" ")!=-1 }; this.copyTextStyles=function(fromNode,toNode,style){var view=this.isIE?fromNode.ownerDocument.parentWindow:fromNode.ownerDocument.defaultView; if(view){if(!style){style=this.isIE?fromNode.currentStyle:view.getComputedStyle(fromNode,"") }toNode.style.fontFamily=style.fontFamily; toNode.style.fontSize=style.fontSize; toNode.style.fontWeight=style.fontWeight; toNode.style.fontStyle=style.fontStyle; return style }}; this.copyBoxStyles=function(fromNode,toNode,style){var view=this.isIE?fromNode.ownerDocument.parentWindow:fromNode.ownerDocument.defaultView; if(view){if(!style){style=this.isIE?fromNode.currentStyle:view.getComputedStyle(fromNode,"") }toNode.style.marginTop=style.marginTop; toNode.style.marginRight=style.marginRight; toNode.style.marginBottom=style.marginBottom; toNode.style.marginLeft=style.marginLeft; toNode.style.borderTopWidth=style.borderTopWidth; toNode.style.borderRightWidth=style.borderRightWidth; toNode.style.borderBottomWidth=style.borderBottomWidth; toNode.style.borderLeftWidth=style.borderLeftWidth; return style }}; this.readBoxStyles=function(style){var styleNames={"margin-top":"marginTop","margin-right":"marginRight","margin-left":"marginLeft","margin-bottom":"marginBottom","border-top-width":"borderTop","border-right-width":"borderRight","border-left-width":"borderLeft","border-bottom-width":"borderBottom","padding-top":"paddingTop","padding-right":"paddingRight","padding-left":"paddingLeft","padding-bottom":"paddingBottom","z-index":"zIndex"}; var styles={}; for(var styleName in styleNames){styles[styleNames[styleName]]=parseInt(style.getPropertyCSSValue(styleName).cssText)||0 }if(FBTrace.DBG_INSPECT){FBTrace.sysout("readBoxStyles ",styles) }return styles }; this.getBoxFromStyles=function(style,element){var args=this.readBoxStyles(style); args.width=element.offsetWidth-(args.paddingLeft+args.paddingRight+args.borderLeft+args.borderRight); args.height=element.offsetHeight-(args.paddingTop+args.paddingBottom+args.borderTop+args.borderBottom); return args }; this.getElementCSSSelector=function(element){var label=element.localName.toLowerCase(); if(element.id){label+="#"+element.id }if(element.hasAttribute("class")){label+="."+element.getAttribute("class").split(" ")[0] }return label }; this.getURLForStyleSheet=function(styleSheet){return(styleSheet.href?styleSheet.href:styleSheet.ownerNode.ownerDocument.URL) }; this.getDocumentForStyleSheet=function(styleSheet){while(styleSheet.parentStyleSheet&&!styleSheet.ownerNode){styleSheet=styleSheet.parentStyleSheet }if(styleSheet.ownerNode){return styleSheet.ownerNode.ownerDocument }}; this.getInstanceForStyleSheet=function(styleSheet,ownerDocument){if(FBL.isSystemStyleSheet(styleSheet)){return 0 }if(FBTrace.DBG_CSS){FBTrace.sysout("getInstanceForStyleSheet: "+styleSheet.href+" "+styleSheet.media.mediaText+" "+(styleSheet.ownerNode&&FBL.getElementXPath(styleSheet.ownerNode)),ownerDocument) }ownerDocument=ownerDocument||FBL.getDocumentForStyleSheet(styleSheet); var ret=0,styleSheets=ownerDocument.styleSheets,href=styleSheet.href; for(var i=0; i<styleSheets.length; i++){var curSheet=styleSheets[i]; if(FBTrace.DBG_CSS){FBTrace.sysout("getInstanceForStyleSheet: compare href "+i+" "+curSheet.href+" "+curSheet.media.mediaText+" "+(curSheet.ownerNode&&FBL.getElementXPath(curSheet.ownerNode))) }if(curSheet==styleSheet){break }if(curSheet.href==href){ret++ }}return ret }; var getElementType=this.getElementType=function(node){if(isElementXUL(node)){return"xul" }else{if(isElementSVG(node)){return"svg" }else{if(isElementMathML(node)){return"mathml" }else{if(isElementXHTML(node)){return"xhtml" }else{if(isElementHTML(node)){return"html" }}}}}}; var getElementSimpleType=this.getElementSimpleType=function(node){if(isElementSVG(node)){return"svg" }else{if(isElementMathML(node)){return"mathml" }else{return"html" }}}; var isElementHTML=this.isElementHTML=function(node){return node.nodeName==node.nodeName.toUpperCase() }; var isElementXHTML=this.isElementXHTML=function(node){return node.nodeName==node.nodeName.toLowerCase() }; var isElementMathML=this.isElementMathML=function(node){return node.namespaceURI=="http://www.w3.org/1998/Math/MathML" }; var isElementSVG=this.isElementSVG=function(node){return node.namespaceURI=="http://www.w3.org/2000/svg" }; var isElementXUL=this.isElementXUL=function(node){return node instanceof XULElement }; this.isSelfClosing=function(element){if(isElementSVG(element)||isElementMathML(element)){return true }var tag=element.localName.toLowerCase(); return(this.selfClosingTags.hasOwnProperty(tag)) }; this.getElementHTML=function(element){var self=this; function toHTML(elt){if(elt.nodeType==Node.ELEMENT_NODE){if(unwrapObject(elt).firebugIgnore){return }html.push("<",elt.nodeName.toLowerCase()); for(var i=0; i<elt.attributes.length; ++i){var attr=elt.attributes[i]; if(attr.localName.indexOf("firebug-")==0){continue }if(attr.localName.indexOf("-moz-math")==0){continue }html.push(" ",attr.nodeName,'="',escapeForElementAttribute(attr.nodeValue),'"') }if(elt.firstChild){html.push(">"); var pureText=true; for(var child=element.firstChild; child; child=child.nextSibling){pureText=pureText&&(child.nodeType==Node.TEXT_NODE) }if(pureText){html.push(escapeForHtmlEditor(elt.textContent)) }else{for(var child=elt.firstChild; child; child=child.nextSibling){toHTML(child) }}html.push("</",elt.nodeName.toLowerCase(),">") }else{if(isElementSVG(elt)||isElementMathML(elt)){html.push("/>") }else{if(self.isSelfClosing(elt)){html.push((isElementXHTML(elt))?"/>":">") }else{html.push("></",elt.nodeName.toLowerCase(),">") }}}}else{if(elt.nodeType==Node.TEXT_NODE){html.push(escapeForTextNode(elt.textContent)) }else{if(elt.nodeType==Node.CDATA_SECTION_NODE){html.push("<![CDATA[",elt.nodeValue,"]]>") }else{if(elt.nodeType==Node.COMMENT_NODE){html.push("<!--",elt.nodeValue,"-->") }}}}}var html=[]; toHTML(element); return html.join("") }; this.getElementXML=function(element){function toXML(elt){if(elt.nodeType==Node.ELEMENT_NODE){if(unwrapObject(elt).firebugIgnore){return }xml.push("<",elt.nodeName.toLowerCase()); for(var i=0; i<elt.attributes.length; ++i){var attr=elt.attributes[i]; if(attr.localName.indexOf("firebug-")==0){continue }if(attr.localName.indexOf("-moz-math")==0){continue }xml.push(" ",attr.nodeName,'="',escapeForElementAttribute(attr.nodeValue),'"') }if(elt.firstChild){xml.push(">"); for(var child=elt.firstChild; child; child=child.nextSibling){toXML(child) }xml.push("</",elt.nodeName.toLowerCase(),">") }else{xml.push("/>") }}else{if(elt.nodeType==Node.TEXT_NODE){xml.push(elt.nodeValue) }else{if(elt.nodeType==Node.CDATA_SECTION_NODE){xml.push("<![CDATA[",elt.nodeValue,"]]>") }else{if(elt.nodeType==Node.COMMENT_NODE){xml.push("<!--",elt.nodeValue,"-->") }}}}}var xml=[]; toXML(element); return xml.join("") }; this.hasClass=function(node,name){if(arguments.length==2){return(" "+node.className+" ").indexOf(" "+name+" ")!=-1 }if(!node||node.nodeType!=1){return false }else{for(var i=1; i<arguments.length; ++i){var name=arguments[i]; var re=new RegExp("(^|\\s)"+name+"($|\\s)"); if(!re.exec(node.className)){return false }}return true }}; this.old_hasClass=function(node,name){if(!node||node.nodeType!=1){return false }else{for(var i=1; i<arguments.length; ++i){var name=arguments[i]; var re=new RegExp("(^|\\s)"+name+"($|\\s)"); if(!re.exec(node.className)){return false }}return true }}; this.setClass=function(node,name){if(node&&(" "+node.className+" ").indexOf(" "+name+" ")==-1){node.className+=" "+name }}; this.getClassValue=function(node,name){var re=new RegExp(name+"-([^ ]+)"); var m=re.exec(node.className); return m?m[1]:"" }; this.removeClass=function(node,name){if(node&&node.className){var index=node.className.indexOf(name); if(index>=0){var size=name.length; node.className=node.className.substr(0,index-1)+node.className.substr(index+size) }}}; this.toggleClass=function(elt,name){if((" "+elt.className+" ").indexOf(" "+name+" ")!=-1){this.removeClass(elt,name) }else{this.setClass(elt,name) }}; this.setClassTimed=function(elt,name,context,timeout){if(!timeout){timeout=1300 }if(elt.__setClassTimeout){context.clearTimeout(elt.__setClassTimeout) }else{this.setClass(elt,name) }elt.__setClassTimeout=context.setTimeout(function(){delete elt.__setClassTimeout; FBL.removeClass(elt,name) },timeout) }; this.cancelClassTimed=function(elt,name,context){if(elt.__setClassTimeout){FBL.removeClass(elt,name); context.clearTimeout(elt.__setClassTimeout); delete elt.__setClassTimeout }}; this.$=function(id,doc){if(doc){return doc.getElementById(id) }else{return FBL.Firebug.chrome.document.getElementById(id) }}; this.$$=function(selector,doc){if(doc||!FBL.Firebug.chrome){return FBL.Firebug.Selector(selector,doc) }else{return FBL.Firebug.Selector(selector,FBL.Firebug.chrome.document) }}; this.getChildByClass=function(node){for(var i=1; i<arguments.length; ++i){var className=arguments[i]; var child=node.firstChild; node=null; for(; child; child=child.nextSibling){if(this.hasClass(child,className)){node=child; break }}}return node }; this.getAncestorByClass=function(node,className){for(var parent=node; parent; parent=parent.parentNode){if(this.hasClass(parent,className)){return parent }}return null }; this.getElementsByClass=function(node,className){var result=[]; for(var child=node.firstChild; child; child=child.nextSibling){if(this.hasClass(child,className)){result.push(child) }}return result }; this.getElementByClass=function(node,className){var args=cloneArray(arguments); args.splice(0,1); for(var child=node.firstChild; child; child=child.nextSibling){var args1=cloneArray(args); args1.unshift(child); if(FBL.hasClass.apply(null,args1)){return child }else{var found=FBL.getElementByClass.apply(null,args1); if(found){return found }}}return null }; this.isAncestor=function(node,potentialAncestor){for(var parent=node; parent; parent=parent.parentNode){if(parent==potentialAncestor){return true }}return false }; this.getNextElement=function(node){while(node&&node.nodeType!=1){node=node.nextSibling }return node }; this.getPreviousElement=function(node){while(node&&node.nodeType!=1){node=node.previousSibling }return node }; this.getBody=function(doc){if(doc.body){return doc.body }var body=doc.getElementsByTagName("body")[0]; if(body){return body }return doc.firstChild }; this.findNextDown=function(node,criteria){if(!node){return null }for(var child=node.firstChild; child; child=child.nextSibling){if(criteria(child)){return child }var next=this.findNextDown(child,criteria); if(next){return next }}}; this.findPreviousUp=function(node,criteria){if(!node){return null }for(var child=node.lastChild; child; child=child.previousSibling){var next=this.findPreviousUp(child,criteria); if(next){return next }if(criteria(child)){return child }}}; this.findNext=function(node,criteria,upOnly,maxRoot){if(!node){return null }if(!upOnly){var next=this.findNextDown(node,criteria); if(next){return next }}for(var sib=node.nextSibling; sib; sib=sib.nextSibling){if(criteria(sib)){return sib }var next=this.findNextDown(sib,criteria); if(next){return next }}if(node.parentNode&&node.parentNode!=maxRoot){return this.findNext(node.parentNode,criteria,true) }}; this.findPrevious=function(node,criteria,downOnly,maxRoot){if(!node){return null }for(var sib=node.previousSibling; sib; sib=sib.previousSibling){var prev=this.findPreviousUp(sib,criteria); if(prev){return prev }if(criteria(sib)){return sib }}if(!downOnly){var next=this.findPreviousUp(node,criteria); if(next){return next }}if(node.parentNode&&node.parentNode!=maxRoot){if(criteria(node.parentNode)){return node.parentNode }return this.findPrevious(node.parentNode,criteria,true) }}; this.getNextByClass=function(root,state){var iter=function iter(node){return node.nodeType==1&&FBL.hasClass(node,state) }; return this.findNext(root,iter) }; this.getPreviousByClass=function(root,state){var iter=function iter(node){return node.nodeType==1&&FBL.hasClass(node,state) }; return this.findPrevious(root,iter) }; this.isElement=function(o){try{return o&&this.instanceOf(o,"Element") }catch(ex){return false }}; var appendFragment=null; this.appendInnerHTML=function(element,html,referenceElement){referenceElement=referenceElement||null; var doc=element.ownerDocument; if(doc.createRange){var range=doc.createRange(); range.selectNodeContents(element); var fragment=range.createContextualFragment(html); var firstChild=fragment.firstChild; element.insertBefore(fragment,referenceElement) }else{if(!appendFragment||appendFragment.ownerDocument!=doc){appendFragment=doc.createDocumentFragment() }var div=doc.createElement("div"); div.innerHTML=html; var firstChild=div.firstChild; while(div.firstChild){appendFragment.appendChild(div.firstChild) }element.insertBefore(appendFragment,referenceElement); div=null }return firstChild }; this.createElement=function(tagName,properties){properties=properties||{}; var doc=properties.document||FBL.Firebug.chrome.document; var element=doc.createElement(tagName); for(var name in properties){if(name!="document"){element[name]=properties[name] }}return element }; this.createGlobalElement=function(tagName,properties){properties=properties||{}; var doc=FBL.Env.browser.document; var element=this.NS&&doc.createElementNS?doc.createElementNS(FBL.NS,tagName):doc.createElement(tagName); for(var name in properties){var propname=name; if(FBL.isIE&&name=="class"){propname="className" }if(name!="document"){element.setAttribute(propname,properties[name]) }}return element }; this.safeGetWindowLocation=function(window){try{if(window){if(window.closed){return"(window.closed)" }if("location" in window){return window.location+"" }else{return"(no window.location)" }}else{return"(no context.window)" }}catch(exc){if(FBTrace.DBG_WINDOWS||FBTrace.DBG_ERRORS){FBTrace.sysout("TabContext.getWindowLocation failed "+exc,exc) }FBTrace.sysout("TabContext.getWindowLocation failed window:",window); return"(getWindowLocation: "+exc+")" }}; this.isLeftClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==1:event.button==0)&&this.noKeyModifiers(event) }; this.isMiddleClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==4:event.button==1)&&this.noKeyModifiers(event) }; this.isRightClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==2:event.button==2)&&this.noKeyModifiers(event) }; this.noKeyModifiers=function(event){return !event.ctrlKey&&!event.shiftKey&&!event.altKey&&!event.metaKey }; this.isControlClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==1:event.button==0)&&this.isControl(event) }; this.isShiftClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==1:event.button==0)&&this.isShift(event) }; this.isControl=function(event){return(event.metaKey||event.ctrlKey)&&!event.shiftKey&&!event.altKey }; this.isAlt=function(event){return event.altKey&&!event.ctrlKey&&!event.shiftKey&&!event.metaKey }; this.isAltClick=function(event){return(this.isIE&&event.type!="click"&&event.type!="dblclick"?event.button==1:event.button==0)&&this.isAlt(event) }; this.isControlShift=function(event){return(event.metaKey||event.ctrlKey)&&event.shiftKey&&!event.altKey }; this.isShift=function(event){return event.shiftKey&&!event.metaKey&&!event.ctrlKey&&!event.altKey }; this.addEvent=function(object,name,handler,useCapture){if(object.addEventListener){object.addEventListener(name,handler,useCapture) }else{object.attachEvent("on"+name,handler) }}; this.removeEvent=function(object,name,handler,useCapture){try{if(object.removeEventListener){object.removeEventListener(name,handler,useCapture) }else{object.detachEvent("on"+name,handler) }}catch(e){if(FBTrace.DBG_ERRORS){FBTrace.sysout("FBL.removeEvent error: ",object,name) }}}; this.cancelEvent=function(e,preventDefault){if(!e){return }if(preventDefault){if(e.preventDefault){e.preventDefault() }else{e.returnValue=false }}if(e.stopPropagation){e.stopPropagation() }else{e.cancelBubble=true }}; this.addGlobalEvent=function(name,handler){var doc=this.Firebug.browser.document; var frames=this.Firebug.browser.window.frames; this.addEvent(doc,name,handler); if(this.Firebug.chrome.type=="popup"){this.addEvent(this.Firebug.chrome.document,name,handler) }for(var i=0,frame; frame=frames[i]; i++){try{this.addEvent(frame.document,name,handler) }catch(E){}}}; this.removeGlobalEvent=function(name,handler){var doc=this.Firebug.browser.document; var frames=this.Firebug.browser.window.frames; this.removeEvent(doc,name,handler); if(this.Firebug.chrome.type=="popup"){this.removeEvent(this.Firebug.chrome.document,name,handler) }for(var i=0,frame; frame=frames[i]; i++){try{this.removeEvent(frame.document,name,handler) }catch(E){}}}; this.dispatch=function(listeners,name,args){if(!listeners){return }try{if(typeof listeners.length!="undefined"){if(FBTrace.DBG_DISPATCH){FBTrace.sysout("FBL.dispatch",name+" to "+listeners.length+" listeners") }for(var i=0; i<listeners.length; ++i){var listener=listeners[i]; if(listener[name]){listener[name].apply(listener,args) }}}else{if(FBTrace.DBG_DISPATCH){FBTrace.sysout("FBL.dispatch",name+" to listeners of an object") }for(var prop in listeners){var listener=listeners[prop]; if(listener[name]){listener[name].apply(listener,args) }}}}catch(exc){if(FBTrace.DBG_ERRORS){FBTrace.sysout(" Exception in lib.dispatch "+name,exc) }}}; var disableTextSelectionHandler=function(event){FBL.cancelEvent(event,true); return false }; this.disableTextSelection=function(e){if(typeof e.onselectstart!="undefined"){this.addEvent(e,"selectstart",disableTextSelectionHandler) }else{e.style.cssText="user-select: none; -khtml-user-select: none; -moz-user-select: none;"; if(!this.isFirefox){this.addEvent(e,"mousedown",disableTextSelectionHandler) }}e.style.cursor="default" }; this.restoreTextSelection=function(e){if(typeof e.onselectstart!="undefined"){this.removeEvent(e,"selectstart",disableTextSelectionHandler) }else{e.style.cssText="cursor: default;"; if(!this.isFirefox){this.removeEvent(e,"mousedown",disableTextSelectionHandler) }}}; var eventTypes={composition:["composition","compositionstart","compositionend"],contextmenu:["contextmenu"],drag:["dragenter","dragover","dragexit","dragdrop","draggesture"],focus:["focus","blur"],form:["submit","reset","change","select","input"],key:["keydown","keyup","keypress"],load:["load","beforeunload","unload","abort","error"],mouse:["mousedown","mouseup","click","dblclick","mouseover","mouseout","mousemove"],mutation:["DOMSubtreeModified","DOMNodeInserted","DOMNodeRemoved","DOMNodeRemovedFromDocument","DOMNodeInsertedIntoDocument","DOMAttrModified","DOMCharacterDataModified"],paint:["paint","resize","scroll"],scroll:["overflow","underflow","overflowchanged"],text:["text"],ui:["DOMActivate","DOMFocusIn","DOMFocusOut"],xul:["popupshowing","popupshown","popuphiding","popuphidden","close","command","broadcast","commandupdate"]}; this.getEventFamily=function(eventType){if(!this.families){this.families={}; for(var family in eventTypes){var types=eventTypes[family]; for(var i=0; i<types.length; ++i){this.families[types[i]]=family }}}return this.families[eventType] }; this.getFileName=function(url){var split=this.splitURLBase(url); return split.name }; this.splitURLBase=function(url){if(this.isDataURL(url)){return this.splitDataURL(url) }return this.splitURLTrue(url) }; this.splitDataURL=function(url){var mark=url.indexOf(":",3); if(mark!=4){return false }var point=url.indexOf(",",mark+1); if(point<mark){return false }var props={encodedContent:url.substr(point+1)}; var metadataBuffer=url.substr(mark+1,point); var metadata=metadataBuffer.split(";"); for(var i=0; i<metadata.length; i++){var nv=metadata[i].split("="); if(nv.length==2){props[nv[0]]=nv[1] }}if(props.hasOwnProperty("fileName")){var caller_URL=decodeURIComponent(props.fileName); var caller_split=this.splitURLTrue(caller_URL); if(props.hasOwnProperty("baseLineNumber")){props.path=caller_split.path; props.line=props.baseLineNumber; var hint=decodeURIComponent(props.encodedContent.substr(0,200)).replace(/\s*$/,""); props.name="eval->"+hint }else{props.name=caller_split.name; props.path=caller_split.path }}else{if(!props.hasOwnProperty("path")){props.path="data:" }if(!props.hasOwnProperty("name")){props.name=decodeURIComponent(props.encodedContent.substr(0,200)).replace(/\s*$/,"") }}return props }; this.splitURLTrue=function(url){var m=reSplitFile.exec(url); if(!m){return{name:url,path:url} }else{if(!m[2]){return{path:m[1],name:m[1]} }else{return{path:m[1],name:m[2]+m[3]} }}}; this.getFileExtension=function(url){if(!url){return null }var queryString=url.indexOf("?"); if(queryString!=-1){url=url.substr(0,queryString) }var lastDot=url.lastIndexOf("."); return url.substr(lastDot+1) }; this.isSystemURL=function(url){if(!url){return true }if(url.length==0){return true }if(url[0]=="h"){return false }if(url.substr(0,9)=="resource:"){return true }else{if(url.substr(0,16)=="chrome://firebug"){return true }else{if(url=="XPCSafeJSObjectWrapper.cpp"){return true }else{if(url.substr(0,6)=="about:"){return true }else{if(url.indexOf("firebug-service.js")!=-1){return true }else{return false }}}}}}; this.isSystemPage=function(win){try{var doc=win.document; if(!doc){return false }if((doc.styleSheets.length&&doc.styleSheets[0].href=="chrome://global/content/xml/XMLPrettyPrint.css")||(doc.styleSheets.length>1&&doc.styleSheets[1].href=="chrome://browser/skin/feeds/subscribe.css")){return true }return FBL.isSystemURL(win.location.href) }catch(exc){ERROR("tabWatcher.isSystemPage document not ready:"+exc); return false }}; this.isSystemStyleSheet=function(sheet){var href=sheet&&sheet.href; return href&&FBL.isSystemURL(href) }; this.getURIHost=function(uri){try{if(uri){return uri.host }else{return"" }}catch(exc){return"" }}; this.isLocalURL=function(url){if(url.substr(0,5)=="file:"){return true }else{if(url.substr(0,8)=="wyciwyg:"){return true }else{return false }}}; this.isDataURL=function(url){return(url&&url.substr(0,5)=="data:") }; this.getLocalPath=function(url){if(this.isLocalURL(url)){var fileHandler=ioService.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler); var file=fileHandler.getFileFromURLSpec(url); return file.path }}; this.getURLFromLocalFile=function(file){var fileHandler=ioService.getProtocolHandler("file").QueryInterface(Ci.nsIFileProtocolHandler); var URL=fileHandler.getURLSpecFromFile(file); return URL }; this.getDataURLForContent=function(content,url){var uri="data:text/html;"; uri+="fileName="+encodeURIComponent(url)+","; uri+=encodeURIComponent(content); return uri },this.getDomain=function(url){var m=/[^:]+:\/{1,3}([^\/]+)/.exec(url); return m?m[1]:"" }; this.getURLPath=function(url){var m=/[^:]+:\/{1,3}[^\/]+(\/.*?)$/.exec(url); return m?m[1]:"" }; this.getPrettyDomain=function(url){var m=/[^:]+:\/{1,3}(www\.)?([^\/]+)/.exec(url); return m?m[2]:"" }; this.absoluteURL=function(url,baseURL){return this.absoluteURLWithDots(url,baseURL).replace("/./","/","g") }; this.absoluteURLWithDots=function(url,baseURL){if(url[0]=="?"){return baseURL+url }var reURL=/(([^:]+:)\/{1,2}[^\/]*)(.*?)$/; var m=reURL.exec(url); if(m){return url }var m=reURL.exec(baseURL); if(!m){return"" }var head=m[1]; var tail=m[3]; if(ur