envjs19 0.3.8.20101029121421
Sign up to get free protection for your applications and to get access to all the features.
- data/.jslintrbrc +30 -0
- data/.project +17 -0
- data/CHANGELOG.rdoc +57 -0
- data/DTD/xhtml-lat1.ent +196 -0
- data/DTD/xhtml-special.ent +80 -0
- data/DTD/xhtml-symbol.ent +237 -0
- data/DTD/xhtml.soc +14 -0
- data/DTD/xhtml1-frameset.dtd +1235 -0
- data/DTD/xhtml1-strict.dtd +978 -0
- data/DTD/xhtml1-transitional.dtd +1201 -0
- data/DTD/xhtml1.dcl +192 -0
- data/Makefile +7 -0
- data/Manifest.txt +280 -0
- data/README.rdoc +65 -0
- data/Rakefile +196 -0
- data/Wakefile +11 -0
- data/bin/envjsrb +257 -0
- data/build.properties +9 -0
- data/build.xml +247 -0
- data/gm/jquery.js +6002 -0
- data/gm/mainx.js +2648 -0
- data/gm/sensx.js +135 -0
- data/gm/t.js +6 -0
- data/gm/x.html +76 -0
- data/htmlparser/BrowserTreeBuilder.java +456 -0
- data/htmlparser/README +34 -0
- data/htmlparser/build.sh +38 -0
- data/jsl/jsl +0 -0
- data/jsl/jsl.default.conf +129 -0
- data/jsl/jsl.exe +0 -0
- data/lib/envjs.rb +35 -0
- data/lib/envjs/event_loop.js +206 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +69 -0
- data/lib/envjs/options.rb +11 -0
- data/lib/envjs/runtime.rb +346 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/licenses/GPL-LICENSE.txt +278 -0
- data/licenses/MIT-LICENSE.txt +20 -0
- data/src/base64.js +80 -0
- data/src/build.js +6 -0
- data/src/cruft/bad.html +24 -0
- data/src/cruft/dom.js +606 -0
- data/src/cruft/element.js +297 -0
- data/src/cruft/good.html +30 -0
- data/src/cruft/good.js +32 -0
- data/src/cruft/internal.js +81 -0
- data/src/cruft/parser.js +458 -0
- data/src/css/properties.js +293 -0
- data/src/css/rule.js +22 -0
- data/src/css/sizzle.js +717 -0
- data/src/css/stylesheet.js +52 -0
- data/src/dom/attr.js +55 -0
- data/src/dom/cdatasection.js +31 -0
- data/src/dom/characterdata.js +119 -0
- data/src/dom/comment.js +30 -0
- data/src/dom/doctype.js +9 -0
- data/src/dom/document.js +1023 -0
- data/src/dom/dom.js +134 -0
- data/src/dom/element.js +217 -0
- data/src/dom/entities.js +273 -0
- data/src/dom/exception.js +28 -0
- data/src/dom/fragment.js +37 -0
- data/src/dom/implementation.js +140 -0
- data/src/dom/instruction.js +51 -0
- data/src/dom/namednodemap.js +374 -0
- data/src/dom/namespace.js +50 -0
- data/src/dom/node.js +618 -0
- data/src/dom/nodelist.js +195 -0
- data/src/dom/parser.js +1207 -0
- data/src/dom/text.js +73 -0
- data/src/event/event.js +47 -0
- data/src/event/mouseevent.js +4 -0
- data/src/event/uievent.js +8 -0
- data/src/html/a.js +110 -0
- data/src/html/anchor.js +80 -0
- data/src/html/area.js +57 -0
- data/src/html/base.js +26 -0
- data/src/html/blockquote-q.js +19 -0
- data/src/html/body.js +19 -0
- data/src/html/button.js +21 -0
- data/src/html/canvas.js +14 -0
- data/src/html/col-colgroup.js +49 -0
- data/src/html/collection.js +72 -0
- data/src/html/cookie.js +153 -0
- data/src/html/del-ins.js +25 -0
- data/src/html/div.js +28 -0
- data/src/html/document.js +364 -0
- data/src/html/element.js +382 -0
- data/src/html/fieldset.js +19 -0
- data/src/html/form.js +484 -0
- data/src/html/frame.js +89 -0
- data/src/html/frameset.js +25 -0
- data/src/html/head.js +44 -0
- data/src/html/html.js +0 -0
- data/src/html/htmlparser.js +340 -0
- data/src/html/iframe.js +26 -0
- data/src/html/image.js +0 -0
- data/src/html/img.js +62 -0
- data/src/html/input-elements.js +307 -0
- data/src/html/input.js +65 -0
- data/src/html/label.js +26 -0
- data/src/html/legend.js +19 -0
- data/src/html/link.js +82 -0
- data/src/html/map.js +22 -0
- data/src/html/meta.js +37 -0
- data/src/html/object.js +89 -0
- data/src/html/optgroup.js +25 -0
- data/src/html/option.js +103 -0
- data/src/html/param.js +38 -0
- data/src/html/script.js +122 -0
- data/src/html/select.js +132 -0
- data/src/html/style.js +31 -0
- data/src/html/table.js +199 -0
- data/src/html/tbody-thead-tfoot.js +92 -0
- data/src/html/td-th.js +18 -0
- data/src/html/textarea.js +31 -0
- data/src/html/title.js +20 -0
- data/src/html/tr.js +114 -0
- data/src/intro.js +141 -0
- data/src/outro.js +70 -0
- data/src/parser/html5.detailed.js +10762 -0
- data/src/parser/html5.min.js +503 -0
- data/src/parser/html5.pretty.js +10815 -0
- data/src/parser/intro.js +42 -0
- data/src/parser/outro.js +9 -0
- data/src/platform/core.js +323 -0
- data/src/platform/johnson.js +484 -0
- data/src/platform/rhino.js +327 -0
- data/src/platform/static/intro.js +41 -0
- data/src/platform/static/outro.js +30 -0
- data/src/profile/aop.js +238 -0
- data/src/profile/profile.js +402 -0
- data/src/serializer/xml.js +21 -0
- data/src/svg/animatedstring.js +25 -0
- data/src/svg/document.js +25 -0
- data/src/svg/element.js +22 -0
- data/src/svg/locatable.js +17 -0
- data/src/svg/rect.js +18 -0
- data/src/svg/rectelement.js +24 -0
- data/src/svg/stylable.js +49 -0
- data/src/svg/svgelement.js +22 -0
- data/src/svg/transformable.js +15 -0
- data/src/window/css.js +15 -0
- data/src/window/dialog.js +16 -0
- data/src/window/document.js +28 -0
- data/src/window/event.js +265 -0
- data/src/window/history.js +62 -0
- data/src/window/location.js +156 -0
- data/src/window/navigator.js +48 -0
- data/src/window/screen.js +53 -0
- data/src/window/timer.js +21 -0
- data/src/window/window.js +284 -0
- data/src/window/xhr.js +135 -0
- data/src/xpath/expression.js +49 -0
- data/src/xpath/implementation.js +2505 -0
- data/src/xpath/result.js +67 -0
- data/src/xpath/util.js +551 -0
- data/src/xpath/xmltoken.js +149 -0
- data/src/xslt/COPYING +34 -0
- data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
- data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
- data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
- data/src/xslt/ajaxslt-0.8.1/README +102 -0
- data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
- data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
- data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
- data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
- data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
- data/src/xslt/implementation.js +625 -0
- data/src/xslt/processor.js +37 -0
- data/src/xslt/util.js +449 -0
- data/test/base64.js +80 -0
- data/test/call-load-test.js +15 -0
- data/test/data.js +45 -0
- data/test/debug.js +53 -0
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -0
- data/test/foo.html +8 -0
- data/test/foo.js +40 -0
- data/test/html/events.html +171 -0
- data/test/html/iframe1.html +46 -0
- data/test/html/iframe1a.html +46 -0
- data/test/html/iframe2.html +45 -0
- data/test/html/iframe3.html +30 -0
- data/test/html/iframeN.html +57 -0
- data/test/html/malformed.html +181 -0
- data/test/html/scope.html +87 -0
- data/test/html/script.js +1 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +328 -0
- data/test/java-prototype.js +9 -0
- data/test/jquery.js +6002 -0
- data/test/primary-tests.js +26 -0
- data/test/prototype-test.js +13 -0
- data/test/qunit.js +61 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/scope.html +19 -0
- data/test/scope.rb +24 -0
- data/test/smp/dmathieu/index.html +8 -0
- data/test/specs/dist/env.spec.js +1534 -0
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/specs/qunit.css +17 -0
- data/test/specs/qunit.js +997 -0
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/dom.js +44 -0
- data/test/unit/elementmembers.js +92 -0
- data/test/unit/events.js +195 -0
- data/test/unit/fixtures/external_script.js +1 -0
- data/test/unit/form.js +40 -0
- data/test/unit/iframe.js +234 -0
- data/test/unit/insertion.js +23 -0
- data/test/unit/multi-window.js +212 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +90 -0
- data/test/unit/parser.js +122 -0
- data/test/unit/prototypecompat.js +22 -0
- data/test/unit/proxy.js +6 -0
- data/test/unit/scope.js +209 -0
- data/test/unit/timer.js +115 -0
- data/test/unit/window.js +57 -0
- data/test/x.js +1 -0
- data/test/y.js +1 -0
- metadata +367 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
require 'envjs'
|
4
|
+
|
5
|
+
class Envjs::TempFile < Tempfile
|
6
|
+
|
7
|
+
def initialize pattern, suffix = nil
|
8
|
+
super(pattern)
|
9
|
+
|
10
|
+
|
11
|
+
if suffix
|
12
|
+
new_path = path + "." + suffix
|
13
|
+
File.link path, new_path
|
14
|
+
File.unlink path
|
15
|
+
# blah ... implementation specific ...
|
16
|
+
@data[0] = @tmpname = new_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def getAbsolutePath
|
21
|
+
path
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,278 @@
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
|
+
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
Preamble
|
10
|
+
|
11
|
+
The licenses for most software are designed to take away your
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
14
|
+
software--to make sure the software is free for all its users. This
|
15
|
+
General Public License applies to most of the Free Software
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
19
|
+
your programs, too.
|
20
|
+
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
24
|
+
this service if you wish), that you receive source code or can get it
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
26
|
+
in new free programs; and that you know you can do these things.
|
27
|
+
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
31
|
+
distribute copies of the software, or if you modify it.
|
32
|
+
|
33
|
+
For example, if you distribute copies of such a program, whether
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
36
|
+
source code. And you must show them these terms so they know their
|
37
|
+
rights.
|
38
|
+
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
41
|
+
distribute and/or modify the software.
|
42
|
+
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
44
|
+
that everyone understands that there is no warranty for this free
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
46
|
+
want its recipients to know that what they have is not the original, so
|
47
|
+
that any problems introduced by others will not reflect on the original
|
48
|
+
authors' reputations.
|
49
|
+
|
50
|
+
Finally, any free program is threatened constantly by software
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
55
|
+
|
56
|
+
The precise terms and conditions for copying, distribution and
|
57
|
+
modification follow.
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
|
+
|
62
|
+
0. This License applies to any program or other work which contains
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
66
|
+
means either the Program or any derivative work under copyright law:
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
68
|
+
either verbatim or with modifications and/or translated into another
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
71
|
+
|
72
|
+
Activities other than copying, distribution and modification are not
|
73
|
+
covered by this License; they are outside its scope. The act of
|
74
|
+
running the Program is not restricted, and the output from the Program
|
75
|
+
is covered only if its contents constitute a work based on the
|
76
|
+
Program (independent of having been made by running the Program).
|
77
|
+
Whether that is true depends on what the Program does.
|
78
|
+
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
80
|
+
source code as you receive it, in any medium, provided that you
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
84
|
+
and give any other recipients of the Program a copy of this License
|
85
|
+
along with the Program.
|
86
|
+
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
89
|
+
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
93
|
+
above, provided that you also meet all of these conditions:
|
94
|
+
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
96
|
+
stating that you changed the files and the date of any change.
|
97
|
+
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
99
|
+
whole or in part contains or is derived from the Program or any
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
101
|
+
parties under the terms of this License.
|
102
|
+
|
103
|
+
c) If the modified program normally reads commands interactively
|
104
|
+
when run, you must cause it, when started running for such
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
106
|
+
announcement including an appropriate copyright notice and a
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
108
|
+
a warranty) and that users may redistribute the program under
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
111
|
+
does not normally print such an announcement, your work based on
|
112
|
+
the Program is not required to print an announcement.)
|
113
|
+
|
114
|
+
These requirements apply to the modified work as a whole. If
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
116
|
+
and can be reasonably considered independent and separate works in
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
118
|
+
sections when you distribute them as separate works. But when you
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
121
|
+
this License, whose permissions for other licensees extend to the
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123
|
+
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
126
|
+
exercise the right to control the distribution of derivative or
|
127
|
+
collective works based on the Program.
|
128
|
+
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
131
|
+
a storage or distribution medium does not bring the other work under
|
132
|
+
the scope of this License.
|
133
|
+
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
137
|
+
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
139
|
+
source code, which must be distributed under the terms of Sections
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141
|
+
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
143
|
+
years, to give any third party, for a charge no more than your
|
144
|
+
cost of physically performing source distribution, a complete
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147
|
+
customarily used for software interchange; or,
|
148
|
+
|
149
|
+
c) Accompany it with the information you received as to the offer
|
150
|
+
to distribute corresponding source code. (This alternative is
|
151
|
+
allowed only for noncommercial distribution and only if you
|
152
|
+
received the program in object code or executable form with such
|
153
|
+
an offer, in accord with Subsection b above.)
|
154
|
+
|
155
|
+
The source code for a work means the preferred form of the work for
|
156
|
+
making modifications to it. For an executable work, complete source
|
157
|
+
code means all the source code for all modules it contains, plus any
|
158
|
+
associated interface definition files, plus the scripts used to
|
159
|
+
control compilation and installation of the executable. However, as a
|
160
|
+
special exception, the source code distributed need not include
|
161
|
+
anything that is normally distributed (in either source or binary
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
163
|
+
operating system on which the executable runs, unless that component
|
164
|
+
itself accompanies the executable.
|
165
|
+
|
166
|
+
If distribution of executable or object code is made by offering
|
167
|
+
access to copy from a designated place, then offering equivalent
|
168
|
+
access to copy the source code from the same place counts as
|
169
|
+
distribution of the source code, even though third parties are not
|
170
|
+
compelled to copy the source along with the object code.
|
171
|
+
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173
|
+
except as expressly provided under this License. Any attempt
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175
|
+
void, and will automatically terminate your rights under this License.
|
176
|
+
However, parties who have received copies, or rights, from you under
|
177
|
+
this License will not have their licenses terminated so long as such
|
178
|
+
parties remain in full compliance.
|
179
|
+
|
180
|
+
5. You are not required to accept this License, since you have not
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
182
|
+
distribute the Program or its derivative works. These actions are
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
184
|
+
modifying or distributing the Program (or any work based on the
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
187
|
+
the Program or works based on it.
|
188
|
+
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
190
|
+
Program), the recipient automatically receives a license from the
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
192
|
+
these terms and conditions. You may not impose any further
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
195
|
+
this License.
|
196
|
+
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
207
|
+
the only way you could satisfy both it and this License would be to
|
208
|
+
refrain entirely from distribution of the Program.
|
209
|
+
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
212
|
+
apply and the section as a whole is intended to apply in other
|
213
|
+
circumstances.
|
214
|
+
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
216
|
+
patents or other property right claims or to contest validity of any
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
218
|
+
integrity of the free software distribution system, which is
|
219
|
+
implemented by public license practices. Many people have made
|
220
|
+
generous contributions to the wide range of software distributed
|
221
|
+
through that system in reliance on consistent application of that
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
223
|
+
to distribute software through any other system and a licensee cannot
|
224
|
+
impose that choice.
|
225
|
+
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
227
|
+
be a consequence of the rest of this License.
|
228
|
+
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
231
|
+
original copyright holder who places the Program under this License
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
233
|
+
those countries, so that distribution is permitted only in or among
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
235
|
+
the limitation as if written in the body of this License.
|
236
|
+
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
238
|
+
of the General Public License from time to time. Such new versions will
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
240
|
+
address new problems or concerns.
|
241
|
+
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
243
|
+
specifies a version number of this License which applies to it and "any
|
244
|
+
later version", you have the option of following the terms and conditions
|
245
|
+
either of that version or of any later version published by the Free
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
248
|
+
Foundation.
|
249
|
+
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
251
|
+
programs whose distribution conditions are different, write to the author
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
256
|
+
of promoting the sharing and reuse of software generally.
|
257
|
+
|
258
|
+
NO WARRANTY
|
259
|
+
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268
|
+
REPAIR OR CORRECTION.
|
269
|
+
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 John Resig, http://jquery.com/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/src/base64.js
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
// This code was written by Tyler Akins and has been placed in the
|
2
|
+
// public domain. It would be nice if you left this header intact.
|
3
|
+
// Base64 code from Tyler Akins -- http://rumkin.com
|
4
|
+
|
5
|
+
var Base64 = (function () {
|
6
|
+
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
7
|
+
|
8
|
+
var obj = {
|
9
|
+
/**
|
10
|
+
* Encodes a string in base64
|
11
|
+
* @param {String} input The string to encode in base64.
|
12
|
+
*/
|
13
|
+
encode: function (input) {
|
14
|
+
var output = "";
|
15
|
+
var chr1, chr2, chr3;
|
16
|
+
var enc1, enc2, enc3, enc4;
|
17
|
+
var i = 0;
|
18
|
+
|
19
|
+
do {
|
20
|
+
chr1 = input.charCodeAt(i++);
|
21
|
+
chr2 = input.charCodeAt(i++);
|
22
|
+
chr3 = input.charCodeAt(i++);
|
23
|
+
|
24
|
+
enc1 = chr1 >> 2;
|
25
|
+
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
26
|
+
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
27
|
+
enc4 = chr3 & 63;
|
28
|
+
|
29
|
+
if (isNaN(chr2)) {
|
30
|
+
enc3 = enc4 = 64;
|
31
|
+
} else if (isNaN(chr3)) {
|
32
|
+
enc4 = 64;
|
33
|
+
}
|
34
|
+
|
35
|
+
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
|
36
|
+
keyStr.charAt(enc3) + keyStr.charAt(enc4);
|
37
|
+
} while (i < input.length);
|
38
|
+
|
39
|
+
return output;
|
40
|
+
},
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Decodes a base64 string.
|
44
|
+
* @param {String} input The string to decode.
|
45
|
+
*/
|
46
|
+
decode: function (input) {
|
47
|
+
var output = "";
|
48
|
+
var chr1, chr2, chr3;
|
49
|
+
var enc1, enc2, enc3, enc4;
|
50
|
+
var i = 0;
|
51
|
+
|
52
|
+
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
53
|
+
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
54
|
+
|
55
|
+
do {
|
56
|
+
enc1 = keyStr.indexOf(input.charAt(i++));
|
57
|
+
enc2 = keyStr.indexOf(input.charAt(i++));
|
58
|
+
enc3 = keyStr.indexOf(input.charAt(i++));
|
59
|
+
enc4 = keyStr.indexOf(input.charAt(i++));
|
60
|
+
|
61
|
+
chr1 = (enc1 << 2) | (enc2 >> 4);
|
62
|
+
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
63
|
+
chr3 = ((enc3 & 3) << 6) | enc4;
|
64
|
+
|
65
|
+
output = output + String.fromCharCode(chr1);
|
66
|
+
|
67
|
+
if (enc3 != 64) {
|
68
|
+
output = output + String.fromCharCode(chr2);
|
69
|
+
}
|
70
|
+
if (enc4 != 64) {
|
71
|
+
output = output + String.fromCharCode(chr3);
|
72
|
+
}
|
73
|
+
} while (i < input.length);
|
74
|
+
|
75
|
+
return output;
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
return obj;
|
80
|
+
})();
|
data/src/build.js
ADDED
data/src/cruft/bad.html
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<html lang="en" xml:lang='en'>
|
2
|
+
<head>
|
3
|
+
<title>Hello World</title>
|
4
|
+
<meta content="en-us"
|
5
|
+
http-equiv="Content-Language"/>
|
6
|
+
<meta content="text/html; charset=utf-8"
|
7
|
+
http-equiv="Content-Type"/>
|
8
|
+
<script type='text/javascript'>
|
9
|
+
document.write("<script>");
|
10
|
+
document.write("var foo = \'hello world\'");
|
11
|
+
document.write("</script>");
|
12
|
+
</script>
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<h1>hello world!</h1>
|
16
|
+
<div><!-- note div not closed properly -->
|
17
|
+
<ul>
|
18
|
+
<li>item 1</li>
|
19
|
+
<li>item 2</li>
|
20
|
+
<li>item 3 <a href='another/page.html'>link</a> to another page!</li>
|
21
|
+
</ul>
|
22
|
+
<div>
|
23
|
+
</body>
|
24
|
+
</html>
|
data/src/cruft/dom.js
ADDED
@@ -0,0 +1,606 @@
|
|
1
|
+
/*
|
2
|
+
* dom.js
|
3
|
+
*
|
4
|
+
* DOM Level 2 /DOM level 3 (partial)
|
5
|
+
*
|
6
|
+
* The DOMDocument is now private in scope but you can create new
|
7
|
+
* DOMDocuments via document.implementation.createDocument which
|
8
|
+
* now also exposes the DOM Level 3 function 'load(uri)'.
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
|
12
|
+
// Helper method for generating the right
|
13
|
+
// DOM objects based upon the type
|
14
|
+
/*var obj_nodes = {};
|
15
|
+
|
16
|
+
function makeNode(node){
|
17
|
+
$log("Making Node");
|
18
|
+
if ( node ) {
|
19
|
+
if ( !obj_nodes[node]){
|
20
|
+
obj_nodes[node] = node.getNodeType() == 1 ? new DOMElement( node ) :
|
21
|
+
(node.getNodeType() == 8 ? new DOMComment( node ) : new DOMNode( node )) ;
|
22
|
+
}
|
23
|
+
return obj_nodes[node];
|
24
|
+
} else
|
25
|
+
return null;
|
26
|
+
};*/
|
27
|
+
// Helper method for generating the right
|
28
|
+
// DOM objects based upon the type
|
29
|
+
|
30
|
+
var $nodeCache = {};//caches a reference to our implementation of the node
|
31
|
+
var $nodeImplCache = {};//reverse look-up : caches a reference to the env supplied implementors dom node
|
32
|
+
var $guid = (-1)*Math.pow(2,31);
|
33
|
+
function createGUID(){
|
34
|
+
return String(++$guid);
|
35
|
+
};
|
36
|
+
|
37
|
+
function makeNode(node){
|
38
|
+
if ( node ) {
|
39
|
+
if ( !$nodeCache[ $env.hashCode(node) ] ){
|
40
|
+
if( node.getNodeType() == 1){
|
41
|
+
$nodeCache[$env.hashCode(node)] = new DOMElement( node );
|
42
|
+
$nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
|
43
|
+
}else{
|
44
|
+
if(node.getNodeType() == 8){
|
45
|
+
$nodeCache[$env.hashCode(node)] = new DOMComment( node );
|
46
|
+
$nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
|
47
|
+
}else{
|
48
|
+
$nodeCache[$env.hashCode(node)] = new DOMNode( node );
|
49
|
+
$nodeImplCache[$nodeCache[$env.hashCode(node)].__guid__] = node;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return $nodeCache[$env.hashCode(node)];
|
54
|
+
} else{
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
//DOMImplementation
|
60
|
+
var DOMImplementation = function(){
|
61
|
+
return {
|
62
|
+
hasFeature: function(feature, version){
|
63
|
+
//TODO
|
64
|
+
return false;
|
65
|
+
},
|
66
|
+
createDocumentType: function(qname, publicId, systemId){
|
67
|
+
//TODO
|
68
|
+
},
|
69
|
+
createDocument:function(namespace, qname, docType){
|
70
|
+
return new DOMDocument();
|
71
|
+
},
|
72
|
+
getFeature:function(feature, version){
|
73
|
+
//TODO or TODONT?
|
74
|
+
}
|
75
|
+
};
|
76
|
+
};
|
77
|
+
|
78
|
+
// DOM Document
|
79
|
+
$w.__defineGetter__('DOMDocument', function(){
|
80
|
+
var $dom, $id, $url;
|
81
|
+
return function(){
|
82
|
+
$id = createGUID();
|
83
|
+
return __extend__(this,{
|
84
|
+
load: function(url){
|
85
|
+
$log("Loading url into DOM Document: "+ url + " - (Asynch? "+$w.document.async+")");
|
86
|
+
var _this = this;
|
87
|
+
var xhr = new XMLHttpRequest();
|
88
|
+
xhr.open("GET", url, $w.document.async);
|
89
|
+
xhr.onreadystatechange = function(){
|
90
|
+
try{
|
91
|
+
_this.loadXML(xhr.responseText);
|
92
|
+
}catch(e){
|
93
|
+
$error("Error Parsing XML - ",e);
|
94
|
+
_this.loadXML(
|
95
|
+
"<html><head></head><body>"+
|
96
|
+
"<h1>Parse Error</h1>"+
|
97
|
+
"<p>"+e.toString()+"</p>"+
|
98
|
+
"</body></html>");
|
99
|
+
}
|
100
|
+
$url = url;
|
101
|
+
if ( !$nodeCache[$dom] ){
|
102
|
+
$nodeCache[$dom] = _this;
|
103
|
+
}
|
104
|
+
$log("Sucessfully loaded document.");
|
105
|
+
var event = document.createEvent();
|
106
|
+
event.initEvent("load");
|
107
|
+
$w.dispatchEvent( event );
|
108
|
+
};
|
109
|
+
xhr.send();
|
110
|
+
},
|
111
|
+
//This is actuall IE specific but still convenient
|
112
|
+
loadXML: function(xmlString){
|
113
|
+
$dom = $env.parseXML(xmlString);
|
114
|
+
return this;
|
115
|
+
},
|
116
|
+
get nodeType(){
|
117
|
+
return 9;
|
118
|
+
},
|
119
|
+
createTextNode: function(text){
|
120
|
+
return makeNode( $dom.createTextNode(
|
121
|
+
text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) );
|
122
|
+
},
|
123
|
+
createElement: function(name){
|
124
|
+
return makeNode( $dom.createElement(name.toLowerCase()) );
|
125
|
+
},
|
126
|
+
getElementsByTagName: function(name){
|
127
|
+
return new DOMNodeList(
|
128
|
+
$dom.getElementsByTagName(
|
129
|
+
name.toLowerCase()) );
|
130
|
+
},
|
131
|
+
getElementsByName: function(name){
|
132
|
+
// why can't we just do ?:
|
133
|
+
//var elems = $dom.getElementsByTagName(name), ret = [];
|
134
|
+
var elems = $dom.getElementsByTagName("*"), ret = [];
|
135
|
+
ret.item = function(i){ return this[i]; };
|
136
|
+
ret.getLength = function(){ return this.length; };
|
137
|
+
for ( var i = 0; i < elems.length; i++ ) {
|
138
|
+
var elem = elems.item(i);
|
139
|
+
if ( elem.getAttribute("name") == name )
|
140
|
+
ret.push( elem );
|
141
|
+
}return new DOMNodeList( ret );
|
142
|
+
},
|
143
|
+
getElementById: function(id){
|
144
|
+
// why can't we just do ?:
|
145
|
+
//return makeNode($dom.getElementById(id));
|
146
|
+
var elems = $dom.getElementsByTagName("*");
|
147
|
+
|
148
|
+
for ( var i = 0; i < elems.length; i++ ) {
|
149
|
+
var elem = elems.item(i);
|
150
|
+
if ( elem.getAttribute("id") == id )
|
151
|
+
return makeNode(elem);
|
152
|
+
}
|
153
|
+
|
154
|
+
return null;
|
155
|
+
},
|
156
|
+
get body(){
|
157
|
+
return this.getElementsByTagName("body")[0];
|
158
|
+
},
|
159
|
+
get documentElement(){
|
160
|
+
return makeNode( $dom.getDocumentElement() );
|
161
|
+
},
|
162
|
+
get ownerDocument(){
|
163
|
+
return null;
|
164
|
+
},
|
165
|
+
addEventListener: window.addEventListener,
|
166
|
+
removeEventListener: window.removeEventListener,
|
167
|
+
dispatchEvent: window.dispatchEvent,
|
168
|
+
get nodeName() {
|
169
|
+
return "#document";
|
170
|
+
},
|
171
|
+
importNode: function(node, deep){
|
172
|
+
//need to replace this with some innerHtml magic
|
173
|
+
//because the ._dom is private in scope now
|
174
|
+
return makeNode( $dom.importNode($nodeImplCache[node.__guid__], deep) );
|
175
|
+
},
|
176
|
+
toString: function(){
|
177
|
+
return "Document" +
|
178
|
+
(typeof $url == "string" ? ": " + $url : "");
|
179
|
+
},
|
180
|
+
get innerHTML(){
|
181
|
+
return this.documentElement.outerHTML;
|
182
|
+
},
|
183
|
+
|
184
|
+
get defaultView(){
|
185
|
+
return {
|
186
|
+
getComputedStyle: function(elem){
|
187
|
+
return {
|
188
|
+
getPropertyValue: function(prop){
|
189
|
+
prop = prop.replace(/\-(\w)/g,function(m,c){
|
190
|
+
return c.toUpperCase();
|
191
|
+
});
|
192
|
+
var val = elem.style[prop];
|
193
|
+
if ( prop === "opacity" && val === "" ){
|
194
|
+
val = "1";
|
195
|
+
}return val;
|
196
|
+
}
|
197
|
+
};
|
198
|
+
}
|
199
|
+
};
|
200
|
+
},
|
201
|
+
|
202
|
+
createEvent: function(){
|
203
|
+
return {
|
204
|
+
type: "",
|
205
|
+
initEvent: function(type){
|
206
|
+
this.type = type;
|
207
|
+
}
|
208
|
+
};
|
209
|
+
},
|
210
|
+
get __guid__(){return $id;}
|
211
|
+
});
|
212
|
+
};
|
213
|
+
});
|
214
|
+
|
215
|
+
function getDocument(node){
|
216
|
+
return $nodeCache[node];
|
217
|
+
}
|
218
|
+
|
219
|
+
// DOM NodeList
|
220
|
+
|
221
|
+
$w.__defineGetter__("DOMNodeList", function(){
|
222
|
+
var $dom;
|
223
|
+
return function(list){
|
224
|
+
$dom = list;
|
225
|
+
this.length = list.getLength();
|
226
|
+
|
227
|
+
for ( var i = 0; i < this.length; i++ ) {
|
228
|
+
var node = list.item(i);
|
229
|
+
this[i] = makeNode( node );
|
230
|
+
}
|
231
|
+
return __extend__(this,{
|
232
|
+
toString: function(){
|
233
|
+
return "[ " +
|
234
|
+
Array.prototype.join.call( this, ", " ) + " ]";
|
235
|
+
},
|
236
|
+
get outerHTML(){
|
237
|
+
return Array.prototype.map.call(
|
238
|
+
this, function(node){return node.outerHTML;}).join('');
|
239
|
+
}
|
240
|
+
});
|
241
|
+
};
|
242
|
+
});
|
243
|
+
|
244
|
+
// DOM Node
|
245
|
+
|
246
|
+
$w.__defineGetter__("DOMNode", function(){
|
247
|
+
var $dom, $id;
|
248
|
+
return function(node){
|
249
|
+
$id = createGUID();
|
250
|
+
$dom = node;
|
251
|
+
return __extend__(this, {
|
252
|
+
get nodeType(){
|
253
|
+
return $dom.getNodeType();
|
254
|
+
},
|
255
|
+
get nodeValue(){
|
256
|
+
return $dom.getNodeValue();
|
257
|
+
},
|
258
|
+
get nodeName() {
|
259
|
+
return $dom.getNodeName();
|
260
|
+
},
|
261
|
+
get childNodes(){
|
262
|
+
return new DOMNodeList( $dom.getChildNodes() );
|
263
|
+
},
|
264
|
+
cloneNode: function(deep){
|
265
|
+
return makeNode( $dom.cloneNode(deep) );
|
266
|
+
},
|
267
|
+
get ownerDocument(){
|
268
|
+
return getDocument( $dom.ownerDocument );
|
269
|
+
},
|
270
|
+
get documentElement(){
|
271
|
+
return makeNode( $dom.documentElement );
|
272
|
+
},
|
273
|
+
get parentNode() {
|
274
|
+
return makeNode( $dom.getParentNode() );
|
275
|
+
},
|
276
|
+
get nextSibling() {
|
277
|
+
return makeNode( $dom.getNextSibling() );
|
278
|
+
},
|
279
|
+
get previousSibling() {
|
280
|
+
return makeNode( $dom.getPreviousSibling() );
|
281
|
+
},
|
282
|
+
toString: function(){
|
283
|
+
return '"' + this.nodeValue + '"';
|
284
|
+
},
|
285
|
+
get outerHTML(){
|
286
|
+
return this.nodeValue;
|
287
|
+
},
|
288
|
+
get __guid__(){return $id;}
|
289
|
+
});
|
290
|
+
};
|
291
|
+
});
|
292
|
+
|
293
|
+
// DOMComment
|
294
|
+
|
295
|
+
$w.__defineGetter__("DOMComment", function(){
|
296
|
+
$id = createGUID();
|
297
|
+
return function(node){
|
298
|
+
return __extend__(this, __extend__(new DOMNode(node),{
|
299
|
+
get nodeType(){
|
300
|
+
return 8;
|
301
|
+
},
|
302
|
+
get outerHTML(){
|
303
|
+
return "<!--" + this.nodeValue + "-->";
|
304
|
+
}
|
305
|
+
}));
|
306
|
+
};
|
307
|
+
});
|
308
|
+
|
309
|
+
// DOM Element
|
310
|
+
|
311
|
+
$w.__defineGetter__("DOMElement", function(){
|
312
|
+
var $dom, $id;
|
313
|
+
return function(elem){
|
314
|
+
$dom = elem;
|
315
|
+
$id = createGUID();
|
316
|
+
__extend__(this, new DOMNode($dom));
|
317
|
+
|
318
|
+
// A lot of the methods defined below belong in HTML specific
|
319
|
+
// subclasses. This is already unwieldy since most of these
|
320
|
+
//methods are meant for general xml consumption
|
321
|
+
__extend__(this, {
|
322
|
+
get nodeName(){
|
323
|
+
return this.tagName;
|
324
|
+
},
|
325
|
+
get tagName(){
|
326
|
+
return $dom.getTagName().toUpperCase();
|
327
|
+
},
|
328
|
+
toString: function(){
|
329
|
+
return "<" + this.tagName + (this.id ? "#" + this.id : "" ) + ">";
|
330
|
+
},
|
331
|
+
get outerHTML(){
|
332
|
+
var ret = "<" + this.tagName, attr = this.attributes;
|
333
|
+
|
334
|
+
for ( var i in attr )
|
335
|
+
ret += " " + i + "='" + attr[i] + "'";
|
336
|
+
|
337
|
+
if ( this.childNodes.length || this.nodeName == "SCRIPT" )
|
338
|
+
ret += ">" + this.childNodes.outerHTML +
|
339
|
+
"</" + this.tagName + ">";
|
340
|
+
else
|
341
|
+
ret += "/>";
|
342
|
+
|
343
|
+
return ret;
|
344
|
+
},
|
345
|
+
|
346
|
+
get attributes(){
|
347
|
+
var attr = {}, attrs = $dom.getAttributes();
|
348
|
+
for ( var i = 0; i < attrs.getLength(); i++ ){
|
349
|
+
attr[ attrs.item(i).nodeName ] = attrs.item(i).nodeValue;
|
350
|
+
}return attr;
|
351
|
+
},
|
352
|
+
|
353
|
+
get innerHTML(){
|
354
|
+
return this.childNodes.outerHTML;
|
355
|
+
},
|
356
|
+
set innerHTML(html){
|
357
|
+
html = html.replace(/<\/?([A-Z]+)/g, function(m){
|
358
|
+
return m.toLowerCase();
|
359
|
+
}).replace(/ /g, " ");
|
360
|
+
|
361
|
+
var dom = new DOMParser().parseFromString("<wrap>" + html + "</wrap>");
|
362
|
+
var nodes = this.ownerDocument.importNode( dom.documentElement, true ).childNodes;
|
363
|
+
|
364
|
+
while (this.firstChild){
|
365
|
+
this.removeChild( this.firstChild );
|
366
|
+
}
|
367
|
+
|
368
|
+
for ( var i = 0; i < nodes.length; i++ )
|
369
|
+
this.appendChild( nodes[i] );
|
370
|
+
},
|
371
|
+
|
372
|
+
get textContent(){
|
373
|
+
function nav(nodes){
|
374
|
+
var str = "";
|
375
|
+
for ( var i = 0; i < nodes.length; i++ ){
|
376
|
+
if ( nodes[i].nodeType == 3 ){
|
377
|
+
str += nodes[i].nodeValue;
|
378
|
+
}else if ( nodes[i].nodeType == 1 ){
|
379
|
+
str += nav(nodes[i].childNodes);
|
380
|
+
}
|
381
|
+
} return str;
|
382
|
+
} return nav(this.childNodes);
|
383
|
+
},
|
384
|
+
set textContent(text){
|
385
|
+
while (this.firstChild)
|
386
|
+
this.removeChild( this.firstChild );
|
387
|
+
this.appendChild( this.ownerDocument.createTextNode(text));
|
388
|
+
},
|
389
|
+
|
390
|
+
style: {},
|
391
|
+
clientHeight: 0,
|
392
|
+
clientWidth: 0,
|
393
|
+
offsetHeight: 0,
|
394
|
+
offsetWidth: 0,
|
395
|
+
|
396
|
+
get disabled() {
|
397
|
+
var val = this.getAttribute("disabled");
|
398
|
+
return val != "false" && !!val;
|
399
|
+
},
|
400
|
+
set disabled(val) { return this.setAttribute("disabled",val); },
|
401
|
+
|
402
|
+
get checked() {
|
403
|
+
var val = this.getAttribute("checked");
|
404
|
+
return val != "false" && !!val;
|
405
|
+
},
|
406
|
+
set checked(val) { return this.setAttribute("checked",val); },
|
407
|
+
|
408
|
+
get selected() {
|
409
|
+
if ( !this._selectDone ) {
|
410
|
+
this._selectDone = true;
|
411
|
+
|
412
|
+
if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) {
|
413
|
+
var opt = this.parentNode.getElementsByTagName("option");
|
414
|
+
|
415
|
+
if ( this == opt[0] ) {
|
416
|
+
var select = true;
|
417
|
+
|
418
|
+
for ( var i = 1; i < opt.length; i++ ){
|
419
|
+
if ( opt[i].selected ) {
|
420
|
+
select = false;
|
421
|
+
break;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
if ( select ){ this.selected = true; }
|
425
|
+
}
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
var val = this.getAttribute("selected");
|
430
|
+
return val != "false" && !!val;
|
431
|
+
},
|
432
|
+
set selected(val) { return this.setAttribute("selected",val); },
|
433
|
+
|
434
|
+
get className() { return this.getAttribute("class") || ""; },
|
435
|
+
set className(val) {
|
436
|
+
return this.setAttribute("class",
|
437
|
+
val.replace(/(^\s*|\s*$)/g,""));
|
438
|
+
},
|
439
|
+
|
440
|
+
get type() { return this.getAttribute("type") || ""; },
|
441
|
+
set type(val) { return this.setAttribute("type",val); },
|
442
|
+
|
443
|
+
get defaultValue() { return this.getAttribute("defaultValue") || ""; },
|
444
|
+
set defaultValue(val) { return this.setAttribute("defaultValue",val); },
|
445
|
+
|
446
|
+
get value() { return this.getAttribute("value") || ""; },
|
447
|
+
set value(val) { return this.setAttribute("value",val); },
|
448
|
+
|
449
|
+
get src() { return this.getAttribute("src") || ""; },
|
450
|
+
set src(val) { return this.setAttribute("src",val); },
|
451
|
+
|
452
|
+
get id() { return this.getAttribute("id") || ""; },
|
453
|
+
set id(val) { return this.setAttribute("id",val); },
|
454
|
+
|
455
|
+
getAttribute: function(name){
|
456
|
+
return $dom.hasAttribute(name) ?
|
457
|
+
new String( $dom.getAttribute(name) ) :
|
458
|
+
null;
|
459
|
+
},
|
460
|
+
setAttribute: function(name,value){
|
461
|
+
$dom.setAttribute(name,value);
|
462
|
+
},
|
463
|
+
removeAttribute: function(name){
|
464
|
+
$dom.removeAttribute(name);
|
465
|
+
},
|
466
|
+
|
467
|
+
get childNodes(){
|
468
|
+
return new DOMNodeList( $dom.getChildNodes() );
|
469
|
+
},
|
470
|
+
get firstChild(){
|
471
|
+
return makeNode( $dom.getFirstChild() );
|
472
|
+
},
|
473
|
+
get lastChild(){
|
474
|
+
return makeNode( $dom.getLastChild() );
|
475
|
+
},
|
476
|
+
appendChild: function(node){
|
477
|
+
//Because the dom implementation is private in scope now,
|
478
|
+
//we will need to fix these to use some innerHtml etc
|
479
|
+
//if required
|
480
|
+
$dom.appendChild( $nodeImplCache[node.__guid__] );
|
481
|
+
},
|
482
|
+
insertBefore: function(node,before){
|
483
|
+
$dom.insertBefore( $nodeImplCache[node.__guid__], before ? $nodeImplCache[before.__guid__] : before );
|
484
|
+
|
485
|
+
execScripts( node );
|
486
|
+
|
487
|
+
function execScripts( node ) {
|
488
|
+
if ( node.nodeName == "SCRIPT" ) {
|
489
|
+
if ( !node.getAttribute("src") ) {
|
490
|
+
eval.call( window, node.textContent );
|
491
|
+
}
|
492
|
+
} else {
|
493
|
+
var scripts = node.getElementsByTagName("script");
|
494
|
+
for ( var i = 0; i < scripts.length; i++ ) {
|
495
|
+
execScripts( node );
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
},
|
500
|
+
removeChild: function(node){
|
501
|
+
$dom.removeChild( $nodeImplCache[node.__guid__] );
|
502
|
+
},
|
503
|
+
|
504
|
+
getElementsByTagName: function(name){
|
505
|
+
// why can't we just do ?:
|
506
|
+
//var elems = $dom.getElementsByTagName(name), ret = [];
|
507
|
+
var elems = $dom.getElementsByTagName("*"), ret = [];
|
508
|
+
ret.item = function(i){ return this[i]; };
|
509
|
+
ret.getLength = function(){ return this.length; };
|
510
|
+
for ( var i = 0; i < elems.length; i++ ) {
|
511
|
+
var elem = elems.item(i);
|
512
|
+
if ( elem.getAttribute("name") == name )
|
513
|
+
ret.push( elem );
|
514
|
+
}return new DOMNodeList( ret );
|
515
|
+
},
|
516
|
+
|
517
|
+
addEventListener: window.addEventListener,
|
518
|
+
removeEventListener: window.removeEventListener,
|
519
|
+
dispatchEvent: window.dispatchEvent,
|
520
|
+
|
521
|
+
click: function(){
|
522
|
+
var event = document.createEvent();
|
523
|
+
event.initEvent("click");
|
524
|
+
this.dispatchEvent(event);
|
525
|
+
},
|
526
|
+
submit: function(){
|
527
|
+
var event = document.createEvent();
|
528
|
+
event.initEvent("submit");
|
529
|
+
this.dispatchEvent(event);
|
530
|
+
},
|
531
|
+
focus: function(){
|
532
|
+
var event = document.createEvent();
|
533
|
+
event.initEvent("focus");
|
534
|
+
this.dispatchEvent(event);
|
535
|
+
},
|
536
|
+
blur: function(){
|
537
|
+
var event = document.createEvent();
|
538
|
+
event.initEvent("blur");
|
539
|
+
this.dispatchEvent(event);
|
540
|
+
},
|
541
|
+
get contentWindow(){
|
542
|
+
return this.nodeName == "IFRAME" ? {
|
543
|
+
document: this.contentDocument
|
544
|
+
} : null;
|
545
|
+
},
|
546
|
+
get contentDocument(){
|
547
|
+
if ( this.nodeName == "IFRAME" ) {
|
548
|
+
if ( !this._doc )
|
549
|
+
this._doc = HTMLtoDOM("<html><head><title></title></head><body></body></html>");
|
550
|
+
return this._doc;
|
551
|
+
} else { return null; }
|
552
|
+
},
|
553
|
+
get __guid__(){return $id;}
|
554
|
+
});
|
555
|
+
|
556
|
+
//All this constructor stuff belond in the HTML subclasses
|
557
|
+
//and even more generally in the HTML specific element
|
558
|
+
//subclass otherwise its going to become a mess
|
559
|
+
this.style = {
|
560
|
+
get opacity(){ return this._opacity; },
|
561
|
+
set opacity(val){ this._opacity = val + ""; }
|
562
|
+
};
|
563
|
+
|
564
|
+
// Load CSS info
|
565
|
+
var styles = (this.getAttribute("style") || "").split(/\s*;\s*/);
|
566
|
+
for ( var i = 0; i < styles.length; i++ ) {
|
567
|
+
var style = styles[i].split(/\s*:\s*/);
|
568
|
+
if ( style.length == 2 )
|
569
|
+
this.style[ style[0] ] = style[1];
|
570
|
+
}
|
571
|
+
|
572
|
+
if ( this.nodeName == "FORM" ) {
|
573
|
+
this.__defineGetter__("elements", function(){
|
574
|
+
return this.getElementsByTagName("*");
|
575
|
+
});
|
576
|
+
this.__defineGetter__("length", function(){
|
577
|
+
var elems = this.elements;
|
578
|
+
for ( var i = 0; i < elems.length; i++ ) {
|
579
|
+
this[i] = elems[i];
|
580
|
+
}
|
581
|
+
return elems.length;
|
582
|
+
});
|
583
|
+
}
|
584
|
+
|
585
|
+
if ( this.nodeName == "SELECT" ) {
|
586
|
+
this.__defineGetter__("options", function(){
|
587
|
+
return this.getElementsByTagName("option");
|
588
|
+
});
|
589
|
+
}
|
590
|
+
|
591
|
+
this.defaultValue = this.value;
|
592
|
+
return this;
|
593
|
+
};
|
594
|
+
});
|
595
|
+
|
596
|
+
$w.__defineGetter__('DOMParser', function(){
|
597
|
+
return function(){
|
598
|
+
return __extend__(this, {
|
599
|
+
parseFromString: function(xmlString){
|
600
|
+
return document.implementation.createDocument().loadXML(xmlString);
|
601
|
+
}
|
602
|
+
});
|
603
|
+
};
|
604
|
+
});
|
605
|
+
|
606
|
+
|