smparkes-envjs 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/bin/envjsrb +157 -73
  2. data/bin/jquery-1.3.2-test.js +11 -4
  3. data/lib/envjs/env.js +935 -11028
  4. data/lib/envjs/net/cgi.rb +94 -0
  5. data/lib/envjs/net/file.rb +4 -4
  6. data/lib/envjs/runtime.rb +80 -24
  7. data/test/call-load-test.js +0 -2
  8. data/test/firebug/errorIcon.png +0 -0
  9. data/test/firebug/firebug.css +209 -0
  10. data/test/firebug/firebug.html +23 -0
  11. data/test/firebug/firebug.js +672 -0
  12. data/test/firebug/firebugx.js +10 -0
  13. data/test/firebug/infoIcon.png +0 -0
  14. data/test/firebug/warningIcon.png +0 -0
  15. data/test/fixtures/html/events.html +171 -0
  16. data/test/fixtures/html/iframe1.html +46 -0
  17. data/test/fixtures/html/iframe1a.html +46 -0
  18. data/test/fixtures/html/iframe2.html +45 -0
  19. data/test/fixtures/html/iframe3.html +28 -0
  20. data/test/fixtures/html/iframeN.html +57 -0
  21. data/test/fixtures/html/malformed.html +181 -0
  22. data/test/fixtures/html/scope.html +81 -0
  23. data/test/fixtures/html/trivial.html +19 -0
  24. data/test/fixtures/html/with_js.html +26 -0
  25. data/test/fixtures/images/icon-blue.png +0 -0
  26. data/test/fixtures/js/external_script.js +1 -0
  27. data/test/fixtures/js/script.js +1 -0
  28. data/test/fixtures/js/script_error.js +2 -0
  29. data/test/html/malformed.html +1 -0
  30. data/test/index.html +21 -19
  31. data/test/{primaryTests.js → primary-tests.js} +1 -3
  32. data/test/{prototype.js → prototype-test.js} +0 -2
  33. data/test/qunit/qunit/qunit.css +0 -0
  34. data/test/qunit/qunit/qunit.js +2 -2
  35. data/test/{qunit/qunit/qunit.js.smp → specs/dist/env.spec.js} +539 -7
  36. data/test/specs/envjs.spec.css +46 -0
  37. data/test/specs/parser/html.js +31 -0
  38. data/test/specs/parser/spec.html +40 -0
  39. data/test/specs/parser/xml.js +31 -0
  40. data/test/specs/qunit.bdd.js +210 -0
  41. data/test/{qunit.smp/qunit → specs}/qunit.css +0 -0
  42. data/test/{qunit.smp/qunit → specs}/qunit.js +2 -2
  43. data/test/specs/template/spec-0.js +31 -0
  44. data/test/specs/template/spec-1.js +31 -0
  45. data/test/specs/template/spec.html +40 -0
  46. data/test/specs/window/css.js +23 -0
  47. data/test/specs/window/dialog.js +25 -0
  48. data/test/specs/window/document.js +23 -0
  49. data/test/specs/window/event.js +25 -0
  50. data/test/specs/window/history.js +34 -0
  51. data/test/specs/window/location.js +34 -0
  52. data/test/specs/window/navigator.js +71 -0
  53. data/test/specs/window/screen.js +42 -0
  54. data/test/specs/window/spec.html +48 -0
  55. data/test/specs/window/timer.js +26 -0
  56. data/test/specs/window/window.js +53 -0
  57. data/test/specs/xhr/spec.html +47 -0
  58. data/test/specs/xhr/xhr.js +31 -0
  59. data/test/test.js +10 -0
  60. data/test/unit/elementmembers.js +31 -0
  61. data/test/unit/nu.validator.js +34 -0
  62. data/test/unit/onload.js +1 -3
  63. data/test/unit/parser.js +106 -98
  64. data/test/unit/prototypecompat.js +2 -2
  65. data/test/vendor/jQuery/1.3.2/ChangeLog.txt +98 -0
  66. data/test/vendor/jQuery/1.3.2/GPL-LICENSE.txt +278 -0
  67. data/test/vendor/jQuery/1.3.2/MIT-LICENSE.txt +20 -0
  68. data/test/vendor/jQuery/1.3.2/Makefile +154 -0
  69. data/test/vendor/jQuery/1.3.2/README +67 -0
  70. data/test/vendor/jQuery/1.3.2/build/ant-contrib-0.6.jar +0 -0
  71. data/test/vendor/jQuery/1.3.2/build/build/min.js +11 -0
  72. data/test/vendor/jQuery/1.3.2/build/build/pack.js +19 -0
  73. data/test/vendor/jQuery/1.3.2/build/js/Packer.js +209 -0
  74. data/test/vendor/jQuery/1.3.2/build/js/ParseMaster.js +106 -0
  75. data/test/vendor/jQuery/1.3.2/build/js/Words.js +62 -0
  76. data/test/vendor/jQuery/1.3.2/build/js/base2.js +978 -0
  77. data/test/vendor/jQuery/1.3.2/build/js/jsmin.js +316 -0
  78. data/test/vendor/jQuery/1.3.2/build/js/json.js +117 -0
  79. data/test/vendor/jQuery/1.3.2/build/js/pack.js +316 -0
  80. data/test/vendor/jQuery/1.3.2/build/js/parse.js +105 -0
  81. data/test/vendor/jQuery/1.3.2/build/js/writeFile.js +19 -0
  82. data/test/vendor/jQuery/1.3.2/build/js/xml.js +25 -0
  83. data/test/vendor/jQuery/1.3.2/build/js.jar +0 -0
  84. data/test/vendor/jQuery/1.3.2/build/runtest/env.js +1 -0
  85. data/test/vendor/jQuery/1.3.2/build/runtest/test.js +106 -0
  86. data/test/vendor/jQuery/1.3.2/build/runtest/testrunner.js +197 -0
  87. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.css +65 -0
  88. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.js +181 -0
  89. data/test/vendor/jQuery/1.3.2/build/speed/index.html +72 -0
  90. data/test/vendor/jQuery/1.3.2/build/speed/jquery-basis.js +3549 -0
  91. data/test/vendor/jQuery/1.3.2/build/style.xsl +99 -0
  92. data/test/vendor/jQuery/1.3.2/build/yuicompressor-2.4.2.jar +0 -0
  93. data/test/vendor/jQuery/1.3.2/build.xml +123 -0
  94. data/test/vendor/jQuery/1.3.2/dist/jquery.js +4376 -0
  95. data/test/vendor/jQuery/1.3.2/reminder.txt +3 -0
  96. data/test/vendor/jQuery/1.3.2/src/ajax.js +541 -0
  97. data/test/vendor/jQuery/1.3.2/src/core.js +1255 -0
  98. data/test/vendor/jQuery/1.3.2/src/data.js +145 -0
  99. data/test/vendor/jQuery/1.3.2/src/dimensions.js +49 -0
  100. data/test/vendor/jQuery/1.3.2/src/event.js +684 -0
  101. data/test/vendor/jQuery/1.3.2/src/fx.js +407 -0
  102. data/test/vendor/jQuery/1.3.2/src/intro.js +13 -0
  103. data/test/vendor/jQuery/1.3.2/src/offset.js +155 -0
  104. data/test/vendor/jQuery/1.3.2/src/outro.js +1 -0
  105. data/test/vendor/jQuery/1.3.2/src/selector.js +1015 -0
  106. data/test/vendor/jQuery/1.3.2/src/support.js +112 -0
  107. data/test/vendor/jQuery/1.3.2/test/data/cow.jpg +0 -0
  108. data/test/vendor/jQuery/1.3.2/test/data/dashboard.xml +11 -0
  109. data/test/vendor/jQuery/1.3.2/test/data/echoQuery.php +1 -0
  110. data/test/vendor/jQuery/1.3.2/test/data/iframe.html +8 -0
  111. data/test/vendor/jQuery/1.3.2/test/data/json.php +9 -0
  112. data/test/vendor/jQuery/1.3.2/test/data/json_assigned_obj.js +1 -0
  113. data/test/vendor/jQuery/1.3.2/test/data/json_obj.js +1 -0
  114. data/test/vendor/jQuery/1.3.2/test/data/jsonp.php +10 -0
  115. data/test/vendor/jQuery/1.3.2/test/data/name.html +1 -0
  116. data/test/vendor/jQuery/1.3.2/test/data/name.php +29 -0
  117. data/test/vendor/jQuery/1.3.2/test/data/offset/absolute.html +39 -0
  118. data/test/vendor/jQuery/1.3.2/test/data/offset/body.html +24 -0
  119. data/test/vendor/jQuery/1.3.2/test/data/offset/fixed.html +33 -0
  120. data/test/vendor/jQuery/1.3.2/test/data/offset/relative.html +31 -0
  121. data/test/vendor/jQuery/1.3.2/test/data/offset/scroll.html +39 -0
  122. data/test/vendor/jQuery/1.3.2/test/data/offset/static.html +31 -0
  123. data/test/vendor/jQuery/1.3.2/test/data/offset/table.html +43 -0
  124. data/test/vendor/jQuery/1.3.2/test/data/params_html.php +12 -0
  125. data/test/vendor/jQuery/1.3.2/test/data/test.html +7 -0
  126. data/test/vendor/jQuery/1.3.2/test/data/test.js +3 -0
  127. data/test/vendor/jQuery/1.3.2/test/data/test.php +7 -0
  128. data/test/vendor/jQuery/1.3.2/test/data/test2.html +5 -0
  129. data/test/vendor/jQuery/1.3.2/test/data/test3.html +3 -0
  130. data/test/vendor/jQuery/1.3.2/test/data/testrunner.js +1 -0
  131. data/test/vendor/jQuery/1.3.2/test/data/text.php +12 -0
  132. data/test/vendor/jQuery/1.3.2/test/data/with_fries.xml +25 -0
  133. data/test/vendor/jQuery/1.3.2/test/index.html +229 -0
  134. data/test/vendor/jQuery/1.3.2/test/jqenv-1259090275493.html +247 -0
  135. data/test/vendor/jQuery/1.3.2/test/jqenv-1259091671501.html +247 -0
  136. data/test/vendor/jQuery/1.3.2/test/jqenv-1259175319655.html +247 -0
  137. data/test/vendor/jQuery/1.3.2/test/offset.html +28 -0
  138. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.1/jquery.js +11 -0
  139. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.3/jquery.js +11 -0
  140. data/test/vendor/jQuery/1.3.2/test/otherlibs/mootools/1.11/mootools.js +1577 -0
  141. data/test/vendor/jQuery/1.3.2/test/otherlibs/prototype/1.6.0.2/prototype.js +4221 -0
  142. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/builder.js +131 -0
  143. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/controls.js +835 -0
  144. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/dragdrop.js +944 -0
  145. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/effects.js +1090 -0
  146. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/scriptaculous.js +51 -0
  147. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/slider.js +278 -0
  148. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/unittest.js +564 -0
  149. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/builder.js +136 -0
  150. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/controls.js +965 -0
  151. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/dragdrop.js +974 -0
  152. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/effects.js +1122 -0
  153. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/scriptaculous.js +58 -0
  154. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/slider.js +275 -0
  155. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/sound.js +55 -0
  156. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/unittest.js +568 -0
  157. data/test/vendor/jQuery/1.3.2/test/polluted.php +64 -0
  158. data/test/vendor/jQuery/1.3.2/test/qunit/testrunner.js +780 -0
  159. data/test/vendor/jQuery/1.3.2/test/qunit/testsuite.css +120 -0
  160. data/test/vendor/jQuery/1.3.2/test/test.js +41 -0
  161. data/test/vendor/jQuery/1.3.2/test/unit/ajax.js +856 -0
  162. data/test/vendor/jQuery/1.3.2/test/unit/core.js +1872 -0
  163. data/test/vendor/jQuery/1.3.2/test/unit/data.js +160 -0
  164. data/test/vendor/jQuery/1.3.2/test/unit/dimensions.js +86 -0
  165. data/test/vendor/jQuery/1.3.2/test/unit/event.js +670 -0
  166. data/test/vendor/jQuery/1.3.2/test/unit/fx.js +451 -0
  167. data/test/vendor/jQuery/1.3.2/test/unit/offset.js +173 -0
  168. data/test/vendor/jQuery/1.3.2/test/unit/selector.js +395 -0
  169. data/test/vendor/jQuery/1.3.2/test/xhtml.php +5 -0
  170. data/test/vendor/jQuery/1.3.2/version.txt +1 -0
  171. metadata +158 -22
  172. data/lib/envjs/runtime.rb.smp +0 -133
  173. data/test/envjs-call-load-test.js +0 -5
  174. data/test/envjs-prototype.js +0 -5
  175. data/test/qunit/package.json +0 -21
  176. data/test/qunit/test/index.html +0 -17
  177. data/test/qunit/test/same.js +0 -1368
  178. data/test/qunit/test/test.js +0 -136
  179. data/test/qunit.smp/package.json +0 -21
  180. data/test/qunit.smp/test/index.html +0 -17
  181. data/test/qunit.smp/test/same.js +0 -1368
  182. data/test/qunit.smp/test/test.js +0 -136
  183. data/test/rhino-call-load-test.js +0 -5
  184. data/test/rhino-prototype.js +0 -5
  185. data/test/test-with-envs-jar.js +0 -8
  186. data/test/test-with-rhino-jar.js +0 -9
