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
@@ -0,0 +1,21 @@
1
+ $debug("Defining HTMLButtonElement");
2
+ /*
3
+ * HTMLButtonElement - DOM Level 2
4
+ */
5
+ var HTMLButtonElement = function(ownerDocument) {
6
+ this.HTMLTypeValueInputs = HTMLTypeValueInputs;
7
+ this.HTMLTypeValueInputs(ownerDocument);
8
+ };
9
+ HTMLButtonElement.prototype = new HTMLTypeValueInputs;
10
+ __extend__(HTMLButtonElement.prototype, inputElements_status);
11
+ __extend__(HTMLButtonElement.prototype, {
12
+ get dataFormatAs(){
13
+ return this.getAttribute('dataFormatAs');
14
+ },
15
+ set dataFormatAs(value){
16
+ this.setAttribute('dataFormatAs',value);
17
+ }
18
+ });
19
+
20
+ // $w.HTMLButtonElement = HTMLButtonElement;
21
+
@@ -0,0 +1,14 @@
1
+ $debug("Defining HTMLCanvasElement");
2
+ /*
3
+ * HTMLCanvasElement - DOM Level 2
4
+ */
5
+ var HTMLCanvasElement = function(ownerDocument) {
6
+ this.HTMLElement = HTMLElement;
7
+ this.HTMLElement(ownerDocument);
8
+ };
9
+ HTMLCanvasElement.prototype = new HTMLElement;
10
+ __extend__(HTMLCanvasElement.prototype, {
11
+ });
12
+
13
+ $w.HTMLCanvasElement = HTMLCanvasElement;
14
+
@@ -0,0 +1,49 @@
1
+ $debug("Defining HTMLTableColElement");
2
+ /*
3
+ * HTMLTableColElement - DOM Level 2
4
+ */
5
+ var HTMLTableColElement = function(ownerDocument) {
6
+ this.HTMLElement = HTMLElement;
7
+ this.HTMLElement(ownerDocument);
8
+ };
9
+ HTMLTableColElement.prototype = new HTMLElement;
10
+ __extend__(HTMLTableColElement.prototype, {
11
+ get align(){
12
+ return this.getAttribute('align');
13
+ },
14
+ set align(value){
15
+ this.setAttribute('align', value);
16
+ },
17
+ get ch(){
18
+ return this.getAttribute('ch');
19
+ },
20
+ set ch(value){
21
+ this.setAttribute('ch', value);
22
+ },
23
+ get chOff(){
24
+ return this.getAttribute('ch');
25
+ },
26
+ set chOff(value){
27
+ this.setAttribute('ch', value);
28
+ },
29
+ get span(){
30
+ return this.getAttribute('span');
31
+ },
32
+ set span(value){
33
+ this.setAttribute('span', value);
34
+ },
35
+ get vAlign(){
36
+ return this.getAttribute('valign');
37
+ },
38
+ set vAlign(value){
39
+ this.setAttribute('valign', value);
40
+ },
41
+ get width(){
42
+ return this.getAttribute('width');
43
+ },
44
+ set width(value){
45
+ this.setAttribute('width', value);
46
+ }
47
+ });
48
+
49
+ // $w.HTMLTableColElement = HTMLTableColElement;
@@ -0,0 +1,72 @@
1
+ $debug("Defining HTMLCollection");
2
+ /*
3
+ * HTMLCollection - DOM Level 2
4
+ * Implementation Provided by Steven Wood
5
+ */
6
+ var HTMLCollection = function(nodelist, type){
7
+
8
+ __setArray__(this, []);
9
+ for (var i=0; i<nodelist.length; i++) {
10
+ this[i] = nodelist[i];
11
+ }
12
+
13
+ this.length = nodelist.length;
14
+
15
+ }
16
+
17
+ HTMLCollection.prototype = {
18
+
19
+ item : function (idx) {
20
+ var ret = null;
21
+ if ((idx >= 0) && (idx < this.length)) {
22
+ ret = this[idx];
23
+ }
24
+
25
+ return ret;
26
+ },
27
+
28
+ namedItem : function (name) {
29
+ }
30
+ };
31
+
32
+ // $w.HTMLCollection = HTMLCollection;
33
+
34
+ /*var HTMLCollection = function(nodelist, type){
35
+ var $items = [],
36
+ $item, i;
37
+ if(type === "Anchor" ){
38
+ for(i=0;i<nodelist.length;i++){
39
+ //The name property is required to be add to the collection
40
+ if(nodelist.item(i).name){
41
+ item = new nodelist.item(i);
42
+ $items.push(item);
43
+ this[nodelist.item(i).name] = item;
44
+ }
45
+ }
46
+ }else if(type === "Link"){
47
+ for(i=0;i<nodelist.length;i++){
48
+ //The name property is required to be add to the collection
49
+ if(nodelist.item(i).href){
50
+ item = new nodelist.item(i);
51
+ $items.push(item);
52
+ this[nodelist.item(i).name] = item;
53
+ }
54
+ }
55
+ }else if(type === "Form"){
56
+ for(i=0;i<nodelist.length;i++){
57
+ //The name property is required to be add to the collection
58
+ if(nodelist.item(i).href){
59
+ item = new nodelist.item(i);
60
+ $items.push(item);
61
+ this[nodelist.item(i).name] = item;
62
+ }
63
+ }
64
+ }
65
+ setArray(this, $items);
66
+ return __extend__(this, {
67
+ item : function(i){return this[i];},
68
+ namedItem : function(name){return this[name];}
69
+ });
70
+ };*/
71
+
72
+
@@ -0,0 +1,153 @@
1
+ $debug("Defining document.cookie");
2
+ /*
3
+ * cookie.js
4
+ * - requires env
5
+ */
6
+
7
+ var $cookies = {
8
+ persistent:{
9
+ //domain - key on domain name {
10
+ //path - key on path {
11
+ //name - key on name {
12
+ //value : cookie value
13
+ //other cookie properties
14
+ //}
15
+ //}
16
+ //}
17
+ //expire - provides a timestamp for expiring the cookie
18
+ //cookie - the cookie!
19
+ },
20
+ temporary:{//transient is a reserved word :(
21
+ //like above
22
+ }
23
+ };
24
+
25
+ //HTMLDocument cookie
26
+ __extend__(HTMLDocument.prototype, {
27
+ set cookie(cookie){
28
+ var i,name,value,properties = {},attr,attrs = cookie.split(";");
29
+ //for now the strategy is to simply create a json object
30
+ //and post it to a file in the .cookies.js file. I hate parsing
31
+ //dates so I decided not to implement support for 'expires'
32
+ //(which is deprecated) and instead focus on the easier 'max-age'
33
+ //(which succeeds 'expires')
34
+ cookie = {};//keyword properties of the cookie
35
+ for(i=0;i<attrs.length;i++){
36
+ var index = attrs[i].indexOf("=");
37
+ if(index > -1){
38
+ name = trim(attrs[i].slice(0,index));
39
+ value = trim(attrs[i].slice(index+1));
40
+ cookie['domain'] = "";
41
+ if(name=='max-age'){
42
+ //we'll have to set a timer to check these
43
+ //and garbage collect expired cookies
44
+ cookie[name] = parseInt(value, 10);
45
+ } else if(name=='domain'){
46
+ if(domainValid(value)){
47
+ cookie['domain']=value;
48
+ }else{
49
+ cookie['domain']=this._parentWindow.location.domain;
50
+ }
51
+ } else if(name=='path'){
52
+ //not sure of any special logic for path
53
+ cookie['path'] = value;
54
+ } else {
55
+ //its not a cookie keyword so store it in our array of properties
56
+ //and we'll serialize individually in a moment
57
+ properties[name] = value;
58
+ }
59
+ }else{
60
+ if(attrs[i] == 'secure'){
61
+ cookie[attrs[i]] = true;
62
+ }
63
+ }
64
+ }
65
+ if(!cookie['max-age']){
66
+ //it's a transient cookie so it only lasts as long as
67
+ //the window.location remains the same
68
+ mergeCookie($cookies.temporary, cookie, properties);
69
+ }else if(cookie['max-age']===0){
70
+ //delete the cookies
71
+ //TODO
72
+ }else{
73
+ //the cookie is persistent
74
+ mergeCookie($cookies.persistent, cookie, properties);
75
+ persistCookies();
76
+ }
77
+ },
78
+ get cookie(c){
79
+ //The cookies that are returned must belong to the same domain
80
+ //and be at or below the current window.location.path. Also
81
+ //we must check to see if the cookie was set to 'secure' in which
82
+ //case we must check our current location.protocol to make sure it's
83
+ //https:
84
+ var allcookies = [], i;
85
+ return cookieString.call(this, $cookies.temporary) +
86
+ cookieString.call(this, $cookies.persistent);
87
+ }});
88
+
89
+ var cookieString = function(cookies) {
90
+ var $w = this._parentWindow;
91
+ var cookieString = "";
92
+ for (var i in cookies) {
93
+ // check if the cookie is in the current domain (if domain is set)
94
+ if (i == "" || i == $w.location.domain) {
95
+ for (var j in cookies[i]) {
96
+ // make sure path is at or below the window location path
97
+ if (j == "/" || $w.location.pathname.indexOf(j) === 0) {
98
+ for (var k in cookies[i][j]) {
99
+ cookieString += k + "=" + cookies[i][j][k].value+";";
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ return cookieString;
106
+ }
107
+
108
+
109
+ var domainValid = function(domain){
110
+ //make sure the domain
111
+ //TODO
112
+ };
113
+
114
+ var mergeCookie = function(target, cookie, properties){
115
+ var name, now;
116
+ if(!target[cookie.domain]){
117
+ target[cookie.domain] = {};
118
+ }
119
+ if(!target[cookie.domain][cookie.path]){
120
+ target[cookie.domain][cookie.path] = {};
121
+ }
122
+ for(name in properties){
123
+ now = new Date().getTime();
124
+ target[cookie.domain][cookie.path][name] = {
125
+ value:properties[name],
126
+ "@env:secure":cookie.secure,
127
+ "@env:max-age":cookie['max-age'],
128
+ "@env:date-created":now,
129
+ "@env:expiration":now + cookie['max-age']
130
+ };
131
+ }
132
+ };
133
+
134
+ var persistCookies = function(){
135
+ //TODO
136
+ //I think it should be done via $env so it can be customized
137
+ };
138
+
139
+ var loadCookies = function(){
140
+ //TODO
141
+ //should also be configurable via $env
142
+ };
143
+
144
+ //We simply use the default ajax get to load the .cookies.js file
145
+ //if it doesn't exist we create it with a post. Cookies are maintained
146
+ //in memory, but serialized with each set.
147
+ try{
148
+ //TODO - load cookies
149
+ loadCookies();
150
+ }catch(e){
151
+ //TODO - fail gracefully
152
+ }
153
+
@@ -0,0 +1,25 @@
1
+ $debug("Defining HTMLModElement");
2
+ /*
3
+ * HTMLModElement - DOM Level 2
4
+ */
5
+ var HTMLModElement = function(ownerDocument) {
6
+ this.HTMLElement = HTMLElement;
7
+ this.HTMLElement(ownerDocument);
8
+ };
9
+ HTMLModElement.prototype = new HTMLElement;
10
+ __extend__(HTMLModElement.prototype, {
11
+ get cite(){
12
+ return this.getAttribute('cite');
13
+ },
14
+ set cite(value){
15
+ this.setAttribute('cite', value);
16
+ },
17
+ get dateTime(){
18
+ return this.getAttribute('datetime');
19
+ },
20
+ set dateTime(value){
21
+ this.setAttribute('datetime', value);
22
+ }
23
+ });
24
+
25
+ // $w.HTMLModElement = HTMLModElement;
data/src/html/div.js ADDED
@@ -0,0 +1,28 @@
1
+ /*
2
+ * This file is a component of env.js,
3
+ * http://github.com/gleneivey/env-js/commits/master/README
4
+ * a Pure JavaScript Browser Environment
5
+ * Copyright 2009 John Resig, licensed under the MIT License
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ */
8
+
9
+
10
+ $debug("Defining HTMLDivElement");
11
+ /*
12
+ * HTMLDivElement - DOM Level 2
13
+ */
14
+ var HTMLDivElement = function(ownerDocument) {
15
+ this.HTMLElement = HTMLElement;
16
+ this.HTMLElement(ownerDocument);
17
+ };
18
+ HTMLDivElement.prototype = new HTMLElement;
19
+ __extend__(HTMLDivElement.prototype, {
20
+ get align(){
21
+ return this.getAttribute('align') || 'left';
22
+ },
23
+ set align(value){
24
+ this.setAttribute('align', value);
25
+ }
26
+ });
27
+
28
+ // $w.HTMLDivElement = HTMLDivElement;
@@ -0,0 +1,364 @@
1
+ $debug("Defining HTMLDocument");
2
+ /*
3
+ * HTMLDocument - DOM Level 2
4
+ */
5
+ /**
6
+ * @class HTMLDocument - The Document interface represents the entire HTML or XML document.
7
+ * Conceptually, it is the root of the document tree, and provides the primary access to the document's data.
8
+ *
9
+ * @extends DOMDocument
10
+ */
11
+ var HTMLDocument = function(implementation, docParentWindow, docReferrer) {
12
+ this.DOMDocument = DOMDocument;
13
+ this.DOMDocument(implementation, docParentWindow);
14
+
15
+ this._referrer = docReferrer;
16
+ this._domain;
17
+ this._open = false;
18
+ this.$async = false;
19
+ };
20
+ HTMLDocument.prototype = new DOMDocument;
21
+ __extend__(HTMLDocument.prototype, {
22
+ loadXML : function(xmlString, url) {
23
+ if (url) {
24
+ var $env = this._parentWindow.$envx;
25
+ $env.__url(url);
26
+ }
27
+
28
+ // create DOM Document
29
+ /*
30
+ if(this === $document){
31
+ $debug("Setting internal window.document");
32
+ $document = this;
33
+ }
34
+ */
35
+ // populate Document with Parsed Nodes
36
+ try {
37
+ // make sure thid document object is empty before we try to load ...
38
+ this.childNodes = new DOMNodeList(this, this);
39
+ this.firstChild = null;
40
+ this.lastChild = null;
41
+ this.attributes = new DOMNamedNodeMap(this, this);
42
+ this._namespaces = new DOMNamespaceNodeMap(this, this);
43
+ this._readonly = false;
44
+
45
+ // var now = Date.now();
46
+ // print("begin parse");
47
+ try{
48
+ this._parentWindow.parseHtmlDocument(xmlString, this, null, null);
49
+ }catch(e){
50
+ print("oopsd",e);
51
+ throw e;
52
+ }
53
+ // print("end parse");
54
+ // print("parse time: "+(Date.now() - now)/1000.);
55
+ // print("parse: "+xmlString.substring(0,80));
56
+
57
+
58
+ } catch (e) {
59
+ $error(e);
60
+ }
61
+
62
+ // set parseComplete flag, (Some validation Rules are relaxed if this is false)
63
+ this._parseComplete = true;
64
+ return this;
65
+ },
66
+ createElement: function(tagName){
67
+ var node;
68
+ //print('createElement :'+tagName);
69
+ // throw Exception if the tagName string contains an illegal character
70
+ if (__ownerDocument__(this).implementation.errorChecking &&
71
+ (!__isValidName__(tagName))) {
72
+ throw(new DOMException(DOMException.INVALID_CHARACTER_ERR));
73
+ }
74
+ var originalName = tagName;
75
+ tagName = tagName.toUpperCase();
76
+ // create DOMElement specifying 'this' as ownerDocument
77
+ //This is an html document so we need to use explicit interfaces per the
78
+ if( tagName.match(/^A$/)) {node = new HTMLAnchorElement(this);}
79
+ else if(tagName.match(/^AREA$/)) {node = new HTMLAreaElement(this);}
80
+ else if(tagName.match(/BASE/)) {node = new HTMLBaseElement(this);}
81
+ else if(tagName.match(/BLOCKQUOTE|Q/)) {node = new HTMLQuoteElement(this);}
82
+ else if(tagName.match(/BODY/)) {node = new HTMLBodyElement(this);}
83
+ else if(tagName.match(/BR/)) {node = new HTMLElement(this);}
84
+ else if(tagName.match(/BUTTON/)) {node = new HTMLButtonElement(this);}
85
+ else if(tagName.match(/CAPTION/)) {node = new HTMLElement(this);}
86
+ else if(tagName.match(/COL|COLGROUP/)) {node = new HTMLTableColElement(this);}
87
+ else if(tagName.match(/DEL|INS/)) {node = new HTMLModElement(this);}
88
+ else if(tagName.match(/DIV/)) {node = new HTMLDivElement(this);}
89
+ else if(tagName.match(/DL/)) {node = new HTMLElement(this);}
90
+ else if(tagName.match(/FIELDSET/)) {node = new HTMLFieldSetElement(this);}
91
+ else if(tagName.match(/FORM/)) {node = new HTMLFormElement(this);}
92
+ else if(tagName.match(/^FRAME$/)) {node = new HTMLFrameElement(this);}
93
+ else if(tagName.match(/FRAMESET/)) {node = new HTMLFrameSetElement(this);}
94
+ else if(tagName.match(/H1|H2|H3|H4|H5|H6/)) {node = new HTMLElement(this);}
95
+ else if(tagName.match(/HEAD/)) {node = new HTMLHeadElement(this);}
96
+ else if(tagName.match(/HR/)) {node = new HTMLElement(this);}
97
+ else if(tagName.match(/HTML/)) {node = new HTMLElement(this);}
98
+ else if(tagName.match(/IFRAME/)) {node = new HTMLIFrameElement(this);}
99
+ else if(tagName.match(/IMG/)) {node = new HTMLImageElement(this);}
100
+ else if(tagName.match(/INPUT/)) {node = new HTMLInputElement(this);}
101
+ else if(tagName.match(/LABEL/)) {node = new HTMLLabelElement(this);}
102
+ else if(tagName.match(/LEGEND/)) {node = new HTMLLegendElement(this);}
103
+ else if(tagName.match(/^LI$/)) {node = new HTMLElement(this);}
104
+ else if(tagName.match(/LINK/)) {node = new HTMLLinkElement(this);}
105
+ else if(tagName.match(/MAP/)) {node = new HTMLMapElement(this);}
106
+ else if(tagName.match(/META/)) {node = new HTMLMetaElement(this);}
107
+ else if(tagName.match(/OBJECT/)) {node = new HTMLObjectElement(this);}
108
+ else if(tagName.match(/OL/)) {node = new HTMLElement(this);}
109
+ else if(tagName.match(/OPTGROUP/)) {node = new HTMLOptGroupElement(this);}
110
+ else if(tagName.match(/OPTION/)) {node = new HTMLOptionElement(this);;}
111
+ else if(tagName.match(/^P$/)) {node = new HTMLElement(this);}
112
+ else if(tagName.match(/PARAM/)) {node = new HTMLParamElement(this);}
113
+ else if(tagName.match(/PRE/)) {node = new HTMLElement(this);}
114
+ else if(tagName.match(/SCRIPT/)) {node = new HTMLScriptElement(this);}
115
+ else if(tagName.match(/SELECT/)) {node = new HTMLSelectElement(this);}
116
+ else if(tagName.match(/STYLE/)) {node = new HTMLStyleElement(this);}
117
+ else if(tagName.match(/TABLE/)) {node = new HTMLTableElement(this);}
118
+ else if(tagName.match(/TBODY|TFOOT|THEAD/)) {node = new HTMLTableSectionElement(this);}
119
+ else if(tagName.match(/TD|TH/)) {node = new HTMLTableCellElement(this);}
120
+ else if(tagName.match(/TEXTAREA/)) {node = new HTMLTextAreaElement(this);}
121
+ else if(tagName.match(/TITLE/)) {node = new HTMLTitleElement(this);}
122
+ else if(tagName.match(/TR/)) {node = new HTMLTableRowElement(this);}
123
+ else if(tagName.match(/UL/)) {node = new HTMLElement(this);}
124
+ else{
125
+ node = new HTMLElement(this);
126
+ }
127
+
128
+ // assign values to properties (and aliases)
129
+ node.tagName = tagName; // originalName;
130
+ return node;
131
+ },
132
+ createElementNS : function (uri, local) {
133
+ //print('createElementNS :'+uri+" "+local);
134
+ if(!uri){
135
+ return this.createElement(local);
136
+ }else if ("http://www.w3.org/1999/xhtml" == uri) {
137
+ return this.createElement(local);
138
+ } else if ("http://www.w3.org/1998/Math/MathML" == uri) {
139
+ if (!this.mathplayerinitialized) {
140
+ var obj = this.createElement("object");
141
+ obj.setAttribute("id", "mathplayer");
142
+ obj.setAttribute("classid", "clsid:32F66A20-7614-11D4-BD11-00104BD3F987");
143
+ this.getElementsByTagName("head")[0].appendChild(obj);
144
+ this.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
145
+ this.mathplayerinitialized = true;
146
+ }
147
+ return this.createElement("m:" + local);
148
+ } else {
149
+ return DOMDocument.prototype.createElementNS.apply(this,[uri, local]);
150
+ }
151
+ },
152
+ get anchors(){
153
+ return new HTMLCollection(this.getElementsByTagName('a'), 'Anchor');
154
+
155
+ },
156
+ get applets(){
157
+ return new HTMLCollection(this.getElementsByTagName('applet'), 'Applet');
158
+
159
+ },
160
+ get body(){
161
+ var nodelist = this.getElementsByTagName('body');
162
+ return nodelist.item(0);
163
+
164
+ },
165
+ set body(html){
166
+ return this.replaceNode(this.body,html);
167
+
168
+ },
169
+
170
+ get title(){
171
+ var titleArray = this.getElementsByTagName('title');
172
+ if (titleArray.length < 1)
173
+ return "";
174
+ return titleArray[0].text;
175
+ },
176
+ set title(titleStr){
177
+ titleArray = this.getElementsByTagName('title');
178
+ if (titleArray.length < 1){
179
+ // need to make a new element and add it to "head"
180
+ var titleElem = new HTMLTitleElement(this);
181
+ titleElem.text = titleStr;
182
+ var headArray = this.getElementsByTagName('head');
183
+ if (headArray.length < 1)
184
+ return; // ill-formed, just give up.....
185
+ headArray[0].appendChild(titleElem);
186
+ }
187
+ else {
188
+ titleArray[0].text = titleStr;
189
+ }
190
+ },
191
+
192
+ //set/get cookie see cookie.js
193
+ get domain(){
194
+ return this._domain||this._parentWindow.location.domain;
195
+
196
+ },
197
+ set domain(){
198
+ /* TODO - requires a bit of thought to enforce domain restrictions */
199
+ return;
200
+
201
+ },
202
+ get forms(){
203
+ return new HTMLCollection(this.getElementsByTagName('form'), 'Form');
204
+ },
205
+ get images(){
206
+ return new HTMLCollection(this.getElementsByTagName('img'), 'Image');
207
+
208
+ },
209
+ get lastModified(){
210
+ /* TODO */
211
+ return this._lastModified;
212
+
213
+ },
214
+ get links(){
215
+ return new HTMLCollection(this.getElementsByTagName('a'), 'Link');
216
+
217
+ },
218
+ get location(){
219
+ return this._parentWindow.location
220
+ },
221
+ get referrer(){
222
+ return this._referrer;
223
+ },
224
+ close : function(){
225
+ /* TODO */
226
+ this._open = false;
227
+ },
228
+ getElementsByName : function(name){
229
+ //returns a real Array + the DOMNodeList
230
+ var retNodes = __extend__([],new DOMNodeList(this, this.documentElement)),
231
+ node;
232
+ // loop through all Elements in the 'all' collection
233
+ var all = this.all;
234
+ for (var i=0; i < all.length; i++) {
235
+ node = all[i];
236
+ if (node.nodeType == DOMNode.ELEMENT_NODE && node.getAttribute('name') == name) {
237
+ retNodes.push(node);
238
+ }
239
+ }
240
+ return retNodes;
241
+ },
242
+ open : function(){
243
+ /* TODO */
244
+ this._open = true;
245
+ },
246
+ write: function(htmlstring){
247
+ /* TODO */
248
+ return;
249
+
250
+ },
251
+ writeln: function(htmlstring){
252
+ this.write(htmlstring+'\n');
253
+ },
254
+ toString: function(){
255
+ return "HTMLDocument" + (typeof this._url == "string" ? ": " + this._url : "");
256
+ },
257
+ get innerHTML(){
258
+ return this.documentElement.outerHTML;
259
+
260
+ },
261
+ get __html__(){
262
+ return true;
263
+
264
+ },
265
+ get async(){ return this.$async;},
266
+ set async(async){ this.$async = async; },
267
+ get baseURI(){
268
+ var $env = this.ownerDocument._parentWindow.$envx;
269
+ return $env.location('./');
270
+ },
271
+ get URL(){ return this._parentWindow.location.href; },
272
+ set URL(url){ this._parentWindow.location.href = url; },
273
+ });
274
+
275
+ var __elementPopped__ = function(ns, name, node){
276
+ try{
277
+ var $env = __ownerDocument__(node)._parentWindow.$envx;
278
+ // $error('Element Popped: '+ns+" "+name+ " "+ node+" " +node.type+" "+node.nodeName);
279
+ var doc = __ownerDocument__(node);
280
+ // SMP: subtle issue here: we're currently getting two kinds of script nodes from the html5 parser.
281
+ // The "fake" nodes come with a type of undefined. The "real" nodes come with the type that's given,
282
+ // or null if not given. So the following check has the side-effect of ignoring the "fake" nodes. So
283
+ // something to watch for if this code changes.
284
+ var type = ( node.type === null ) ? "text/javascript" : node.type;
285
+ try{
286
+ if(node.nodeName.toLowerCase() == 'script' && type == "text/javascript"){
287
+ // print(node,doc.in_inner_html);
288
+ if (doc.in_inner_html) {
289
+ // this is a fib, but ...
290
+ // print("ignore",node);
291
+ // node.executed = true;
292
+ } else {
293
+ //$env.debug("element popped: script\n"+node.xml);
294
+ // unless we're parsing in a window context, don't execute scripts
295
+ // this probably doesn't do anything ...
296
+ if (true /*doc.parentWindow && !node.ownerDocument.is_innerHTML*/){
297
+ //p.replaceEntities = true;
298
+ var okay = $env.loadLocalScript(node, null);
299
+ // only fire event if we actually had something to load
300
+ if (node.src && node.src.length > 0){
301
+ var event = doc.createEvent();
302
+ event.initEvent( okay ? "load" : "error", false, false );
303
+ node.dispatchEvent( event, false );
304
+ }
305
+ }
306
+ }
307
+ }
308
+ else if (node.nodeName.toLowerCase() == 'frame' ||
309
+ node.nodeName.toLowerCase() == 'iframe' ){
310
+
311
+ //$env.debug("element popped: iframe\n"+node.xml);
312
+ if (node.src && node.src.length > 0){
313
+ $debug("getting content document for (i)frame from " + node.src);
314
+
315
+ // any JS here is DOM-instigated, so the JS scope is the window, not the first script
316
+
317
+ var $inner = node.ownerDocument._parentWindow["$inner"];
318
+
319
+ var save = $master.first_script_window;
320
+ $master.first_script_window = $inner;
321
+
322
+ $env.loadFrame(node, $env.location(node.src));
323
+
324
+ $master.first_script_window = save;
325
+
326
+ var event = doc.createEvent();
327
+ event.initEvent("load", false, false);
328
+ node.dispatchEvent( event, false );
329
+ }
330
+ }
331
+ else if (node.nodeName.toLowerCase() == 'link'){
332
+ //$env.debug("element popped: link\n"+node.xml);
333
+ if (node.href && node.href.length > 0){
334
+ // don't actually load anything, so we're "done" immediately:
335
+ var event = doc.createEvent();
336
+ event.initEvent("load", false, false);
337
+ node.dispatchEvent( event, false );
338
+ }
339
+ }
340
+ else if (node.nodeName.toLowerCase() == 'img'){
341
+ //$env.debug("element popped: img \n"+node.xml);
342
+ if (node.src && node.src.length > 0){
343
+ // don't actually load anything, so we're "done" immediately:
344
+ var event = doc.createEvent();
345
+ event.initEvent("load", false, false);
346
+ node.dispatchEvent( event, false );
347
+ }
348
+ }
349
+ }catch(e){
350
+ $error('error loading html element', e);
351
+ $error(e);
352
+ }
353
+ } catch(e) {
354
+ $error("arg",e);
355
+ }
356
+ };
357
+
358
+ //$w.HTMLDocument = HTMLDocument;
359
+
360
+ // Local Variables:
361
+ // espresso-indent-level:4
362
+ // c-basic-offset:4
363
+ // tab-width:4
364
+ // End: