OpenLayers OpenLayers

Ticket #507: debug.2.patch

File debug.2.patch, 99.1 kB (added by crschmidt, 1 year ago)
  • tests/list-tests.html

    old new  
    44    <li>BaseTypes/test_Size.html</li> 
    55    <li>BaseTypes/test_LonLat.html</li> 
    66    <li>BaseTypes/test_Bounds.html</li> 
     7    <li>BaseTypes/test_Console.html</li> 
    78    <li>test_Geometry.html</li> 
    89    <li>Geometry/test_Point.html</li> 
    910    <li>Geometry/test_Curve.html</li> 
  • lib/OpenLayers/BaseTypes.js

    old new  
    936936    return __method.call(object, event || window.event); 
    937937  } 
    938938}; 
     939 
     940/********************* 
     941 *                   * 
     942 *      CONSOLE      *  
     943 *                   *  
     944 *********************/ 
     945 
     946/** 
     947 * Create empty functions for all console methods.  The real value of these 
     948 * properties will be set if the Firebug/DebugOpenLayers.js script is included 
     949 * after OpenLayers.js. 
     950 */ 
     951 
     952OpenLayers.console = {}; 
     953(function() { 
     954    var methods = ['log', 'debug', 'info', 'warn', 'error', 'assert', 
     955                   'dir', 'dirxml', 'trace', 'group', 'groupEnd', 'time', 
     956                   'timeEnd', 'profile', 'profileEnd', 'count']; 
     957    for(var i=0; i<methods.length; ++i) { 
     958        OpenLayers.console[methods[i]] = function() {}; 
     959    } 
     960})(); 
  • lib/Firebug/DebugOpenLayers.js

    old new  
     1/** 
     2 * Include this script in your OpenLayers application after the OpenLayers.js 
     3 * script tag to get Firebug debugging in any browser.  With this script 
     4 * included, if a browser has the Firebug extension installed, calls to 
     5 * OpenLayers.console will get rerouted to console.  If a browser does not 
     6 * have the Firebug extension installed, this script mimics the behavior 
     7 * of that extension.  With this script included, the Firebug console can 
     8 * be opened with F12 or Ctrl+Shift+L (or ?+Shift+L on a Mac). 
     9 * 
     10 * This script is based on the firebug.js script from 
     11 * http://www.getfirebug.com/lite.html 
     12 * Modifications include putting the console object in the OpenLayers 
     13 * namespace, modifying getFirebugURL, and re-routing OpenLayers.console calls 
     14 * to console if the Firebug extension is installed. 
     15 */ 
     16 
     17 
     18if (("console" in window) && ("firebug" in console)) { 
     19    /** 
     20     * If the Firebug extension is installed, re-route all OpenLayers.console 
     21     * calls to the console object. 
     22     */ 
     23    OpenLayers.Util.extend(OpenLayers.console, console); 
     24} else { 
     25    /** 
     26     * An anonymous function is called here so that variables are not 
     27     * global in scope. 
     28     */ 
     29    (function() 
     30    { 
     31        OpenLayers.console =  
     32        { 
     33            log: function() 
     34            { 
     35                logFormatted(arguments, ""); 
     36            }, 
     37             
     38            debug: function() 
     39            { 
     40                logFormatted(arguments, "debug"); 
     41            }, 
     42             
     43            info: function() 
     44            { 
     45                logFormatted(arguments, "info"); 
     46            }, 
     47             
     48            warn: function() 
     49            { 
     50                logFormatted(arguments, "warning"); 
     51            }, 
     52             
     53            error: function() 
     54            { 
     55                logFormatted(arguments, "error"); 
     56            }, 
     57             
     58            assert: function(truth, message) 
     59            { 
     60                if (!truth) 
     61                { 
     62                    var args = []; 
     63                    for (var i = 1; i < arguments.length; ++i) 
     64                        args.push(arguments[i]); 
     65                     
     66                    logFormatted(args.length ? args : ["Assertion Failure"], "error"); 
     67                    throw message ? message : "Assertion Failure"; 
     68                } 
     69            }, 
     70             
     71            dir: function(object) 
     72            { 
     73                var html = []; 
     74                             
     75                var pairs = []; 
     76                for (var name in object) 
     77                { 
     78                    try 
     79                    { 
     80                        pairs.push([name, object[name]]); 
     81                    } 
     82                    catch (exc) 
     83                    { 
     84                    } 
     85                } 
     86                 
     87                pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; }); 
     88                 
     89                html.push('<table>'); 
     90                for (var i = 0; i < pairs.length; ++i) 
     91                { 
     92                    var name = pairs[i][0], value = pairs[i][1]; 
     93                     
     94                    html.push('<tr>',  
     95                    '<td class="propertyNameCell"><span class="propertyName">', 
     96                        escapeHTML(name), '</span></td>', '<td><span class="propertyValue">'); 
     97                    appendObject(value, html); 
     98                    html.push('</span></td></tr>'); 
     99                } 
     100                html.push('</table>'); 
     101                 
     102                logRow(html, "dir"); 
     103            }, 
     104             
     105            dirxml: function(node) 
     106            { 
     107                var html = []; 
     108                 
     109                appendNode(node, html); 
     110                logRow(html, "dirxml"); 
     111            }, 
     112             
     113            group: function() 
     114            { 
     115                logRow(arguments, "group", pushGroup); 
     116            }, 
     117             
     118            groupEnd: function() 
     119            { 
     120                logRow(arguments, "", popGroup); 
     121            }, 
     122             
     123            time: function(name) 
     124            { 
     125                timeMap[name] = (new Date()).getTime(); 
     126            }, 
     127             
     128            timeEnd: function(name) 
     129            { 
     130                if (name in timeMap) 
     131                { 
     132                    var delta = (new Date()).getTime() - timeMap[name]; 
     133                    logFormatted([name+ ":", delta+"ms"]); 
     134                    delete timeMap[name]; 
     135                } 
     136            }, 
     137             
     138            count: function() 
     139            { 
     140                this.warn(["count() not supported."]); 
     141            }, 
     142             
     143            trace: function() 
     144            { 
     145                this.warn(["trace() not supported."]); 
     146            }, 
     147             
     148            profile: function() 
     149            { 
     150                this.warn(["profile() not supported."]); 
     151            }, 
     152             
     153            profileEnd: function() 
     154            { 
     155            }, 
     156             
     157            clear: function() 
     158            { 
     159                consoleBody.innerHTML = ""; 
     160            }, 
     161     
     162            open: function() 
     163            { 
     164                toggleConsole(true); 
     165            }, 
     166             
     167            close: function() 
     168            { 
     169                if (frameVisible) 
     170                    toggleConsole(); 
     171            } 
     172        }; 
     173      
     174        // ******************************************************************************************** 
     175            
     176        var consoleFrame = null; 
     177        var consoleBody = null; 
     178        var commandLine = null; 
     179         
     180        var frameVisible = false; 
     181        var messageQueue = []; 
     182        var groupStack = []; 
     183        var timeMap = {}; 
     184         
     185        var clPrefix = ">>> "; 
     186         
     187        var isFirefox = navigator.userAgent.indexOf("Firefox") != -1; 
     188        var isIE = navigator.userAgent.indexOf("MSIE") != -1; 
     189        var isOpera = navigator.userAgent.indexOf("Opera") != -1; 
     190        var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1; 
     191     
     192        // ******************************************************************************************** 
     193     
     194        function toggleConsole(forceOpen) 
     195        { 
     196            frameVisible = forceOpen || !frameVisible; 
     197            if (consoleFrame) 
     198                consoleFrame.style.visibility = frameVisible ? "visible" : "hidden"; 
     199            else 
     200                waitForBody(); 
     201        } 
     202     
     203        function focusCommandLine() 
     204        { 
     205            toggleConsole(true); 
     206            if (commandLine) 
     207                commandLine.focus(); 
     208        } 
     209     
     210        function waitForBody() 
     211        { 
     212            if (document.body) 
     213                createFrame(); 
     214            else 
     215                setTimeout(waitForBody, 200); 
     216        }     
     217     
     218        function createFrame() 
     219        { 
     220            if (consoleFrame) 
     221                return; 
     222             
     223            window.onFirebugReady = function(doc) 
     224            { 
     225                window.onFirebugReady = null; 
     226     
     227                var toolbar = doc.getElementById("toolbar"); 
     228                toolbar.onmousedown = onSplitterMouseDown; 
     229     
     230                commandLine = doc.getElementById("commandLine"); 
     231                addEvent(commandLine, "keydown", onCommandLineKeyDown); 
     232     
     233                addEvent(doc, isIE || isSafari ? "keydown" : "keypress", onKeyDown); 
     234                 
     235                consoleBody = doc.getElementById("log"); 
     236                layout(); 
     237                flush(); 
     238            } 
     239     
     240            var baseURL = getFirebugURL(); 
     241     
     242            consoleFrame = document.createElement("iframe"); 
     243            consoleFrame.setAttribute("src", baseURL+"/firebug.html"); 
     244            consoleFrame.setAttribute("frameBorder", "0"); 
     245            consoleFrame.style.visibility = (frameVisible ? "visible" : "hidden");     
     246            consoleFrame.style.zIndex = "2147483647"; 
     247            consoleFrame.style.position = "fixed"; 
     248            consoleFrame.style.width = "100%"; 
     249            consoleFrame.style.left = "0"; 
     250            consoleFrame.style.bottom = "0"; 
     251            consoleFrame.style.height = "200px"; 
     252            document.body.appendChild(consoleFrame); 
     253        } 
     254         
     255        function getFirebugURL() 
     256        { 
     257            var scripts = document.getElementsByTagName("script"); 
     258            for (var i = 0; i < scripts.length; ++i) 
     259            { 
     260                if (scripts[i].src.indexOf("DebugOpenLayers.js") != -1) 
     261                { 
     262                    var lastSlash = scripts[i].src.lastIndexOf("/"); 
     263                    return scripts[i].src.substr(0, lastSlash); 
     264                } 
     265            } 
     266        } 
     267         
     268        function evalCommandLine() 
     269        { 
     270            var text = commandLine.value; 
     271            commandLine.value = ""; 
     272     
     273            logRow([clPrefix, text], "command"); 
     274             
     275            var value; 
     276            try 
     277            { 
     278                value = eval(text); 
     279            } 
     280            catch (exc) 
     281            { 
     282            } 
     283     
     284            OpenLayers.console.log(value); 
     285        } 
     286         
     287        function layout() 
     288        { 
     289            var toolbar = consoleBody.ownerDocument.getElementById("toolbar"); 
     290            var height = consoleFrame.offsetHeight - (toolbar.offsetHeight + commandLine.offsetHeight); 
     291            height = Math.max(height, 0); 
     292            consoleBody.style.top = toolbar.offsetHeight + "px"; 
     293            consoleBody.style.height = height + "px"; 
     294            commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px"; 
     295        } 
     296         
     297        function logRow(message, className, handler) 
     298        { 
     299            if (consoleBody) 
     300                writeMessage(message, className, handler); 
     301            else 
     302            { 
     303                messageQueue.push([message, className, handler]); 
     304                waitForBody(); 
     305            } 
     306        } 
     307         
     308        function flush() 
     309        { 
     310            var queue = messageQueue; 
     311            messageQueue = []; 
     312             
     313            for (var i = 0; i < queue.length; ++i) 
     314                writeMessage(queue[i][0], queue[i][1], queue[i][2]); 
     315        } 
     316     
     317        function writeMessage(message, className, handler) 
     318        { 
     319            var isScrolledToBottom = 
     320                consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight; 
     321     
     322            if (!handler) 
     323                handler = writeRow; 
     324             
     325            handler(message, className); 
     326             
     327            if (isScrolledToBottom) 
     328                consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight; 
     329        } 
     330         
     331        function appendRow(row) 
     332        { 
     333            var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody; 
     334            container.appendChild(row); 
     335        } 
     336     
     337        function writeRow(message, className) 
     338        { 
     339            var row = consoleBody.ownerDocument.createElement("div"); 
     340            row.className = "logRow" + (className ? " logRow-"+className : ""); 
     341            row.innerHTML = message.join(""); 
     342            appendRow(row); 
     343        } 
     344     
     345        function pushGroup(message, className) 
     346        { 
     347            logFormatted(message, className); 
     348     
     349            var groupRow = consoleBody.ownerDocument.createElement("div"); 
     350            groupRow.className = "logGroup"; 
     351            var groupRowBox = consoleBody.ownerDocument.createElement("div"); 
     352            groupRowBox.className = "logGroupBox"; 
     353            groupRow.appendChild(groupRowBox); 
     354            appendRow(groupRowBox); 
     355            groupStack.push(groupRowBox); 
     356        } 
     357     
     358        function popGroup() 
     359        { 
     360            groupStack.pop(); 
     361        } 
     362         
     363        // ******************************************************************************************** 
     364     
     365        function logFormatted(objects, className) 
     366        { 
     367            var html = []; 
     368     
     369            var format = objects[0]; 
     370            var objIndex = 0; 
     371     
     372            if (typeof(format) != "string") 
     373            { 
     374                format = ""; 
     375                objIndex = -1; 
     376            } 
     377     
     378            var parts = parseFormat(format); 
     379            for (var i = 0; i < parts.length; ++i) 
     380            { 
     381                var part = parts[i]; 
     382                if (part && typeof(part) == "object") 
     383                { 
     384                    var object = objects[++objIndex]; 
     385                    part.appender(object, html); 
     386                } 
     387                else 
     388                    appendText(part, html); 
     389            } 
     390     
     391            for (var i = objIndex+1; i < objects.length; ++i) 
     392            { 
     393                appendText(" ", html); 
     394                 
     395                var object = objects[i]; 
     396                if (typeof(object) == "string") 
     397                    appendText(object, html); 
     398                else 
     399                    appendObject(object, html); 
     400            } 
     401             
     402            logRow(html, className); 
     403        } 
     404     
     405        function parseFormat(format) 
     406        { 
     407            var parts = []; 
     408     
     409            var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;     
     410            var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat}; 
     411     
     412            for (var m = reg.exec(format); m; m = reg.exec(format)) 
     413            { 
     414                var type = m[8] ? m[8] : m[5]; 
     415                var appender = type in appenderMap ? appenderMap[type] : appendObject; 
     416                var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0); 
     417     
     418                parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1)); 
     419                parts.push({appender: appender, precision: precision}); 
     420     
     421                format = format.substr(m.index+m[0].length); 
     422            } 
     423     
     424            parts.push(format); 
     425     
     426            return parts; 
     427        } 
     428     
     429        function escapeHTML(value) 
     430        { 
     431            function replaceChars(ch) 
     432            { 
     433                switch (ch) 
     434                { 
     435                    case "<": 
     436                        return "&lt;"; 
     437                    case ">": 
     438                        return "&gt;"; 
     439                    case "&": 
     440                        return "&amp;"; 
     441                    case "'": 
     442                        return "&#39;"; 
     443                    case '"': 
     444                        return "&quot;"; 
     445                } 
     446                return "?"; 
     447            }; 
     448            return String(value).replace(/[<>&"']/g, replaceChars); 
     449        } 
     450     
     451        function objectToString(object) 
     452        { 
     453            try 
     454            { 
     455                return object+""; 
     456            } 
     457            catch (exc) 
     458            { 
     459                return null; 
     460            } 
     461        } 
     462     
     463        // ******************************************************************************************** 
     464     
     465        function appendText(object, html) 
     466        { 
     467            html.push(escapeHTML(objectToString(object))); 
     468        } 
     469     
     470        function appendNull(object, html) 
     471        { 
     472            html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>'); 
     473        } 
     474     
     475        function appendString(object, html) 
     476        { 
     477            html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)), 
     478                '&quot;</span>'); 
     479        } 
     480     
     481        function appendInteger(object, html) 
     482        { 
     483            html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>'); 
     484        } 
     485     
     486        function appendFloat(object, html) 
     487        { 
     488            html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>'); 
     489        } 
     490     
     491        function appendFunction(object, html) 
     492        { 
     493            var reName = /function ?(.*?)\(/; 
     494            var m = reName.exec(objectToString(object)); 
     495            var name = m ? m[1] : "function"; 
     496            html.push('<span class="objectBox-function">', escapeHTML(name), '()</span>'); 
     497        } 
     498         
     499        function appendObject(object, html) 
     500        { 
     501            try 
     502            { 
     503                if (object == undefined) 
     504                    appendNull("undefined", html); 
     505                else if (object == null) 
     506                    appendNull("null", html); 
     507                else if (typeof object == "string") 
     508                    appendString(object, html); 
     509                else if (typeof object == "number") 
     510                    appendInteger(object, html); 
     511                else if (typeof object == "function") 
     512                    appendFunction(object, html); 
     513                else if (object.nodeType == 1) 
     514                    appendSelector(object, html); 
     515                else if (typeof object == "object") 
     516                    appendObjectFormatted(object, html); 
     517                else 
     518                    appendText(object, html); 
     519            } 
     520            catch (exc) 
     521            { 
     522            } 
     523        } 
     524             
     525        function appendObjectFormatted(object, html) 
     526        { 
     527            var text = objectToString(object); 
     528            var reObject = /\[object (.*?)\]/; 
     529     
     530            var m = reObject.exec(text); 
     531            html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>') 
     532        } 
     533         
     534        function appendSelector(object, html) 
     535        { 
     536            html.push('<span class="objectBox-selector">'); 
     537     
     538            html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>'); 
     539            if (object.id) 
     540                html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>'); 
     541            if (object.className) 
     542                html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>'); 
     543     
     544            html.push('</span>'); 
     545        } 
     546     
     547        function appendNode(node, html) 
     548        { 
     549            if (node.nodeType == 1) 
     550            { 
     551                html.push( 
     552                    '<div class="objectBox-element">', 
     553                        '&lt;<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>'); 
     554     
     555                for (var i = 0; i < node.attributes.length; ++i) 
     556                { 
     557                    var attr = node.attributes[i]; 
     558                    if (!attr.specified) 
     559                        continue; 
     560                     
     561                    html.push('&nbsp;<span class="nodeName">', attr.nodeName.toLowerCase(), 
     562                        '</span>=&quot;<span class="nodeValue">', escapeHTML(attr.nodeValue), 
     563                        '</span>&quot;') 
     564                } 
     565     
     566                if (node.firstChild) 
     567                { 
     568                    html.push('&gt;</div><div class="nodeChildren">'); 
     569     
     570                    for (var child = node.firstChild; child; child = child.nextSibling) 
     571                        appendNode(child, html); 
     572                         
     573                    html.push('</div><div class="objectBox-element">&lt;/<span class="nodeTag">',  
     574                        node.nodeName.toLowerCase(), '&gt;</span></div>'); 
     575                } 
     576                else 
     577                    html.push('/&gt;</div>'); 
     578            } 
     579            else if (node.nodeType == 3) 
     580            { 
     581                html.push('<div class="nodeText">', escapeHTML(node.nodeValue), 
     582                    '</div>'); 
     583            } 
     584        } 
     585     
     586        // ******************************************************************************************** 
     587         
     588        function addEvent(object, name, handler) 
     589        { 
     590            if (document.all) 
     591                object.attachEvent("on"+name, handler); 
     592            else 
     593                object.addEventListener(name, handler, false); 
     594        } 
     595         
     596        function removeEvent(object, name, handler) 
     597        { 
     598            if (document.all) 
     599                object.detachEvent("on"+name, handler); 
     600            else 
     601                object.removeEventListener(name, handler, false); 
     602        } 
     603         
     604        function cancelEvent(event) 
     605        { 
     606            if (document.all) 
     607                event.cancelBubble = true; 
     608            else 
     609                event.stopPropagation();         
     610        } 
     611     
     612        function onError(msg, href, lineNo) 
     613        { 
     614            var html = []; 
     615             
     616            var lastSlash = href.lastIndexOf("/"); 
     617            var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1); 
     618             
     619            html.push( 
     620                '<span class="errorMessage">', msg, '</span>',  
     621                '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>' 
     622            ); 
     623             
     624            logRow(html, "error"); 
     625        }; 
     626     
     627        function onKeyDown(event) 
     628        { 
     629            if (event.keyCode == 123) 
     630                toggleConsole(); 
     631            else if ((event.keyCode == 108 || event.keyCode == 76) && event.shiftKey 
     632                     && (event.metaKey || event.ctrlKey)) 
     633                focusCommandLine(); 
     634            else 
     635                return; 
     636             
     637            cancelEvent(event); 
     638        } 
     639     
     640        function onSplitterMouseDown(event) 
     641        { 
     642            if (isSafari || isOpera) 
     643                return; 
     644             
     645            addEvent(document, "mousemove", onSplitterMouseMove); 
     646            addEvent(document, "mouseup", onSplitterMouseUp); 
     647     
     648            for (var i = 0; i < frames.length; ++i) 
     649            { 
     650                addEvent(frames[i].document, "mousemove", onSplitterMouseMove); 
     651                addEvent(frames[i].document, "mouseup", onSplitterMouseUp); 
     652            } 
     653        } 
     654         
     655        function onSplitterMouseMove(event) 
     656        { 
     657            var win = document.all 
     658                ? event.srcElement.ownerDocument.parentWindow 
     659                : event.target.ownerDocument.defaultView; 
     660     
     661            var clientY = event.clientY; 
     662            if (win != win.parent) 
     663                clientY += win.frameElement ? win.frameElement.offsetTop : 0; 
     664             
     665            var height = consoleFrame.offsetTop + consoleFrame.clientHeight; 
     666            var toolbar = consoleBody.ownerDocument.getElementById("toolbar"); 
     667            var y = Math.max(height - clientY, 
     668                             toolbar.offsetHeight + commandLine.offsetHeight); 
     669            consoleFrame.style.height = y + "px"; 
     670            layout(); 
     671        } 
     672         
     673        function onSplitterMouseUp(event) 
     674        { 
     675            removeEvent(document, "mousemove", onSplitterMouseMove); 
     676            removeEvent(document, "mouseup", onSplitterMouseUp); 
     677     
     678            for (var i = 0; i < frames.length; ++i) 
     679            { 
     680                removeEvent(frames[i].document, "mousemove", onSplitterMouseMove); 
     681                removeEvent(frames[i].document, "mouseup", onSplitterMouseUp); 
     682            } 
     683        } 
     684         
     685        function onCommandLineKeyDown(event) 
     686        { 
     687            if (event.keyCode == 13) 
     688                evalCommandLine(); 
     689            else if (event.keyCode == 27) 
     690                commandLine.value = ""; 
     691        } 
     692         
     693        window.onerror = onError; 
     694        addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown); 
     695         
     696        if (document.documentElement.getAttribute("debug") == "true") 
     697            toggleConsole(true); 
     698    })(); 
     699} 
     700/** 
     701 * Include this script in your OpenLayers application after the OpenLayers.js 
     702 * script tag to get Firebug debugging in any browser.  With this script 
     703 * included, if a browser has the Firebug extension installed, calls to 
     704 * OpenLayers.console will get rerouted to console.  If a browser does not 
     705 * have the Firebug extension installed, this script mimics the behavior 
     706 * of that extension.  With this script included, the Firebug console can 
     707 * be opened with F12 or Ctrl+Shift+L (or ?+Shift+L on a Mac). 
     708 * 
     709 * This script is based on the firebug.js script from 
     710 * http://www.getfirebug.com/lite.html 
     711 * Modifications include putting the console object in the OpenLayers 
     712 * namespace, modifying getFirebugURL, and re-routing OpenLayers.console calls 
     713 * to console if the Firebug extension is installed. 
     714 */ 
     715 
     716 
     717if (("console" in window) && ("firebug" in console)) { 
     718    /** 
     719     * If the Firebug extension is installed, re-route all OpenLayers.console 
     720     * calls to the console object. 
     721     */ 
     722    OpenLayers.Util.extend(OpenLayers.console, console); 
     723} else { 
     724    /** 
     725     * An anonymous function is called here so that variables are not 
     726     * global in scope. 
     727     */ 
     728    (function() 
     729    { 
     730        OpenLayers.console =  
     731        { 
     732            log: function() 
     733            { 
     734                logFormatted(arguments, ""); 
     735            }, 
     736             
     737            debug: function() 
     738            { 
     739                logFormatted(arguments, "debug"); 
     740            }, 
     741             
     742            info: function() 
     743            { 
     744                logFormatted(arguments, "info"); 
     745            }, 
     746             
     747            warn: function() 
     748            { 
     749                logFormatted(arguments, "warning"); 
     750            }, 
     751             
     752            error: function() 
     753            { 
     754                logFormatted(arguments, "error"); 
     755            }, 
     756             
     757            assert: function(truth, message) 
     758            { 
     759                if (!truth) 
     760                { 
     761                    var args = []; 
     762                    for (var i = 1; i < arguments.length; ++i) 
     763                        args.push(arguments[i]); 
     764                     
     765                    logFormatted(args.length ? args : ["Assertion Failure"], "error"); 
     766                    throw message ? message : "Assertion Failure"; 
     767                } 
     768            }, 
     769             
     770            dir: function(object) 
     771            { 
     772                var html = []; 
     773                             
     774                var pairs = []; 
     775                for (var name in object) 
     776                { 
     777                    try 
     778                    { 
     779                        pairs.push([name, object[name]]); 
     780                    } 
     781                    catch (exc) 
     782                    { 
     783                    } 
     784                } 
     785                 
     786                pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; }); 
     787                 
     788                html.push('<table>'); 
     789                for (var i = 0; i < pairs.length; ++i) 
     790                { 
     791                    var name = pairs[i][0], value = pairs[i][1]; 
     792                     
     793                    html.push('<tr>',  
     794                    '<td class="propertyNameCell"><span class="propertyName">', 
     795                        escapeHTML(name), '</span></td>', '<td><span class="propertyValue">'); 
     796                    appendObject(value, html); 
     797                    html.push('</span></td></tr>'); 
     798                } 
     799                html.push('</table>'); 
     800                 
     801                logRow(html, "dir"); 
     802            }, 
     803             
     804            dirxml: function(node) 
     805            { 
     806                var html = []; 
     807                 
     808                appendNode(node, html); 
     809                logRow(html, "dirxml"); 
     810            }, 
     811             
     812            group: function() 
     813            { 
     814                logRow(arguments, "group", pushGroup); 
     815            }, 
     816             
     817            groupEnd: function() 
     818            { 
     819                logRow(arguments, "", popGroup); 
     820            }, 
     821             
     822            time: function(name) 
     823            { 
     824                timeMap[name] = (new Date()).getTime(); 
     825            }, 
     826             
     827            timeEnd: function(name) 
     828            { 
     829                if (name in timeMap) 
     830                { 
     831                    var delta = (new Date()).getTime() - timeMap[name]; 
     832                    logFormatted([name+ ":", delta+"ms"]); 
     833                    delete timeMap[name]; 
     834                } 
     835            }, 
     836             
     837            count: function() 
     838            { 
     839                this.warn(["count() not supported."]); 
     840            }, 
     841             
     842            trace: function() 
     843            { 
     844                this.warn(["trace() not supported."]); 
     845            }, 
     846             
     847            profile: function() 
     848            { 
     849                this.warn(["profile() not supported."]); 
     850            }, 
     851             
     852            profileEnd: function() 
     853            { 
     854            }, 
     855             
     856            clear: function() 
     857            { 
     858                consoleBody.innerHTML = ""; 
     859            }, 
     860     
     861            open: function() 
     862            { 
     863                toggleConsole(true); 
     864            }, 
     865             
     866            close: function() 
     867            { 
     868                if (frameVisible) 
     869                    toggleConsole(); 
     870            } 
     871        }; 
     872      
     873        // ******************************************************************************************** 
     874            
     875        var consoleFrame = null; 
     876        var consoleBody = null; 
     877        var commandLine = null; 
     878         
     879        var frameVisible = false; 
     880        var messageQueue = []; 
     881        var groupStack = []; 
     882        var timeMap = {}; 
     883         
     884        var clPrefix = ">>> "; 
     885         
     886        var isFirefox = navigator.userAgent.indexOf("Firefox") != -1; 
     887        var isIE = navigator.userAgent.indexOf("MSIE") != -1; 
     888        var isOpera = navigator.userAgent.indexOf("Opera") != -1; 
     889        var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1; 
     890     
     891        // ******************************************************************************************** 
     892     
     893        function toggleConsole(forceOpen) 
     894        { 
     895            frameVisible = forceOpen || !frameVisible; 
     896            if (consoleFrame) 
     897                consoleFrame.style.visibility = frameVisible ? "visible" : "hidden"; 
     898            else 
     899                waitForBody(); 
     900        } 
     901     
     902        function focusCommandLine() 
     903        { 
     904            toggleConsole(true); 
     905            if (commandLine) 
     906                commandLine.focus(); 
     907        } 
     908     
     909        function waitForBody() 
     910        { 
     911            if (document.body) 
     912<