| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Firebug
Revision: 940
Author: azer@kodfabrik.com
Date: 19 Aug 2008 15:40:13
Changes:Files:
| ... | ...@@ -0,0 +1,23 @@ | |
| 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> |
| ... | ...@@ -0,0 +1,10 @@ | |
| 1 | ||
| 2 | if (!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 | } | |
| 0 | 11 | \ No newline at end of file |
| ... | ...@@ -1,23 +0,0 @@ | |
| 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> |
| ... | ...@@ -1,10 +0,0 @@ | |
| 1 | ||
| 2 | if (!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 | } | |
| 11 | 0 | \ No newline at end of file |
| ... | ...@@ -0,0 +1,209 @@ | |
| 1 | ||
| 2 | html, body { | |
| 3 | margin: 0; | |
| 4 | background: #FFFFFF; | |
| 5 | font-family: Lucida Grande, Tahoma, sans-serif; | |
| 6 | font-size: 11px; | |
| 7 | overflow: hidden; | |
| 8 | } | |
| 9 | ||
| 10 | a { | |
| 11 | text-decoration: none; | |
| 12 | } | |
| 13 | ||
| 14 | a: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 | } |
| ... | ...@@ -1,209 +0,0 @@ | |
| 1 | ||
| 2 | html, body { | |
| 3 | margin: 0; | |
| 4 | background: #FFFFFF; | |
| 5 | font-family: Lucida Grande, Tahoma, sans-serif; | |
| 6 | font-size: 11px; | |
| 7 | overflow: hidden; | |
| 8 | } | |
| 9 | ||
| 10 | a { | |
| 11 | text-decoration: none; | |
| 12 | } | |
| 13 | ||
| 14 | a: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 | } |
| ... | ...@@ -0,0 +1,672 @@ | |
| 1 | ||
| 2 | if (!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 | consoleBody.style.top = toolbar.offsetHeight + "px"; | |
| 266 | consoleBody.style.height = height + "px"; | |
| 267 | ||
| 268 | commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px"; | |
| 269 | } | |
| 270 | ||
| 271 | function logRow(message, className, handler) | |
| 272 | { | |
| 273 | if (consoleBody) | |
| 274 | writeMessage(message, className, handler); | |
| 275 | else | |
| 276 | { | |
| 277 | messageQueue.push([message, className, handler]); | |
| 278 | waitForBody(); | |
| 279 | } | |
| 280 | } | |
| 281 | ||
| 282 | function flush() | |
| 283 | { | |
| 284 | var queue = messageQueue; | |
| 285 | messageQueue = []; | |
| 286 | ||
| 287 | for (var i = 0; i < queue.length; ++i) | |
| 288 | writeMessage(queue[i][0], queue[i][1], queue[i][2]); | |
| 289 | } | |
| 290 | ||
| 291 | function writeMessage(message, className, handler) | |
| 292 | { | |
| 293 | var isScrolledToBottom = | |
| 294 | consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight; | |
| 295 | ||
| 296 | if (!handler) | |
| 297 | handler = writeRow; | |
| 298 | ||
| 299 | handler(message, className); | |
| 300 | ||
| 301 | if (isScrolledToBottom) | |
| 302 | consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight; | |
| 303 | } | |
| 304 | ||
| 305 | function appendRow(row) | |
| 306 | { | |
| 307 | var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody; | |
| 308 | container.appendChild(row); | |
| 309 | } | |
| 310 | ||
| 311 | function writeRow(message, className) | |
| 312 | { | |
| 313 | var row = consoleBody.ownerDocument.createElement("div"); | |
| 314 | row.className = "logRow" + (className ? " logRow-"+className : ""); | |
| 315 | row.innerHTML = message.join(""); | |
| 316 | appendRow(row); | |
| 317 | } | |
| 318 | ||
| 319 | function pushGroup(message, className) | |
| 320 | { | |
| 321 | logFormatted(message, className); | |
| 322 | ||
| 323 | var groupRow = consoleBody.ownerDocument.createElement("div"); | |
| 324 | groupRow.className = "logGroup"; | |
| 325 | var groupRowBox = consoleBody.ownerDocument.createElement("div"); | |
| 326 | groupRowBox.className = "logGroupBox"; | |
| 327 | groupRow.appendChild(groupRowBox); | |
| 328 | appendRow(groupRowBox); | |
| 329 | groupStack.push(groupRowBox); | |
| 330 | } | |
| 331 | ||
| 332 | function popGroup() | |
| 333 | { | |
| 334 | groupStack.pop(); | |
| 335 | } | |
| 336 | ||
| 337 | // ******************************************************************************************** | |
| 338 | ||
| 339 | function logFormatted(objects, className) | |
| 340 | { | |
| 341 | var html = []; | |
| 342 | ||
| 343 | var format = objects[0]; | |
| 344 | var objIndex = 0; | |
| 345 | ||
| 346 | if (typeof(format) != "string") | |
| 347 | { | |
| 348 | format = ""; | |
| 349 | objIndex = -1; | |
| 350 | } | |
| 351 | ||
| 352 | var parts = parseFormat(format); | |
| 353 | for (var i = 0; i < parts.length; ++i) | |
| 354 | { | |
| 355 | var part = parts[i]; | |
| 356 | if (part && typeof(part) == "object") | |
| 357 | { | |
| 358 | var object = objects[++objIndex]; | |
| 359 | part.appender(object, html); | |
| 360 | } | |
| 361 | else | |
| 362 | appendText(part, html); | |
| 363 | } | |
| 364 | ||
| 365 | for (var i = objIndex+1; i < objects.length; ++i) | |
| 366 | { | |
| 367 | appendText(" ", html); | |
| 368 | ||
| 369 | var object = objects[i]; | |
| 370 | if (typeof(object) == "string") | |
| 371 | appendText(object, html); | |
| 372 | else | |
| 373 | appendObject(object, html); | |
| 374 | } | |
| 375 | ||
| 376 | logRow(html, className); | |
| 377 | } | |
| 378 | ||
| 379 | function parseFormat(format) | |
| 380 | { | |
| 381 | var parts = []; | |
| 382 | ||
| 383 | var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/; | |
| 384 | var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat}; | |
| 385 | ||
| 386 | for (var m = reg.exec(format); m; m = reg.exec(format)) | |
| 387 | { | |
| 388 | var type = m[8] ? m[8] : m[5]; | |
| 389 | var appender = type in appenderMap ? appenderMap[type] : appendObject; | |
| 390 | var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0); | |
| 391 | ||
| 392 | parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1)); | |
| 393 | parts.push({appender: appender, precision: precision}); | |
| 394 | ||
| 395 | format = format.substr(m.index+m[0].length); | |
| 396 | } | |
| 397 | ||
| 398 | parts.push(format); | |
| 399 | ||
| 400 | return parts; | |
| 401 | } | |
| 402 | ||
| 403 | function escapeHTML(value) | |
| 404 | { | |
| 405 | function replaceChars(ch) | |
| 406 | { | |
| 407 | switch (ch) | |
| 408 | { | |
| 409 | case "<": | |
| 410 | return "<"; | |
| 411 | case ">": | |
| 412 | return ">"; | |
| 413 | case "&": | |
| 414 | return "&"; | |
| 415 | case "'": | |
| 416 | return "'"; | |
| 417 | case '"': | |
| 418 | return """; | |
| 419 | } | |
| 420 | return "?"; | |
| 421 | }; | |
| 422 | return String(value).replace(/[<>&"']/g, replaceChars); | |
| 423 | } | |
| 424 | ||
| 425 | function objectToString(object) | |
| 426 | { | |
| 427 | try | |
| 428 | { | |
| 429 | return object+""; | |
| 430 | } | |
| 431 | catch (exc) | |
| 432 | { | |
| 433 | return null; | |
| 434 | } | |