OpenLayers OpenLayers

Ticket #507: debug.5.patch

File debug.5.patch, 34.0 kB (added by tschaub, 1 year ago)

a complete patch

  • examples/debug.html

    old new  
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
     2         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     3<html xmlns="http://www.w3.org/1999/xhtml"> 
     4  <head> 
     5    <script src="../lib/Firebug/firebug.js"></script> 
     6    <script src="../lib/OpenLayers.js"></script> 
     7    <script type="text/javascript"> 
     8        <!-- 
     9        function consoleLog() { 
     10            OpenLayers.Console.log("This is the result of an OpenLayers.Console.log() call"); 
     11        } 
     12        function consoleWarn() { 
     13            OpenLayers.Console.warn("This is the result of an OpenLayers.Console.warn() call"); 
     14        } 
     15        function consoleError() { 
     16            OpenLayers.Console.error("This is the result of an OpenLayers.Console.error() call"); 
     17        } 
     18        function consoleDir() { 
     19            OpenLayers.Console.dir(OpenLayers); 
     20        } 
     21        function consoleDirxml() { 
     22            OpenLayers.Console.dirxml(document.getElementsByTagName('body')[0]); 
     23        } 
     24        // --> 
     25    </script> 
     26  </head> 
     27  <body> 
     28    <h1>OpenLayers Debug Example</h1> 
     29    <p>To run OpenLayers in debug mode, include the following script 
     30    tag <b>before</b> the tag that loads OpenLayers: 
     31    <pre> 
     32    &lt;script src="../lib/Firebug/firebug.js"&gt;&lt;/script&gt; 
     33    </pre> 
     34    The path to firebug.js must be relative to your 
     35    html file.  With this script included calls to OpenLayers.Console 
     36    will be displayed in the Firebug console.  For browsers without 
     37    the Firebug extension, the script creates a Firebug Lite console. 
     38    This console can be opened by hitting <b>F12</b> or <b>Ctrl+Shift+L</b> 
     39    (<b>?+Shift+L</b> on a Mac).  If you want the Firebug Lite console 
     40    to be open when the page loads, add <b>debug="true"</b> to the opening 
     41    html tag of your page.  Open the console and click on the links below 
     42    to see console calls.</p> 
     43    <ul> 
     44        <li> 
     45            <a href="javascript: void(consoleLog());">OpenLayers.Console.log()</a> 
     46        </li> 
     47        <li> 
     48            <a href="javascript: void(consoleWarn());">OpenLayers.Console.warn()</a> 
     49        </li> 
     50        <li> 
     51            <a href="javascript: void(consoleError());">OpenLayers.Console.error()</a> 
     52        </li> 
     53        <li> 
     54            <a href="javascript: void(consoleDir());">OpenLayers.Console.dir()</a> 
     55        </li> 
     56        <li> 
     57            <a href="javascript: void(consoleDirxml());">OpenLayers.Console.dirxml()</a> 
     58        </li> 
     59    </ul> 
     60    <p>The Firebug website has a complete list of 
     61    <a href="http://www.getfirebug.com/console.html">console calls</a>. 
     62    Note that not all are supported with Firebug Lite.</p> 
     63  </body> 
     64</html> 
  • lib/Firebug/firebug.css

    old new  
     1 
     2html, body { 
     3    margin: 0; 
     4    background: #FFFFFF; 
     5    font-family: Lucida Grande, Tahoma, sans-serif; 
     6    font-size: 11px; 
     7    overflow: hidden; 
     8} 
     9 
     10a { 
     11    text-decoration: none; 
     12} 
     13 
     14a:hover { 
     15    text-decoration: underline; 
     16} 
     17 
     18.toolbar { 
     19    height: 14px; 
     20    border-top: 1px solid ThreeDHighlight; 
     21    border-bottom: 1px solid ThreeDShadow; 
     22    padding: 2px 6px; 
     23    background: ThreeDFace; 
     24} 
     25 
     26.toolbarRight { 
     27    position: absolute; 
     28    top: 4px; 
     29    right: 6px; 
     30} 
     31 
     32#log { 
     33    overflow: auto; 
     34    position: absolute; 
     35    left: 0; 
     36    width: 100%; 
     37} 
     38 
     39#commandLine { 
     40    position: absolute; 
     41    bottom: 0; 
     42    left: 0; 
     43    width: 100%; 
     44    height: 18px; 
     45    border: none; 
     46    border-top: 1px solid ThreeDShadow; 
     47} 
     48 
     49/************************************************************************************************/ 
     50 
     51.logRow { 
     52    position: relative; 
     53    border-bottom: 1px solid #D7D7D7; 
     54    padding: 2px 4px 1px 6px; 
     55    background-color: #FFFFFF; 
     56} 
     57 
     58.logRow-command { 
     59    font-family: Monaco, monospace; 
     60    color: blue; 
     61} 
     62 
     63.objectBox-null { 
     64    padding: 0 2px; 
     65    border: 1px solid #666666; 
     66    background-color: #888888; 
     67    color: #FFFFFF; 
     68} 
     69 
     70.objectBox-string { 
     71    font-family: Monaco, monospace; 
     72    color: red; 
     73    white-space: pre; 
     74} 
     75 
     76.objectBox-number { 
     77    color: #000088; 
     78} 
     79 
     80.objectBox-function { 
     81    font-family: Monaco, monospace; 
     82    color: DarkGreen; 
     83} 
     84 
     85.objectBox-object { 
     86    color: DarkGreen; 
     87    font-weight: bold; 
     88} 
     89 
     90/************************************************************************************************/ 
     91 
     92.logRow-info, 
     93.logRow-error, 
     94.logRow-warning { 
     95    background: #FFFFFF no-repeat 2px 2px; 
     96    padding-left: 20px; 
     97    padding-bottom: 3px; 
     98} 
     99 
     100.logRow-info { 
     101    background-image: url(infoIcon.png); 
     102} 
     103 
     104.logRow-warning { 
     105    background-color: cyan; 
     106    background-image: url(warningIcon.png); 
     107} 
     108 
     109.logRow-error { 
     110    background-color: LightYellow; 
     111    background-image: url(errorIcon.png); 
     112} 
     113 
     114.errorMessage { 
     115    vertical-align: top; 
     116    color: #FF0000; 
     117} 
     118 
     119.objectBox-sourceLink { 
     120    position: absolute; 
     121    right: 4px; 
     122    top: 2px; 
     123    padding-left: 8px; 
     124    font-family: Lucida Grande, sans-serif; 
     125    font-weight: bold; 
     126    color: #0000FF; 
     127} 
     128 
     129/************************************************************************************************/ 
     130 
     131.logRow-group { 
     132    background: #EEEEEE; 
     133    border-bottom: none; 
     134} 
     135 
     136.logGroup { 
     137    background: #EEEEEE; 
     138} 
     139 
     140.logGroupBox { 
     141    margin-left: 24px; 
     142    border-top: 1px solid #D7D7D7; 
     143    border-left: 1px solid #D7D7D7; 
     144} 
     145 
     146/************************************************************************************************/ 
     147 
     148.selectorTag, 
     149.selectorId, 
     150.selectorClass { 
     151    font-family: Monaco, monospace; 
     152    font-weight: normal; 
     153} 
     154 
     155.selectorTag { 
     156    color: #0000FF; 
     157} 
     158 
     159.selectorId { 
     160    color: DarkBlue; 
     161} 
     162 
     163.selectorClass { 
     164    color: red; 
     165} 
     166 
     167/************************************************************************************************/ 
     168 
     169.objectBox-element { 
     170    font-family: Monaco, monospace; 
     171    color: #000088; 
     172} 
     173 
     174.nodeChildren { 
     175    margin-left: 16px; 
     176} 
     177 
     178.nodeTag { 
     179    color: blue; 
     180} 
     181 
     182.nodeValue { 
     183    color: #FF0000; 
     184    font-weight: normal; 
     185} 
     186 
     187.nodeText, 
     188.nodeComment { 
     189    margin: 0 2px; 
     190    vertical-align: top; 
     191} 
     192 
     193.nodeText { 
     194    color: #333333; 
     195} 
     196 
     197.nodeComment { 
     198    color: DarkGreen; 
     199} 
     200 
     201/************************************************************************************************/ 
     202 
     203.propertyNameCell { 
     204    vertical-align: top; 
     205} 
     206 
     207.propertyName { 
     208    font-weight: bold; 
     209} 
  • lib/Firebug/firebug.html

    old new  
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
     2         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
     3 
     4<html xmlns="http://www.w3.org/1999/xhtml"> 
     5 
     6<head> 
     7    <title>Firebug</title> 
     8    <link rel="stylesheet" type="text/css" href="firebug.css"> 
     9</head> 
     10 
     11<body> 
     12    <div id="toolbar" class="toolbar"> 
     13        <a href="#" onclick="parent.console.clear()">Clear</a> 
     14        <span class="toolbarRight"> 
     15            <a href="#" onclick="parent.console.close()">Close</a> 
     16        </span> 
     17    </div> 
     18    <div id="log"></div> 
     19    <input type="text" id="commandLine"> 
     20     
     21    <script>parent.onFirebugReady(document);</script> 
     22</body> 
     23</html> 
  • lib/Firebug/firebug.js

    old new  
     1 
     2if (!window.console || !console.firebug) { 
     3(function() 
     4{ 
     5    window.console =  
     6    { 
     7        log: function() 
     8        { 
     9            logFormatted(arguments, ""); 
     10        }, 
     11         
     12        debug: function() 
     13        { 
     14            logFormatted(arguments, "debug"); 
     15        }, 
     16         
     17        info: function() 
     18        { 
     19            logFormatted(arguments, "info"); 
     20        }, 
     21         
     22        warn: function() 
     23        { 
     24            logFormatted(arguments, "warning"); 
     25        }, 
     26         
     27        error: function() 
     28        { 
     29            logFormatted(arguments, "error"); 
     30        }, 
     31         
     32        assert: function(truth, message) 
     33        { 
     34            if (!truth) 
     35            { 
     36                var args = []; 
     37                for (var i = 1; i < arguments.length; ++i) 
     38                    args.push(arguments[i]); 
     39                 
     40                logFormatted(args.length ? args : ["Assertion Failure"], "error"); 
     41                throw message ? message : "Assertion Failure"; 
     42            } 
     43        }, 
     44         
     45        dir: function(object) 
     46        { 
     47            var html = []; 
     48                         
     49            var pairs = []; 
     50            for (var name in object) 
     51            { 
     52                try 
     53                { 
     54                    pairs.push([name, object[name]]); 
     55                } 
     56                catch (exc) 
     57                { 
     58                } 
     59            } 
     60             
     61            pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; }); 
     62             
     63            html.push('<table>'); 
     64            for (var i = 0; i < pairs.length; ++i) 
     65            { 
     66                var name = pairs[i][0], value = pairs[i][1]; 
     67                 
     68                html.push('<tr>',  
     69                '<td class="propertyNameCell"><span class="propertyName">', 
     70                    escapeHTML(name), '</span></td>', '<td><span class="propertyValue">'); 
     71                appendObject(value, html); 
     72                html.push('</span></td></tr>'); 
     73            } 
     74            html.push('</table>'); 
     75             
     76            logRow(html, "dir"); 
     77        }, 
     78         
     79        dirxml: function(node) 
     80        { 
     81            var html = []; 
     82             
     83            appendNode(node, html); 
     84            logRow(html, "dirxml"); 
     85        }, 
     86         
     87        group: function() 
     88        { 
     89            logRow(arguments, "group", pushGroup); 
     90        }, 
     91         
     92        groupEnd: function() 
     93        { 
     94            logRow(arguments, "", popGroup); 
     95        }, 
     96         
     97        time: function(name) 
     98        { 
     99            timeMap[name] = (new Date()).getTime(); 
     100        }, 
     101         
     102        timeEnd: function(name) 
     103        { 
     104            if (name in timeMap) 
     105            { 
     106                var delta = (new Date()).getTime() - timeMap[name]; 
     107                logFormatted([name+ ":", delta+"ms"]); 
     108                delete timeMap[name]; 
     109            } 
     110        }, 
     111         
     112        count: function() 
     113        { 
     114            this.warn(["count() not supported."]); 
     115        }, 
     116         
     117        trace: function() 
     118        { 
     119            this.warn(["trace() not supported."]); 
     120        }, 
     121         
     122        profile: function() 
     123        { 
     124            this.warn(["profile() not supported."]); 
     125        }, 
     126         
     127        profileEnd: function() 
     128        { 
     129        }, 
     130         
     131        clear: function() 
     132        { 
     133            consoleBody.innerHTML = ""; 
     134        }, 
     135 
     136        open: function() 
     137        { 
     138            toggleConsole(true); 
     139        }, 
     140         
     141        close: function() 
     142        { 
     143            if (frameVisible) 
     144                toggleConsole(); 
     145        } 
     146    }; 
     147  
     148    // ******************************************************************************************** 
     149        
     150    var consoleFrame = null; 
     151    var consoleBody = null; 
     152    var commandLine = null; 
     153     
     154    var frameVisible = false; 
     155    var messageQueue = []; 
     156    var groupStack = []; 
     157    var timeMap = {}; 
     158     
     159    var clPrefix = ">>> "; 
     160     
     161    var isFirefox = navigator.userAgent.indexOf("Firefox") != -1; 
     162    var isIE = navigator.userAgent.indexOf("MSIE") != -1; 
     163    var isOpera = navigator.userAgent.indexOf("Opera") != -1; 
     164    var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1; 
     165 
     166    // ******************************************************************************************** 
     167 
     168    function toggleConsole(forceOpen) 
     169    { 
     170        frameVisible = forceOpen || !frameVisible; 
     171        if (consoleFrame) 
     172            consoleFrame.style.visibility = frameVisible ? "visible" : "hidden"; 
     173        else 
     174            waitForBody(); 
     175    } 
     176 
     177    function focusCommandLine() 
     178    { 
     179        toggleConsole(true); 
     180        if (commandLine) 
     181            commandLine.focus(); 
     182    } 
     183 
     184    function waitForBody() 
     185    { 
     186        if (document.body) 
     187            createFrame(); 
     188        else 
     189            setTimeout(waitForBody, 200); 
     190    }     
     191 
     192    function createFrame() 
     193    { 
     194        if (consoleFrame) 
     195            return; 
     196         
     197        window.onFirebugReady = function(doc) 
     198        { 
     199            window.onFirebugReady = null; 
     200 
     201            var toolbar = doc.getElementById("toolbar"); 
     202            toolbar.onmousedown = onSplitterMouseDown; 
     203 
     204            commandLine = doc.getElementById("commandLine"); 
     205            addEvent(commandLine, "keydown", onCommandLineKeyDown); 
     206 
     207            addEvent(doc, isIE || isSafari ? "keydown" : "keypress", onKeyDown); 
     208             
     209            consoleBody = doc.getElementById("log"); 
     210            layout(); 
     211            flush(); 
     212        } 
     213 
     214        var baseURL = getFirebugURL(); 
     215 
     216        consoleFrame = document.createElement("iframe"); 
     217        consoleFrame.setAttribute("src", baseURL+"/firebug.html"); 
     218        consoleFrame.setAttribute("frameBorder", "0"); 
     219        consoleFrame.style.visibility = (frameVisible ? "visible" : "hidden");     
     220        consoleFrame.style.zIndex = "2147483583"; 
     221        consoleFrame.style.position = document.all ? "absolute" : "fixed"; 
     222        consoleFrame.style.width = "100%"; 
     223        consoleFrame.style.left = "0"; 
     224        consoleFrame.style.bottom = "0"; 
     225        consoleFrame.style.height = "200px"; 
     226        document.body.appendChild(consoleFrame); 
     227    } 
     228     
     229    function getFirebugURL() 
     230    { 
     231        var scripts = document.getElementsByTagName("script"); 
     232        for (var i = 0; i < scripts.length; ++i) 
     233        { 
     234            if (scripts[i].src.indexOf("firebug.js") != -1) 
     235            { 
     236                var lastSlash = scripts[i].src.lastIndexOf("/"); 
     237                return scripts[i].src.substr(0, lastSlash); 
     238            } 
     239        } 
     240    } 
     241     
     242    function evalCommandLine() 
     243    { 
     244        var text = commandLine.value; 
     245        commandLine.value = ""; 
     246 
     247        logRow([clPrefix, text], "command"); 
     248         
     249        var value; 
     250        try 
     251        { 
     252            value = eval(text); 
     253        } 
     254        catch (exc) 
     255        { 
     256        } 
     257 
     258        console.log(value); 
     259    } 
     260     
     261    function layout() 
     262    { 
     263        var toolbar = consoleBody.ownerDocument.getElementById("toolbar"); 
     264        var height = consoleFrame.offsetHeight - (toolbar.offsetHeight + commandLine.offsetHeight); 
     265        height = Math.max(height, 0); 
     266        consoleBody.style.top = toolbar.offsetHeight + "px"; 
     267        consoleBody.style.height = height + "px"; 
     268         
     269        commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px"; 
     270    } 
     271     
     272    function logRow(message, className, handler) 
     273    { 
     274        if (consoleBody) 
     275            writeMessage(message, className, handler); 
     276        else 
     277        { 
     278            messageQueue.push([message, className, handler]); 
     279            waitForBody(); 
     280        } 
     281    } 
     282     
     283    function flush() 
     284    { 
     285        var queue = messageQueue; 
     286        messageQueue = []; 
     287         
     288        for (var i = 0; i < queue.length; ++i) 
     289            writeMessage(queue[i][0], queue[i][1], queue[i][2]); 
     290    } 
     291 
     292    function writeMessage(message, className, handler) 
     293    { 
     294        var isScrolledToBottom = 
     295            consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight; 
     296 
     297        if (!handler) 
     298            handler = writeRow; 
     299         
     300        handler(message, className); 
     301         
     302        if (isScrolledToBottom) 
     303            consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight; 
     304    } 
     305     
     306    function appendRow(row) 
     307    { 
     308        var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody; 
     309        container.appendChild(row); 
     310    } 
     311 
     312    function writeRow(message, className) 
     313    { 
     314        var row = consoleBody.ownerDocument.createElement("div"); 
     315        row.className = "logRow" + (className ? " logRow-"+className : ""); 
     316        row.innerHTML = message.join(""); 
     317        appendRow(row); 
     318    } 
     319 
     320    function pushGroup(message, className) 
     321    { 
     322        logFormatted(message, className); 
     323 
     324        var groupRow = consoleBody.ownerDocument.createElement("div"); 
     325        groupRow.className = "logGroup"; 
     326        var groupRowBox = consoleBody.ownerDocument.createElement("div"); 
     327        groupRowBox.className = "logGroupBox"; 
     328        groupRow.appendChild(groupRowBox); 
     329        appendRow(groupRowBox); 
     330        groupStack.push(groupRowBox); 
     331    } 
     332 
     333    function popGroup() 
     334    { 
     335        groupStack.pop(); 
     336    } 
     337     
     338    // ******************************************************************************************** 
     339 
     340    function logFormatted(objects, className) 
     341    { 
     342        var html = []; 
     343 
     344        var format = objects[0]; 
     345        var objIndex = 0; 
     346 
     347        if (typeof(format) != "string") 
     348        { 
     349            format = ""; 
     350            objIndex = -1; 
     351        } 
     352 
     353        var parts = parseFormat(format); 
     354        for (var i = 0; i < parts.length; ++i) 
     355        { 
     356            var part = parts[i]; 
     357            if (part && typeof(part) == "object") 
     358            { 
     359                var object = objects[++objIndex]; 
     360                part.appender(object, html); 
     361            } 
     362            else 
     363                appendText(part, html); 
     364        } 
     365 
     366        for (var i = objIndex+1; i < objects.length; ++i) 
     367        { 
     368            appendText(" ", html); 
     369             
     370            var object = objects[i]; 
     371            if (typeof(object) == "string") 
     372                appendText(object, html); 
     373            else 
     374                appendObject(object, html); 
     375        } 
     376         
     377        logRow(html, className); 
     378    } 
     379 
     380    function parseFormat(format) 
     381    { 
     382        var parts = []; 
     383 
     384        var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;     
     385        var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat}; 
     386 
     387        for (var m = reg.exec(format); m; m = reg.exec(format)) 
     388        { 
     389            var type = m[8] ? m[8] : m[5]; 
     390            var appender = type in appenderMap ? appenderMap[type] : appendObject; 
     391            var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0); 
     392 
     393            parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1)); 
     394            parts.push({appender: appender, precision: precision}); 
     395 
     396            format = format.substr(m.index+m[0].length); 
     397        } 
     398 
     399        parts.push(format); 
     400 
     401        return parts; 
     402    } 
     403 
     404    function escapeHTML(value) 
     405    { 
     406        function replaceChars(ch) 
     407        { 
     408            switch (ch) 
     409            { 
     410                case "<": 
     411                    return "&lt;"; 
     412                case ">": 
     413                    return "&gt;"; 
     414                case "&": 
     415                    return "&amp;"; 
     416                case "'": 
     417                    return "&#39;"; 
     418                case '"': 
     419                    return "&quot;"; 
     420            } 
     421            return "?"; 
     422        }; 
     423        return String(value).replace(/[<>&"']/g, replaceChars); 
     424    } 
     425 
     426    function objectToString(object) 
     427    { 
     428        try 
     429        { 
     430            return object+""; 
     431        } 
     432        catch (exc) 
     433        { 
     434            return null; 
     435        } 
     436    } 
     437 
     438    // ******************************************************************************************** 
     439 
     440    function appendText(object, html) 
     441    { 
     442        html.push(escapeHTML(objectToString(object))); 
     443    } 
     444 
     445    function appendNull(object, html) 
     446    { 
     447        html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>'); 
     448    } 
     449 
     450    function appendString(object, html) 
     451    { 
     452        html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)), 
     453            '&quot;</span>'); 
     454    } 
     455 
     456    function appendInteger(object, html) 
     457    { 
     458        html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>'); 
     459    } 
     460 
     461    function appendFloat(object, html) 
     462    { 
     463        html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>'); 
     464    } 
     465 
     466    function appendFunction(object, html) 
     467    { 
     468        var reName = /function ?(.*?)\(/; 
     469        var m = reName.exec(objectToString(object)); 
     470        var name = m ? m[1] : "function"; 
     471        html.push('<span class="objectBox-function">', escapeHTML(name), '()</span>'); 
     472    } 
     473     
     474    function appendObject(object, html) 
     475    { 
     476        try 
     477        { 
     478            if (object == undefined) 
     479                appendNull("undefined", html); 
     480            else if (object == null) 
     481                appendNull("null", html); 
     482            else if (typeof object == "string") 
     483                appendString(object, html); 
     484            else if (typeof object == "number") 
     485                appendInteger(object, html); 
     486            else if (typeof object == "function") 
     487                appendFunction(object, html); 
     488            else if (object.nodeType == 1) 
     489                appendSelector(object, html); 
     490            else if (typeof object == "object") 
     491                appendObjectFormatted(object, html); 
     492            else 
     493                appendText(object, html); 
     494        } 
     495        catch (exc) 
     496        { 
     497        } 
     498    } 
     499         
     500    function appendObjectFormatted(object, html) 
     501    { 
     502        var text = objectToString(object); 
     503        var reObject = /\[object (.*?)\]/; 
     504 
     505        var m = reObject.exec(text); 
     506        html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>') 
     507    } 
     508     
     509    function appendSelector(object, html) 
     510    { 
     511        html.push('<span class="objectBox-selector">'); 
     512 
     513        html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>'); 
     514        if (object.id) 
     515            html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>'); 
     516        if (object.className) 
     517            html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>'); 
     518 
     519        html.push('</span>'); 
     520    } 
     521 
     522    function appendNode(node, html) 
     523    { 
     524        if (node.nodeType == 1) 
     525        { 
     526            html.push( 
     527                '<div class="objectBox-element">', 
     528                    '&lt;<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>'); 
     529 
     530            for (var i = 0; i < node.attributes.length; ++i) 
     531            { 
     532                var attr = node.attributes[i]; 
     533                if (!attr.specified) 
     534                    continue; 
     535                 
     536                html.push('&nbsp;<span class="nodeName">', attr.nodeName.toLowerCase(), 
     537                    '</span>=&quot;<span class="nodeValue">', escapeHTML(attr.nodeValue), 
     538                    '</span>&quot;') 
     539            } 
     540 
     541            if (node.firstChild) 
     542            { 
     543                html.push('&gt;</div><div class="nodeChildren">'); 
     544 
     545                for (var child = node.firstChild; child; child = child.nextSibling) 
     546                    appendNode(child, html); 
     547                     
     548                html.push('</div><div class="objectBox-element">&lt;/<span class="nodeTag">',  
     549                    node.nodeName.toLowerCase(), '&gt;</span></div>'); 
     550            } 
     551            else 
     552                html.push('/&gt;</div>'); 
     553        } 
     554        else if (node.nodeType == 3) 
     555        { 
     556            html.push('<div class="nodeText">', escapeHTML(node.nodeValue), 
     557                '</div>'); 
     558        } 
     559    } 
     560 
     561    // ******************************************************************************************** 
     562     
     563    function addEvent(object, name, handler) 
     564    { 
     565        if (document.all) 
     566            object.attachEvent("on"+name, handler); 
     567        else 
     568            object.addEventListener(name, handler, false); 
     569    } 
     570     
     571    function removeEvent(object, name, handler) 
     572    { 
     573        if (document.all) 
     574            object.detachEvent("on"+name, handler); 
     575        else 
     576            object.removeEventListener(name, handler, false); 
     577    } 
     578     
     579    function cancelEvent(event) 
     580    { 
     581        if (document.all) 
     582            event.cancelBubble = true; 
     583        else 
     584            event.stopPropagation();         
     585    } 
     586 
     587    function onError(msg, href, lineNo) 
     588    { 
     589        var html = []; 
     590         
     591        var lastSlash = href.lastIndexOf("/"); 
     592        var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1); 
     593         
     594        html.push( 
     595            '<span class="errorMessage">', msg, '</span>',  
     596            '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>' 
     597        ); 
     598         
     599        logRow(html, "error"); 
     600    }; 
     601 
     602    function onKeyDown(event) 
     603    { 
     604        if (event.keyCode == 123) 
     605            toggleConsole(); 
     606        else if ((event.keyCode == 108 || event.keyCode == 76) && event.shiftKey 
     607                 && (event.metaKey || event.ctrlKey)) 
     608            focusCommandLine(); 
     609        else 
     610            return; 
     611         
     612        cancelEvent(event); 
     613    } 
     614 
     615    function onSplitterMouseDown(event) 
     616    { 
     617        if (isSafari || isOpera) 
     618            return; 
     619         
     620        addEvent(document, "mousemove", onSplitterMouseMove); 
     621        addEvent(document, "mouseup", onSplitterMouseUp); 
     622 
     623        for (var i = 0; i < frames.length; ++i) 
     624        { 
     625            addEvent(frames[i].document, "mousemove", onSplitterMouseMove); 
     626            addEvent(frames[i].document, "mouseup", onSplitterMouseUp); 
     627        } 
     628    } 
     629     
     630    function onSplitterMouseMove(event) 
     631    { 
     632        var win = document.all 
     633            ? event.srcElement.ownerDocument.parentWindow 
     634            : event.target.ownerDocument.defaultView; 
     635 
     636        var clientY = event.clientY; 
     637        if (win != win.parent) 
     638            clientY += win.frameElement ? win.frameElement.offsetTop : 0; 
     639         
     640        var height = consoleFrame.offsetTop + consoleFrame.clientHeight; 
     641        var toolbar = consoleBody.ownerDocument.getElementById("toolbar"); 
     642        var y = Math.max(height - clientY, 
     643                         toolbar.offsetHeight + commandLine.offsetHeight); 
     644         
     645        consoleFrame.style.height = y + "px"; 
     646        layout(); 
     647    } 
     648     
     649    function onSplitterMouseUp(event) 
     650    { 
     651        removeEvent(document, "mousemove", onSplitterMouseMove); 
     652        removeEvent(document, "mouseup", onSplitterMouseUp); 
     653 
     654        for (var i = 0; i < frames.length; ++i) 
     655        { 
     656            removeEvent(frames[i].document, "mousemove", onSplitterMouseMove); 
     657            removeEvent(frames[i].document, "mouseup", onSplitterMouseUp); 
     658        } 
     659    } 
     660     
     661    function onCommandLineKeyDown(event) 
     662    { 
     663        if (event.keyCode == 13) 
     664            evalCommandLine(); 
     665        else if (event.keyCode == 27) 
     666            commandLine.value = ""; 
     667    } 
     668     
     669    window.onerror = onError; 
     670    addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown); 
     671     
     672    if (document.documentElement.getAttribute("debug") == "true") 
     673        toggleConsole(true); 
     674})(); 
     675} 
  • lib/Firebug/firebugx.js

    old new  
     1 
     2if (!window.console || !console.firebug) 
     3{ 
     4    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", 
     5    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; 
     6 
     7    window.console = {}; 
     8    for (var i = 0; i < names.length; ++i) 
     9        window.console[names[i]] = function() {} 
     10} 
  • lib/Firebug/readme.txt

    old new  
     1This directory contains the source for Firebug Lite 
     2(http://www.getfirebug.com/lite.html). 
     3 
     4This is a patched version of the trunk from 
     5http://fbug.googlecode.com/svn/trunk. 
     6 
     7Revision 36 was patched to resolve the issue described here 
     8http://code.google.com/p/fbug/issues/detail?id=85 
     9 
     10When this issue is resolved, Firebug Lite can be used directly - no further 
     11modifications are needed for OpenLayers. 
  • lib/OpenLayers.js

    old new  
    5454    var jsfiles=new Array( 
    5555        "OpenLayers/BaseTypes.js", 
    5656        "OpenLayers/Util.js", 
     57        "OpenLayers/Console.js", 
    5758        "Rico/Corner.js", 
    5859        "Rico/Color.js", 
    5960        "OpenLayers/Ajax.js", 
  • lib/OpenLayers/Console.js

    old new  
     1/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license. 
     2 * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt  
     3 * for the full text of the license. */ 
     4 
     5/** 
     6 * The OpenLayers.Console namespace is used for debugging and error logging. 
     7 * If the Firebug Lite (../Firebug/firebug.js) is included before this script, 
     8 * calls to OpenLayers.Console methods will get redirected to window.console. 
     9 * This makes use of the Firebug extension where available and allows for 
     10 * cross-browser deugging Firebug style. 
     11 */ 
     12OpenLayers.Console = {}; 
     13(function() { 
     14    /** 
     15     * Create empty functions for all console methods.  The real value of these 
     16     * properties will be set if Firebug Lite (../Firebug/firebug.js script) is 
     17     * included.  We explicitly require the Firebug Lite script to trigger 
     18     * functionality of the OpenLayers.Console methods. 
     19     */ 
     20    var methods = ['log', 'debug', 'info', 'warn', 'error', 'assert', 
     21                   'dir', 'dirxml', 'trace', 'group', 'groupEnd', 'time', 
     22                   'timeEnd', 'profile', 'profileEnd', 'count']; 
     23    for(var i=0; i<methods.length; ++i) { 
     24        OpenLayers.Console[methods[i]] = function() {}; 
     25    } 
     26    /** 
     27     * If Firebug Lite is included, re-route all OpenLayers.Console calls to the 
     28     * console object. 
     29     */ 
     30    var scripts = document.getElementsByTagName("script"); 
     31    for(var i=0; i<scripts.length; ++i) { 
     32        if(scripts[i].src.indexOf("firebug.js") != -1) { 
     33            OpenLayers.Util.extend(OpenLayers.Console, console); 
     34            break; 
     35        } 
     36    } 
     37})(); 
  • lib/OpenLayers/Layer.js

    old new  
    309309        if(this.gutter) { 
    310310            // layers with gutters need non-null tile sizes 
    311311            //if(tileSize == null) { 
    312             //    OpenLayers.console.error("Error in layer.setMap() for " + 
     312            //    OpenLayers.Console.error("Error in layer.setMap() for " + 
    313313            //                              this.name + ": layers with gutters " + 
    314314            //                              "need non-null tile sizes"); 
    315315            //} 
  • 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>test_Console.html</li> 
    78    <li>test_Geometry.html</li> 
    89    <li>Geometry/test_Point.html</li> 
    910    <li>Geometry/test_Curve.html</li> 
  • tests/test_Console.html

    old new  
     1<html> 
     2<head> 
     3  <script src="../lib/OpenLayers.js"></script> 
     4  <script type="text/javascript"><!-- 
     5    function test_Console(t) { 
     6         
     7        /*