envjs19 0.3.8.20101029121421

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. data/.jslintrbrc +30 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +57 -0
  4. data/DTD/xhtml-lat1.ent +196 -0
  5. data/DTD/xhtml-special.ent +80 -0
  6. data/DTD/xhtml-symbol.ent +237 -0
  7. data/DTD/xhtml.soc +14 -0
  8. data/DTD/xhtml1-frameset.dtd +1235 -0
  9. data/DTD/xhtml1-strict.dtd +978 -0
  10. data/DTD/xhtml1-transitional.dtd +1201 -0
  11. data/DTD/xhtml1.dcl +192 -0
  12. data/Makefile +7 -0
  13. data/Manifest.txt +280 -0
  14. data/README.rdoc +65 -0
  15. data/Rakefile +196 -0
  16. data/Wakefile +11 -0
  17. data/bin/envjsrb +257 -0
  18. data/build.properties +9 -0
  19. data/build.xml +247 -0
  20. data/gm/jquery.js +6002 -0
  21. data/gm/mainx.js +2648 -0
  22. data/gm/sensx.js +135 -0
  23. data/gm/t.js +6 -0
  24. data/gm/x.html +76 -0
  25. data/htmlparser/BrowserTreeBuilder.java +456 -0
  26. data/htmlparser/README +34 -0
  27. data/htmlparser/build.sh +38 -0
  28. data/jsl/jsl +0 -0
  29. data/jsl/jsl.default.conf +129 -0
  30. data/jsl/jsl.exe +0 -0
  31. data/lib/envjs.rb +35 -0
  32. data/lib/envjs/event_loop.js +206 -0
  33. data/lib/envjs/net.rb +3 -0
  34. data/lib/envjs/net/cgi.rb +94 -0
  35. data/lib/envjs/net/file.rb +69 -0
  36. data/lib/envjs/options.rb +11 -0
  37. data/lib/envjs/runtime.rb +346 -0
  38. data/lib/envjs/tempfile.rb +24 -0
  39. data/licenses/GPL-LICENSE.txt +278 -0
  40. data/licenses/MIT-LICENSE.txt +20 -0
  41. data/src/base64.js +80 -0
  42. data/src/build.js +6 -0
  43. data/src/cruft/bad.html +24 -0
  44. data/src/cruft/dom.js +606 -0
  45. data/src/cruft/element.js +297 -0
  46. data/src/cruft/good.html +30 -0
  47. data/src/cruft/good.js +32 -0
  48. data/src/cruft/internal.js +81 -0
  49. data/src/cruft/parser.js +458 -0
  50. data/src/css/properties.js +293 -0
  51. data/src/css/rule.js +22 -0
  52. data/src/css/sizzle.js +717 -0
  53. data/src/css/stylesheet.js +52 -0
  54. data/src/dom/attr.js +55 -0
  55. data/src/dom/cdatasection.js +31 -0
  56. data/src/dom/characterdata.js +119 -0
  57. data/src/dom/comment.js +30 -0
  58. data/src/dom/doctype.js +9 -0
  59. data/src/dom/document.js +1023 -0
  60. data/src/dom/dom.js +134 -0
  61. data/src/dom/element.js +217 -0
  62. data/src/dom/entities.js +273 -0
  63. data/src/dom/exception.js +28 -0
  64. data/src/dom/fragment.js +37 -0
  65. data/src/dom/implementation.js +140 -0
  66. data/src/dom/instruction.js +51 -0
  67. data/src/dom/namednodemap.js +374 -0
  68. data/src/dom/namespace.js +50 -0
  69. data/src/dom/node.js +618 -0
  70. data/src/dom/nodelist.js +195 -0
  71. data/src/dom/parser.js +1207 -0
  72. data/src/dom/text.js +73 -0
  73. data/src/event/event.js +47 -0
  74. data/src/event/mouseevent.js +4 -0
  75. data/src/event/uievent.js +8 -0
  76. data/src/html/a.js +110 -0
  77. data/src/html/anchor.js +80 -0
  78. data/src/html/area.js +57 -0
  79. data/src/html/base.js +26 -0
  80. data/src/html/blockquote-q.js +19 -0
  81. data/src/html/body.js +19 -0
  82. data/src/html/button.js +21 -0
  83. data/src/html/canvas.js +14 -0
  84. data/src/html/col-colgroup.js +49 -0
  85. data/src/html/collection.js +72 -0
  86. data/src/html/cookie.js +153 -0
  87. data/src/html/del-ins.js +25 -0
  88. data/src/html/div.js +28 -0
  89. data/src/html/document.js +364 -0
  90. data/src/html/element.js +382 -0
  91. data/src/html/fieldset.js +19 -0
  92. data/src/html/form.js +484 -0
  93. data/src/html/frame.js +89 -0
  94. data/src/html/frameset.js +25 -0
  95. data/src/html/head.js +44 -0
  96. data/src/html/html.js +0 -0
  97. data/src/html/htmlparser.js +340 -0
  98. data/src/html/iframe.js +26 -0
  99. data/src/html/image.js +0 -0
  100. data/src/html/img.js +62 -0
  101. data/src/html/input-elements.js +307 -0
  102. data/src/html/input.js +65 -0
  103. data/src/html/label.js +26 -0
  104. data/src/html/legend.js +19 -0
  105. data/src/html/link.js +82 -0
  106. data/src/html/map.js +22 -0
  107. data/src/html/meta.js +37 -0
  108. data/src/html/object.js +89 -0
  109. data/src/html/optgroup.js +25 -0
  110. data/src/html/option.js +103 -0
  111. data/src/html/param.js +38 -0
  112. data/src/html/script.js +122 -0
  113. data/src/html/select.js +132 -0
  114. data/src/html/style.js +31 -0
  115. data/src/html/table.js +199 -0
  116. data/src/html/tbody-thead-tfoot.js +92 -0
  117. data/src/html/td-th.js +18 -0
  118. data/src/html/textarea.js +31 -0
  119. data/src/html/title.js +20 -0
  120. data/src/html/tr.js +114 -0
  121. data/src/intro.js +141 -0
  122. data/src/outro.js +70 -0
  123. data/src/parser/html5.detailed.js +10762 -0
  124. data/src/parser/html5.min.js +503 -0
  125. data/src/parser/html5.pretty.js +10815 -0
  126. data/src/parser/intro.js +42 -0
  127. data/src/parser/outro.js +9 -0
  128. data/src/platform/core.js +323 -0
  129. data/src/platform/johnson.js +484 -0
  130. data/src/platform/rhino.js +327 -0
  131. data/src/platform/static/intro.js +41 -0
  132. data/src/platform/static/outro.js +30 -0
  133. data/src/profile/aop.js +238 -0
  134. data/src/profile/profile.js +402 -0
  135. data/src/serializer/xml.js +21 -0
  136. data/src/svg/animatedstring.js +25 -0
  137. data/src/svg/document.js +25 -0
  138. data/src/svg/element.js +22 -0
  139. data/src/svg/locatable.js +17 -0
  140. data/src/svg/rect.js +18 -0
  141. data/src/svg/rectelement.js +24 -0
  142. data/src/svg/stylable.js +49 -0
  143. data/src/svg/svgelement.js +22 -0
  144. data/src/svg/transformable.js +15 -0
  145. data/src/window/css.js +15 -0
  146. data/src/window/dialog.js +16 -0
  147. data/src/window/document.js +28 -0
  148. data/src/window/event.js +265 -0
  149. data/src/window/history.js +62 -0
  150. data/src/window/location.js +156 -0
  151. data/src/window/navigator.js +48 -0
  152. data/src/window/screen.js +53 -0
  153. data/src/window/timer.js +21 -0
  154. data/src/window/window.js +284 -0
  155. data/src/window/xhr.js +135 -0
  156. data/src/xpath/expression.js +49 -0
  157. data/src/xpath/implementation.js +2505 -0
  158. data/src/xpath/result.js +67 -0
  159. data/src/xpath/util.js +551 -0
  160. data/src/xpath/xmltoken.js +149 -0
  161. data/src/xslt/COPYING +34 -0
  162. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  163. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  164. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  165. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  166. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  167. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  168. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  169. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  170. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  171. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  172. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  173. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  174. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  175. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  176. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  177. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  178. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  179. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  180. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  181. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  182. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  183. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  184. data/src/xslt/implementation.js +625 -0
  185. data/src/xslt/processor.js +37 -0
  186. data/src/xslt/util.js +449 -0
  187. data/test/base64.js +80 -0
  188. data/test/call-load-test.js +15 -0
  189. data/test/data.js +45 -0
  190. data/test/debug.js +53 -0
  191. data/test/firebug/errorIcon.png +0 -0
  192. data/test/firebug/firebug.css +209 -0
  193. data/test/firebug/firebug.html +23 -0
  194. data/test/firebug/firebug.js +672 -0
  195. data/test/firebug/firebugx.js +10 -0
  196. data/test/firebug/infoIcon.png +0 -0
  197. data/test/firebug/warningIcon.png +0 -0
  198. data/test/fixtures/html/events.html +171 -0
  199. data/test/fixtures/html/iframe1.html +46 -0
  200. data/test/fixtures/html/iframe1a.html +46 -0
  201. data/test/fixtures/html/iframe2.html +45 -0
  202. data/test/fixtures/html/iframe3.html +28 -0
  203. data/test/fixtures/html/iframeN.html +57 -0
  204. data/test/fixtures/html/malformed.html +181 -0
  205. data/test/fixtures/html/scope.html +81 -0
  206. data/test/fixtures/html/trivial.html +19 -0
  207. data/test/fixtures/html/with_js.html +26 -0
  208. data/test/fixtures/images/icon-blue.png +0 -0
  209. data/test/fixtures/js/external_script.js +1 -0
  210. data/test/fixtures/js/script.js +1 -0
  211. data/test/fixtures/js/script_error.js +2 -0
  212. data/test/foo.html +8 -0
  213. data/test/foo.js +40 -0
  214. data/test/html/events.html +171 -0
  215. data/test/html/iframe1.html +46 -0
  216. data/test/html/iframe1a.html +46 -0
  217. data/test/html/iframe2.html +45 -0
  218. data/test/html/iframe3.html +30 -0
  219. data/test/html/iframeN.html +57 -0
  220. data/test/html/malformed.html +181 -0
  221. data/test/html/scope.html +87 -0
  222. data/test/html/script.js +1 -0
  223. data/test/html/trivial.html +19 -0
  224. data/test/html/with_js.html +26 -0
  225. data/test/index.html +328 -0
  226. data/test/java-prototype.js +9 -0
  227. data/test/jquery.js +6002 -0
  228. data/test/primary-tests.js +26 -0
  229. data/test/prototype-test.js +13 -0
  230. data/test/qunit.js +61 -0
  231. data/test/qunit/qunit/qunit.css +17 -0
  232. data/test/qunit/qunit/qunit.js +997 -0
  233. data/test/scope.html +19 -0
  234. data/test/scope.rb +24 -0
  235. data/test/smp/dmathieu/index.html +8 -0
  236. data/test/specs/dist/env.spec.js +1534 -0
  237. data/test/specs/envjs.spec.css +46 -0
  238. data/test/specs/parser/html.js +31 -0
  239. data/test/specs/parser/spec.html +40 -0
  240. data/test/specs/parser/xml.js +31 -0
  241. data/test/specs/qunit.bdd.js +210 -0
  242. data/test/specs/qunit.css +17 -0
  243. data/test/specs/qunit.js +997 -0
  244. data/test/specs/template/spec-0.js +31 -0
  245. data/test/specs/template/spec-1.js +31 -0
  246. data/test/specs/template/spec.html +40 -0
  247. data/test/specs/window/css.js +23 -0
  248. data/test/specs/window/dialog.js +25 -0
  249. data/test/specs/window/document.js +23 -0
  250. data/test/specs/window/event.js +25 -0
  251. data/test/specs/window/history.js +34 -0
  252. data/test/specs/window/location.js +34 -0
  253. data/test/specs/window/navigator.js +71 -0
  254. data/test/specs/window/screen.js +42 -0
  255. data/test/specs/window/spec.html +48 -0
  256. data/test/specs/window/timer.js +26 -0
  257. data/test/specs/window/window.js +53 -0
  258. data/test/specs/xhr/spec.html +47 -0
  259. data/test/specs/xhr/xhr.js +31 -0
  260. data/test/test.js +10 -0
  261. data/test/unit/dom.js +44 -0
  262. data/test/unit/elementmembers.js +92 -0
  263. data/test/unit/events.js +195 -0
  264. data/test/unit/fixtures/external_script.js +1 -0
  265. data/test/unit/form.js +40 -0
  266. data/test/unit/iframe.js +234 -0
  267. data/test/unit/insertion.js +23 -0
  268. data/test/unit/multi-window.js +212 -0
  269. data/test/unit/nu.validator.js +34 -0
  270. data/test/unit/onload.js +90 -0
  271. data/test/unit/parser.js +122 -0
  272. data/test/unit/prototypecompat.js +22 -0
  273. data/test/unit/proxy.js +6 -0
  274. data/test/unit/scope.js +209 -0
  275. data/test/unit/timer.js +115 -0
  276. data/test/unit/window.js +57 -0
  277. data/test/x.js +1 -0
  278. data/test/y.js +1 -0
  279. metadata +367 -0
data/htmlparser/README ADDED
@@ -0,0 +1,34 @@
1
+ Envjs make use the awesome project 'http://about.validator.nu/htmlparser/'
2
+ which generates an HTML5 compliant parsing engine, written in Java, into
3
+ javascript via GWT.
4
+
5
+ The generated files are available in
6
+ env-js/
7
+ src/
8
+ parser/
9
+ html5.js
10
+ html5.min.js
11
+ html5.detailed.js
12
+
13
+ The various versions are simply generated with varying verbosity of source.
14
+ html.js is the most readable at 60KB, html.detailed.js is almost too verbose at
15
+ over 120KB, and finally html5.min.js is totally unreadable but weighs in at only
16
+ 30KB. By default the html5.min.js is included in Envjs releases because most
17
+ folks aren't too worried about the gory details of the parser.
18
+
19
+ The scripts in this folder can be used to checkout and download the various
20
+ components you will need to generate these yourself.
21
+
22
+ Once generated, there are a couple very small and specific changes that must be
23
+ made by hand to allow the parser to be initialized with the usual GWT hooks.
24
+
25
+ You will need to download the appropiate gwt for your platform
26
+
27
+ http://google-web-toolkit.googlecode.com/files/gwt-mac-1.5.1.tar.gz
28
+ http://google-web-toolkit.googlecode.com/files/gwt-windows-1.5.1.zip
29
+ http://google-web-toolkit.googlecode.com/files/gwt-linux-1.5.1.tar.bz2
30
+
31
+ Our scripts expect that it will be available at
32
+ env-js/
33
+ htmlparser/
34
+ gwt-1.5.1/
@@ -0,0 +1,38 @@
1
+ #!/bin/sh
2
+
3
+ svn co https://whattf.svn.cvsdude.com/htmlparser/trunk/ html5
4
+
5
+ cp BrowserTreeBuilder.java html5/gwt-src/nu/validator/htmlparser/gwt/BrowserTreeBuilder.java
6
+
7
+ cp gwt-1.5.1/gwt-dev-*.jar gwt-1.5.1/gwt-dev.jar
8
+
9
+ APPDIR=`dirname $0`/html5/;
10
+
11
+ echo $APPDIR
12
+
13
+ echo "Generating Minified HTMLParser"
14
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -out "build/min" "$@" nu.validator.htmlparser.HtmlParser;
15
+ cp ./build/min/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.min.js
16
+ perl -pi~ -e "s/if\(j\.addEventListener\)(.*)50\)/\/\*envjsedit\*\//" ./build/html5.min.js
17
+ perl -pi~ -e "s/if\(j\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.min.js
18
+ perl -pi~ -e "s/function kb\(\)/\/\*envjsedit\*\/var kb = Html5Parser = function\(\)/" ./build/html5.min.js
19
+
20
+ echo "Generating Pretty HTMLParser"
21
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style PRETTY -out "build/pretty" "$@" nu.validator.htmlparser.HtmlParser;
22
+ cp ./build/pretty/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.pretty.js
23
+ perl -pi~ -e "s/if(.*)\((.*)doc_0\.addEventListener\)/\/\*envjsedit/s" ./build/html5.pretty.js
24
+ perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.pretty.js
25
+ perl -pi~ -e "s/if(.*)\((.*)doc_0\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.pretty.js
26
+ perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.pretty.js
27
+
28
+ echo "Generating Detailed HTMLParser"
29
+ java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/gwt-src:$APPDIR/super:./gwt-1.5.1/gwt-user.jar:./gwt-1.5.1/gwt-dev.jar" com.google.gwt.dev.GWTCompiler -style DETAILED -out "build/detailed" "$@" nu.validator.htmlparser.HtmlParser;
30
+ cp ./build/detailed/nu.*.HtmlParser/nu.*.HtmlParser.nocache.js ./build/html5.detailed.js
31
+ perl -pi~ -e "s/if(.*)\((.*)doc\.addEventListener\)/\/\*envjsedit/s" ./build/html5.detailed.js
32
+ perl -pi~ -e "s/,\s50\);/envjsedit\*\//s" ./build/html5.detailed.js
33
+ perl -pi~ -e "s/if(.*)\((.*)doc\.removeEventListener\)/if\(false\/\*envjsedit\*\/\)/" ./build/html5.detailed.js
34
+ perl -pi~ -e "s/function onBodyDone\(\)/\/\*envjsedit\*\/var onBodyDone = Html5Parser = function\(\)/" ./build/html5.detailed.js
35
+
36
+ rm ./build/*.js~
37
+
38
+ cp ./build/html5.*.js ../src/parser/
data/jsl/jsl ADDED
Binary file
@@ -0,0 +1,129 @@
1
+ #
2
+ # Configuration File for JavaScript Lint 0.3.0
3
+ # Developed by Matthias Miller (http://www.JavaScriptLint.com)
4
+ #
5
+ # This configuration file can be used to lint a collection of scripts, or to enable
6
+ # or disable warnings for scripts that are linted via the command line.
7
+ #
8
+
9
+ ### Warnings
10
+ # Enable or disable warnings based on requirements.
11
+ # Use "+WarningName" to display or "-WarningName" to suppress.
12
+ #
13
+ +no_return_value # function {0} does not always return a value
14
+ +duplicate_formal # duplicate formal argument {0}
15
+ +equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
16
+ +var_hides_arg # variable {0} hides argument
17
+ +redeclared_var # redeclaration of {0} {1}
18
+ +anon_no_return_value # anonymous function does not always return a value
19
+ +missing_semicolon # missing semicolon
20
+ +meaningless_block # meaningless block; curly braces have no impact
21
+ +comma_separated_stmts # multiple statements separated by commas (use semicolons?)
22
+ +unreachable_code # unreachable code
23
+ +missing_break # missing break statement
24
+ +missing_break_for_last_case # missing break statement for last case in switch
25
+ +comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
26
+ +inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
27
+ +useless_void # use of the void type may be unnecessary (void is always undefined)
28
+ +multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
29
+ +use_of_label # use of label
30
+ -block_without_braces # block statement without curly braces
31
+ +leading_decimal_point # leading decimal point may indicate a number or an object member
32
+ +trailing_decimal_point # trailing decimal point may indicate a number or an object member
33
+ +octal_number # leading zeros make an octal number
34
+ +nested_comment # nested comment
35
+ +misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
36
+ +ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
37
+ -empty_statement # empty statement or extra semicolon
38
+ -missing_option_explicit # the "option explicit" control comment is missing
39
+ +partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
40
+ +dup_option_explicit # duplicate "option explicit" control comment
41
+ +useless_assign # useless assignment
42
+ +ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
43
+ +ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
44
+ +missing_default_case # missing default case in switch statement
45
+ +duplicate_case_in_switch # duplicate case in switch statements
46
+ +default_not_at_end # the default case is not at the end of the switch statement
47
+ +legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
48
+ +jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
49
+ +useless_comparison # useless comparison; comparing identical expressions
50
+ +with_statement # with statement hides undeclared variables; use temporary variable instead
51
+ +trailing_comma_in_array # extra comma is not recommended in array initializers
52
+ +assign_to_function_call # assignment to a function call
53
+ +parseint_missing_radix # parseInt missing radix parameter
54
+
55
+
56
+ ### Output format
57
+ # Customize the format of the error message.
58
+ # __FILE__ indicates current file path
59
+ # __FILENAME__ indicates current file name
60
+ # __LINE__ indicates current line
61
+ # __ERROR__ indicates error message
62
+ #
63
+ # Visual Studio syntax (default):
64
+ +output-format __FILE__(__LINE__): __ERROR__
65
+ # Alternative syntax:
66
+ #+output-format __FILE__:__LINE__: __ERROR__
67
+
68
+
69
+ ### Context
70
+ # Show the in-line position of the error.
71
+ # Use "+context" to display or "-context" to suppress.
72
+ #
73
+ +context
74
+
75
+
76
+ ### Semicolons
77
+ # By default, assignments of an anonymous function to a variable or
78
+ # property (such as a function prototype) must be followed by a semicolon.
79
+ #
80
+ +lambda_assign_requires_semicolon
81
+
82
+
83
+ ### Control Comments
84
+ # Both JavaScript Lint and the JScript interpreter confuse each other with the syntax for
85
+ # the /*@keyword@*/ control comments and JScript conditional comments. (The latter is
86
+ # enabled in JScript with @cc_on@). The /*jsl:keyword*/ syntax is preferred for this reason,
87
+ # although legacy control comments are enabled by default for backward compatibility.
88
+ #
89
+ +legacy_control_comments
90
+
91
+
92
+ ### JScript Function Extensions
93
+ # JScript allows member functions to be defined like this:
94
+ # function MyObj() { /*constructor*/ }
95
+ # function MyObj.prototype.go() { /*member function*/ }
96
+ #
97
+ # It also allows events to be attached like this:
98
+ # function window::onload() { /*init page*/ }
99
+ #
100
+ # This is a Microsoft-only JavaScript extension. Enable this setting to allow them.
101
+ #
102
+ -jscript_function_extensions
103
+
104
+
105
+ ### Defining identifiers
106
+ # By default, "option explicit" is enabled on a per-file basis.
107
+ # To enable this for all files, use "+always_use_option_explicit"
108
+ -always_use_option_explicit
109
+
110
+ # Define certain identifiers of which the lint is not aware.
111
+ # (Use this in conjunction with the "undeclared identifier" warning.)
112
+ #
113
+ # Common uses for webpages might be:
114
+ #+define window
115
+ #+define document
116
+
117
+
118
+ ### Interactive
119
+ # Prompt for a keystroke before exiting.
120
+ #+pauseatend
121
+
122
+
123
+ ### Files
124
+ # Specify which files to lint
125
+ # Use "+recurse" to enable recursion (disabled by default).
126
+ # To add a set of files, use "+process FileName", "+process Folder\Path\*.js",
127
+ # or "+process Folder\Path\*.htm".
128
+ #
129
+ +process jsl-test.js
data/jsl/jsl.exe ADDED
Binary file
data/lib/envjs.rb ADDED
@@ -0,0 +1,35 @@
1
+ module Envjs
2
+
3
+ VERSION = "0.3.8"
4
+
5
+ def self.js_exception_stack e
6
+ result = %(Exception: )+e.to_s
7
+ e.stack.to_s.split(%(\n)).each do |line|
8
+ next if line == "@:0"
9
+ m = line.match(/(.*)@([^@]*)$/)
10
+ s = m[1]
11
+ limit = 50
12
+ if ( s.length > limit )
13
+ s = s[0,limit] + %(...)
14
+ end
15
+ result += "\n" + m[2]+%( )+s
16
+ end
17
+ result
18
+ end
19
+
20
+ ENVJS =
21
+ File.expand_path( File.join( File.dirname(__FILE__),
22
+ "envjs",
23
+ "env.js" ) )
24
+
25
+ EVENT_LOOP =
26
+ File.expand_path( File.join( File.dirname(__FILE__),
27
+ "envjs",
28
+ "event_loop.js" ) )
29
+
30
+ STATIC =
31
+ File.expand_path( File.join( File.dirname(__FILE__),
32
+ "envjs",
33
+ "static.js" ) )
34
+
35
+ end
@@ -0,0 +1,206 @@
1
+ (function(){
2
+ if ($master.eventLoop) {
3
+ throw new Error("event loop multiply defined");
4
+ }
5
+ var el = $master.eventLoop = {};
6
+
7
+ var $env = {};
8
+ $env.sync = function(f){return f;};
9
+ $env.error = function(s){
10
+ debug("timer error: "+s);
11
+ if (s.stack) {
12
+ debug("timer error: "+s.stack);
13
+ }
14
+ };
15
+ $env.sleep = function(t){ Ruby.sleep(t/1000.); };
16
+
17
+ var $timers = [];
18
+ var $event_loop_running = false;
19
+ $timers.lock = $env.sync(function(fn){fn();});
20
+
21
+ var $timer = function(w, fn, interval){
22
+ this.w = w;
23
+ this.fn = fn;
24
+ this.interval = interval;
25
+ this.at = Date.now() + interval;
26
+ this.running = false; // allows for calling wait() from callbacks
27
+ };
28
+
29
+ var convert_time = function(time) {
30
+ time = time*1;
31
+ if ( isNaN(time) || time < 0 ) {
32
+ time = 0;
33
+ }
34
+ // html5 says this should be at least 4, but the parser is using a setTimeout for the SAX stuff
35
+ // which messes up the world
36
+ var min = /* 4 */ 0;
37
+ if ( $event_loop_running && time < min ) {
38
+ time = min;
39
+ }
40
+ return time;
41
+ };
42
+
43
+ var enter_and_exec = function(w,fn) {
44
+
45
+ };
46
+
47
+ el.setTimeout = function(w, fn, time){
48
+ var num;
49
+ time = convert_time(time);
50
+ $timers.lock(function(){
51
+ num = $timers.length+1;
52
+ var tfn;
53
+ if (typeof fn == 'string') {
54
+ tfn = function() {
55
+ try {
56
+ // FIX ME: has to evaluate in inner ... probably in caller?
57
+ eval(fn);
58
+ } catch (e) {
59
+ $env.error(e);
60
+ } finally {
61
+ el.clearInterval(num);
62
+ }
63
+ };
64
+ } else {
65
+ tfn = function() {
66
+ try {
67
+ fn();
68
+ } catch (e) {
69
+ $env.error(e);
70
+ } finally {
71
+ el.clearInterval(num);
72
+ }
73
+ };
74
+ }
75
+ $timers[num] = new $timer(w, tfn, time);
76
+ });
77
+ return num;
78
+ };
79
+
80
+ el.setInterval = function(w, fn, time){
81
+ time = convert_time(time);
82
+ if ( time < 10 ) {
83
+ time = 10;
84
+ }
85
+ if (typeof fn == 'string') {
86
+ var fnstr = fn;
87
+ fn = function() {
88
+ // FIX ME: has to evaluate in inner ... probably in caller(?)
89
+ eval(fnstr);
90
+ };
91
+ }
92
+ var num;
93
+ $timers.lock(function(){
94
+ num = $timers.length+1;
95
+ $timers[num] = new $timer(w, fn, time);
96
+ });
97
+ return num;
98
+ };
99
+
100
+ el.clear = el.clearInterval = el.clearTimeout = function(num){
101
+ //$log("clearing interval "+num);
102
+ $timers.lock(function(){
103
+ if ( $timers[num] ) {
104
+ delete $timers[num];
105
+ }
106
+ });
107
+ };
108
+
109
+ // wait === null/undefined: execute any timers as they fire, waiting until there are none left
110
+ // wait(n) (n > 0): execute any timers as they fire until there are none left waiting at least n ms
111
+ // but no more, even if there are future events/current threads
112
+ // wait(0): execute any immediately runnable timers and return
113
+ // wait(-n): keep sleeping until the next event is more than n ms in the future
114
+
115
+ // FIX: make a priority queue ...
116
+
117
+ el.wait = function(wait) {
118
+ // print("wait",wait,$event_loop_running);
119
+ var fired = false;
120
+ var delta_wait;
121
+ if (wait < 0) {
122
+ delta_wait = -wait;
123
+ wait = 0;
124
+ }
125
+ var start = Date.now();
126
+ var old_loop_running = $event_loop_running;
127
+ $event_loop_running = true;
128
+ if (wait !== 0 && wait !== null && wait !== undefined){
129
+ wait += Date.now();
130
+ }
131
+ for (;;) {
132
+ var earliest;
133
+ $timers.lock(function(){
134
+ earliest = undefined;
135
+ for(var i in $timers){
136
+ if( isNaN(i*0) ) {
137
+ continue;
138
+ }
139
+ var timer = $timers[i];
140
+ if( !timer.running && ( !earliest || timer.at < earliest.at) ) {
141
+ earliest = timer;
142
+ }
143
+ }
144
+ });
145
+ var sleep = earliest && earliest.at - Date.now();
146
+ if ( earliest && sleep <= 0 ) {
147
+ var f = earliest.fn;
148
+ var previous = $master.first_script_window;
149
+ fired = true;
150
+ try {
151
+ earliest.running = true;
152
+ $master.first_script_window = earliest.w;
153
+ f();
154
+ } catch (e) {
155
+ $env.error(e);
156
+ } finally {
157
+ earliest.running = false;
158
+ $master.first_script_window = previous;
159
+ }
160
+ var goal = earliest.at + earliest.interval;
161
+ var now = Date.now();
162
+ if ( goal < now ) {
163
+ earliest.at = now;
164
+ } else {
165
+ earliest.at = goal;
166
+ }
167
+ continue;
168
+ }
169
+
170
+ // bunch of subtle cases here ...
171
+ if ( !earliest ) {
172
+ // no events in the queue (but maybe XHR will bring in events, so ...
173
+ if ( !wait || wait < Date.now() ) {
174
+ // Loop ends if there are no events and a wait hasn't been requested or has expired
175
+ break;
176
+ }
177
+ // no events, but a wait requested: fall through to sleep
178
+ } else {
179
+ // there are events in the queue, but they aren't firable now
180
+ // print(delta_wait,sleep);
181
+ if ( delta_wait && sleep <= delta_wait ) {
182
+ // if they will happen within the next delta, fall through to sleep
183
+ } else if ( wait === 0 || ( wait > 0 && wait < Date.now () ) ) {
184
+ // loop ends even if there are events but the user specifcally asked not to wait too long
185
+ break;
186
+ }
187
+ // there are events and the user wants to wait: fall through to sleep
188
+ }
189
+
190
+ // Related to ajax threads ... hopefully can go away ..
191
+ var interval = el.wait.interval || 100;
192
+ if ( !sleep || sleep > interval ) {
193
+ sleep = interval;
194
+ }
195
+ // the parser sets the timeout at 1 ... the chances of us getting back through this loop in that amount of time
196
+ // are small, no need to both the driver for something so small; just spin
197
+ if (sleep>1) {
198
+ $env.sleep(sleep);
199
+ }
200
+ }
201
+ $event_loop_running = old_loop_running;
202
+ // print("unwait",earliest,sleep);
203
+ return [ fired, earliest && sleep ];
204
+ };
205
+
206
+ }());