@@ -0,0 +1,672 @@
1
+
2
+ if (!("console" in window) || !("firebug" in console)) {
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 = "2147483647";
221
+ consoleFrame.style.position = "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 "&lt;";
411
+ case ">":
412
+ return "&gt;";
413
+ case "&":
414
+ return "&amp;";
415
+ case "'":
416
+ return "&#39;";
417
+ case '"':
418
+ return "&quot;";
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
+ }
435
+ }
436
+
437
+ // ********************************************************************************************
438
+
439
+ function appendText(object, html)
440
+ {
441
+ html.push(escapeHTML(objectToString(object)));
442
+ }
443
+
444
+ function appendNull(object, html)
445
+ {
446
+ html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>');
447
+ }
448
+
449
+ function appendString(object, html)
450
+ {
451
+ html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)),
452
+ '&quot;</span>');
453
+ }
454
+
455
+ function appendInteger(object, html)
456
+ {
457
+ html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');
458
+ }
459
+
460
+ function appendFloat(object, html)
461
+ {
462
+ html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');
463
+ }
464
+
465
+ function appendFunction(object, html)
466
+ {
467
+ var reName = /function ?(.*?)\(/;
468
+ var m = reName.exec(objectToString(object));
469
+ var name = m ? m[1] : "function";
470
+ html.push('<span class="objectBox-function">', escapeHTML(name), '()</span>');
471
+ }
472
+
473
+ function appendObject(object, html)
474
+ {
475
+ try
476
+ {
477
+ if (object == undefined)
478
+ appendNull("undefined", html);
479
+ else if (object == null)
480
+ appendNull("null", html);
481
+ else if (typeof object == "string")
482
+ appendString(object, html);
483
+ else if (typeof object == "number")
484
+ appendInteger(object, html);
485
+ else if (typeof object == "function")
486
+ appendFunction(object, html);
487
+ else if (object.nodeType == 1)
488
+ appendSelector(object, html);
489
+ else if (typeof object == "object")
490
+ appendObjectFormatted(object, html);
491
+ else
492
+ appendText(object, html);
493
+ }
494
+ catch (exc)
495
+ {
496
+ }
497
+ }
498
+
499
+ function appendObjectFormatted(object, html)
500
+ {
501
+ var text = objectToString(object);
502
+ var reObject = /\[object (.*?)\]/;
503
+
504
+ var m = reObject.exec(text);
505
+ html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>')
506
+ }
507
+
508
+ function appendSelector(object, html)
509
+ {
510
+ html.push('<span class="objectBox-selector">');
511
+
512
+ html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>');
513
+ if (object.id)
514
+ html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>');
515
+ if (object.className)
516
+ html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>');
517
+
518
+ html.push('</span>');
519
+ }
520
+
521
+ function appendNode(node, html)
522
+ {
523
+ if (node.nodeType == 1)
524
+ {
525
+ html.push(
526
+ '<div class="objectBox-element">',
527
+ '&lt;<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>');
528
+
529
+ for (var i = 0; i < node.attributes.length; ++i)
530
+ {
531
+ var attr = node.attributes[i];
532
+ if (!attr.specified)
533
+ continue;
534
+
535
+ html.push('&nbsp;<span class="nodeName">', attr.nodeName.toLowerCase(),
536
+ '</span>=&quot;<span class="nodeValue">', escapeHTML(attr.nodeValue),
537
+ '</span>&quot;')
538
+ }
539
+
540
+ if (node.firstChild)
541
+ {
542
+ html.push('&gt;</div><div class="nodeChildren">');
543
+
544
+ for (var child = node.firstChild; child; child = child.nextSibling)
545
+ appendNode(child, html);
546
+
547
+ html.push('</div><div class="objectBox-element">&lt;/<span class="nodeTag">',
548
+ node.nodeName.toLowerCase(), '&gt;</span></div>');
549
+ }
550
+ else
551
+ html.push('/&gt;</div>');
552
+ }
553
+ else if (node.nodeType == 3)
554
+ {
555
+ html.push('<div class="nodeText">', escapeHTML(node.nodeValue),
556
+ '</div>');
557
+ }
558
+ }
559
+
560
+ // ********************************************************************************************
561
+
562
+ function addEvent(object, name, handler)
563
+ {
564
+ if (document.all)
565
+ object.attachEvent("on"+name, handler);
566
+ else
567
+ object.addEventListener(name, handler, false);
568
+ }
569
+
570
+ function removeEvent(object, name, handler)
571
+ {
572
+ if (document.all)
573
+ object.detachEvent("on"+name, handler);
574
+ else
575
+ object.removeEventListener(name, handler, false);
576
+ }
577
+
578
+ function cancelEvent(event)
579
+ {
580
+ if (document.all)
581
+ event.cancelBubble = true;
582
+ else
583
+ event.stopPropagation();
584
+ }
585
+
586
+ function onError(msg, href, lineNo)
587
+ {
588
+ var html = [];
589
+
590
+ var lastSlash = href.lastIndexOf("/");
591
+ var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1);
592
+
593
+ html.push(
594
+ '<span class="errorMessage">', msg, '</span>',
595
+ '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>'
596
+ );
597
+
598
+ logRow(html, "error");
599
+ };
600
+
601
+ function onKeyDown(event)
602
+ {
603
+ if (event.keyCode == 123)
604
+ toggleConsole();
605
+ else if ((event.keyCode == 108 || event.keyCode == 76) && event.shiftKey
606
+ && (event.metaKey || event.ctrlKey))
607
+ focusCommandLine();
608
+ else
609
+ return;
610
+
611
+ cancelEvent(event);
612
+ }
613
+
614
+ function onSplitterMouseDown(event)
615
+ {
616
+ if (isSafari || isOpera)
617
+ return;
618
+
619
+ addEvent(document, "mousemove", onSplitterMouseMove);
620
+ addEvent(document, "mouseup", onSplitterMouseUp);
621
+
622
+ for (var i = 0; i < frames.length; ++i)
623
+ {
624
+ addEvent(frames[i].document, "mousemove", onSplitterMouseMove);
625
+ addEvent(frames[i].document, "mouseup", onSplitterMouseUp);
626
+ }
627
+ }
628
+
629
+ function onSplitterMouseMove(event)
630
+ {
631
+ var win = document.all
632
+ ? event.srcElement.ownerDocument.parentWindow
633
+ : event.target.ownerDocument.defaultView;
634
+
635
+ var clientY = event.clientY;
636
+ if (win != win.parent)
637
+ clientY += win.frameElement ? win.frameElement.offsetTop : 0;
638
+
639
+ var height = consoleFrame.offsetTop + consoleFrame.clientHeight;
640
+ var y = height - clientY;
641
+
642
+ consoleFrame.style.height = y + "px";
643
+ layout();
644
+ }
645
+
646
+ function onSplitterMouseUp(event)
647
+ {
648
+ removeEvent(document, "mousemove", onSplitterMouseMove);
649
+ removeEvent(document, "mouseup", onSplitterMouseUp);
650
+
651
+ for (var i = 0; i < frames.length; ++i)
652
+ {
653
+ removeEvent(frames[i].document, "mousemove", onSplitterMouseMove);
654
+ removeEvent(frames[i].document, "mouseup", onSplitterMouseUp);
655
+ }
656
+ }
657
+
658
+ function onCommandLineKeyDown(event)
659
+ {
660
+ if (event.keyCode == 13)
661
+ evalCommandLine();
662
+ else if (event.keyCode == 27)
663
+ commandLine.value = "";
664
+ }
665
+
666
+ window.onerror = onError;
667
+ addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown);
668
+
669
+ if (document.documentElement.getAttribute("debug") == "true")
670
+ toggleConsole(true);
671
+ })();
672
+ }
@@ -0,0 +1,10 @@
1
+
2
+ if (!("console" in window) || !("firebug" in console))
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
+ }
Binary file
Binary file