smparkes-envjs 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/envjsrb +157 -73
- data/bin/jquery-1.3.2-test.js +11 -4
- data/lib/envjs/env.js +935 -11028
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +4 -4
- data/lib/envjs/runtime.rb +80 -24
- data/test/call-load-test.js +0 -2
- 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/html/malformed.html +1 -0
- data/test/index.html +21 -19
- data/test/{primaryTests.js → primary-tests.js} +1 -3
- data/test/{prototype.js → prototype-test.js} +0 -2
- data/test/qunit/qunit/qunit.css +0 -0
- data/test/qunit/qunit/qunit.js +2 -2
- data/test/{qunit/qunit/qunit.js.smp → specs/dist/env.spec.js} +539 -7
- 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/{qunit.smp/qunit → specs}/qunit.css +0 -0
- data/test/{qunit.smp/qunit → specs}/qunit.js +2 -2
- 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/elementmembers.js +31 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +1 -3
- data/test/unit/parser.js +106 -98
- data/test/unit/prototypecompat.js +2 -2
- data/test/vendor/jQuery/1.3.2/ChangeLog.txt +98 -0
- data/test/vendor/jQuery/1.3.2/GPL-LICENSE.txt +278 -0
- data/test/vendor/jQuery/1.3.2/MIT-LICENSE.txt +20 -0
- data/test/vendor/jQuery/1.3.2/Makefile +154 -0
- data/test/vendor/jQuery/1.3.2/README +67 -0
- data/test/vendor/jQuery/1.3.2/build/ant-contrib-0.6.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build/build/min.js +11 -0
- data/test/vendor/jQuery/1.3.2/build/build/pack.js +19 -0
- data/test/vendor/jQuery/1.3.2/build/js/Packer.js +209 -0
- data/test/vendor/jQuery/1.3.2/build/js/ParseMaster.js +106 -0
- data/test/vendor/jQuery/1.3.2/build/js/Words.js +62 -0
- data/test/vendor/jQuery/1.3.2/build/js/base2.js +978 -0
- data/test/vendor/jQuery/1.3.2/build/js/jsmin.js +316 -0
- data/test/vendor/jQuery/1.3.2/build/js/json.js +117 -0
- data/test/vendor/jQuery/1.3.2/build/js/pack.js +316 -0
- data/test/vendor/jQuery/1.3.2/build/js/parse.js +105 -0
- data/test/vendor/jQuery/1.3.2/build/js/writeFile.js +19 -0
- data/test/vendor/jQuery/1.3.2/build/js/xml.js +25 -0
- data/test/vendor/jQuery/1.3.2/build/js.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/env.js +1 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/test.js +106 -0
- data/test/vendor/jQuery/1.3.2/build/runtest/testrunner.js +197 -0
- data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.css +65 -0
- data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.js +181 -0
- data/test/vendor/jQuery/1.3.2/build/speed/index.html +72 -0
- data/test/vendor/jQuery/1.3.2/build/speed/jquery-basis.js +3549 -0
- data/test/vendor/jQuery/1.3.2/build/style.xsl +99 -0
- data/test/vendor/jQuery/1.3.2/build/yuicompressor-2.4.2.jar +0 -0
- data/test/vendor/jQuery/1.3.2/build.xml +123 -0
- data/test/vendor/jQuery/1.3.2/dist/jquery.js +4376 -0
- data/test/vendor/jQuery/1.3.2/reminder.txt +3 -0
- data/test/vendor/jQuery/1.3.2/src/ajax.js +541 -0
- data/test/vendor/jQuery/1.3.2/src/core.js +1255 -0
- data/test/vendor/jQuery/1.3.2/src/data.js +145 -0
- data/test/vendor/jQuery/1.3.2/src/dimensions.js +49 -0
- data/test/vendor/jQuery/1.3.2/src/event.js +684 -0
- data/test/vendor/jQuery/1.3.2/src/fx.js +407 -0
- data/test/vendor/jQuery/1.3.2/src/intro.js +13 -0
- data/test/vendor/jQuery/1.3.2/src/offset.js +155 -0
- data/test/vendor/jQuery/1.3.2/src/outro.js +1 -0
- data/test/vendor/jQuery/1.3.2/src/selector.js +1015 -0
- data/test/vendor/jQuery/1.3.2/src/support.js +112 -0
- data/test/vendor/jQuery/1.3.2/test/data/cow.jpg +0 -0
- data/test/vendor/jQuery/1.3.2/test/data/dashboard.xml +11 -0
- data/test/vendor/jQuery/1.3.2/test/data/echoQuery.php +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/iframe.html +8 -0
- data/test/vendor/jQuery/1.3.2/test/data/json.php +9 -0
- data/test/vendor/jQuery/1.3.2/test/data/json_assigned_obj.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/json_obj.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/jsonp.php +10 -0
- data/test/vendor/jQuery/1.3.2/test/data/name.html +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/name.php +29 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/absolute.html +39 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/body.html +24 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/fixed.html +33 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/relative.html +31 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/scroll.html +39 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/static.html +31 -0
- data/test/vendor/jQuery/1.3.2/test/data/offset/table.html +43 -0
- data/test/vendor/jQuery/1.3.2/test/data/params_html.php +12 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.html +7 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.js +3 -0
- data/test/vendor/jQuery/1.3.2/test/data/test.php +7 -0
- data/test/vendor/jQuery/1.3.2/test/data/test2.html +5 -0
- data/test/vendor/jQuery/1.3.2/test/data/test3.html +3 -0
- data/test/vendor/jQuery/1.3.2/test/data/testrunner.js +1 -0
- data/test/vendor/jQuery/1.3.2/test/data/text.php +12 -0
- data/test/vendor/jQuery/1.3.2/test/data/with_fries.xml +25 -0
- data/test/vendor/jQuery/1.3.2/test/index.html +229 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259090275493.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259091671501.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/jqenv-1259175319655.html +247 -0
- data/test/vendor/jQuery/1.3.2/test/offset.html +28 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.1/jquery.js +11 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.3/jquery.js +11 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/mootools/1.11/mootools.js +1577 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/prototype/1.6.0.2/prototype.js +4221 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/builder.js +131 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/controls.js +835 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/dragdrop.js +944 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/effects.js +1090 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/scriptaculous.js +51 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/slider.js +278 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/unittest.js +564 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/builder.js +136 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/controls.js +965 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/dragdrop.js +974 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/effects.js +1122 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/scriptaculous.js +58 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/slider.js +275 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/sound.js +55 -0
- data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/unittest.js +568 -0
- data/test/vendor/jQuery/1.3.2/test/polluted.php +64 -0
- data/test/vendor/jQuery/1.3.2/test/qunit/testrunner.js +780 -0
- data/test/vendor/jQuery/1.3.2/test/qunit/testsuite.css +120 -0
- data/test/vendor/jQuery/1.3.2/test/test.js +41 -0
- data/test/vendor/jQuery/1.3.2/test/unit/ajax.js +856 -0
- data/test/vendor/jQuery/1.3.2/test/unit/core.js +1872 -0
- data/test/vendor/jQuery/1.3.2/test/unit/data.js +160 -0
- data/test/vendor/jQuery/1.3.2/test/unit/dimensions.js +86 -0
- data/test/vendor/jQuery/1.3.2/test/unit/event.js +670 -0
- data/test/vendor/jQuery/1.3.2/test/unit/fx.js +451 -0
- data/test/vendor/jQuery/1.3.2/test/unit/offset.js +173 -0
- data/test/vendor/jQuery/1.3.2/test/unit/selector.js +395 -0
- data/test/vendor/jQuery/1.3.2/test/xhtml.php +5 -0
- data/test/vendor/jQuery/1.3.2/version.txt +1 -0
- metadata +158 -22
- data/lib/envjs/runtime.rb.smp +0 -133
- data/test/envjs-call-load-test.js +0 -5
- data/test/envjs-prototype.js +0 -5
- data/test/qunit/package.json +0 -21
- data/test/qunit/test/index.html +0 -17
- data/test/qunit/test/same.js +0 -1368
- data/test/qunit/test/test.js +0 -136
- data/test/qunit.smp/package.json +0 -21
- data/test/qunit.smp/test/index.html +0 -17
- data/test/qunit.smp/test/same.js +0 -1368
- data/test/qunit.smp/test/test.js +0 -136
- data/test/rhino-call-load-test.js +0 -5
- data/test/rhino-prototype.js +0 -5
- data/test/test-with-envs-jar.js +0 -8
- data/test/test-with-rhino-jar.js +0 -9
@@ -0,0 +1,316 @@
|
|
1
|
+
/* jsmin.js - 2006-08-31
|
2
|
+
Author: Franck Marcia
|
3
|
+
This work is an adaptation of jsminc.c published by Douglas Crockford.
|
4
|
+
Permission is hereby granted to use the Javascript version under the same
|
5
|
+
conditions as the jsmin.c on which it is based.
|
6
|
+
|
7
|
+
jsmin.c
|
8
|
+
2006-05-04
|
9
|
+
|
10
|
+
Copyright (c) 2002 Douglas Crockford (www.crockford.com)
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
13
|
+
this software and associated documentation files (the "Software"), to deal in
|
14
|
+
the Software without restriction, including without limitation the rights to
|
15
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
16
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
17
|
+
so, subject to the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
20
|
+
copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
The Software shall be used for Good, not Evil.
|
23
|
+
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
30
|
+
SOFTWARE.
|
31
|
+
|
32
|
+
Update:
|
33
|
+
add level:
|
34
|
+
1: minimal, keep linefeeds if single
|
35
|
+
2: normal, the standard algorithm
|
36
|
+
3: agressive, remove any linefeed and doesn't take care of potential
|
37
|
+
missing semicolons (can be regressive)
|
38
|
+
store stats
|
39
|
+
jsmin.oldSize
|
40
|
+
jsmin.newSize
|
41
|
+
*/
|
42
|
+
|
43
|
+
String.prototype.has = function(c) {
|
44
|
+
return this.indexOf(c) > -1;
|
45
|
+
};
|
46
|
+
|
47
|
+
function jsmin(comment, input, level) {
|
48
|
+
|
49
|
+
if (input === undefined) {
|
50
|
+
input = comment;
|
51
|
+
comment = '';
|
52
|
+
level = 2;
|
53
|
+
} else if (level === undefined || level < 1 || level > 3) {
|
54
|
+
level = 2;
|
55
|
+
}
|
56
|
+
|
57
|
+
if (comment.length > 0) {
|
58
|
+
comment += '\n';
|
59
|
+
}
|
60
|
+
|
61
|
+
var a = '',
|
62
|
+
b = '',
|
63
|
+
EOF = -1,
|
64
|
+
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
|
65
|
+
DIGITS = '0123456789',
|
66
|
+
ALNUM = LETTERS + DIGITS + '_$\\',
|
67
|
+
theLookahead = EOF;
|
68
|
+
|
69
|
+
|
70
|
+
/* isAlphanum -- return true if the character is a letter, digit, underscore,
|
71
|
+
dollar sign, or non-ASCII character.
|
72
|
+
*/
|
73
|
+
|
74
|
+
function isAlphanum(c) {
|
75
|
+
return c != EOF && (ALNUM.has(c) || c.charCodeAt(0) > 126);
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
/* get -- return the next character. Watch out for lookahead. If the
|
80
|
+
character is a control character, translate it to a space or
|
81
|
+
linefeed.
|
82
|
+
*/
|
83
|
+
|
84
|
+
function get() {
|
85
|
+
|
86
|
+
var c = theLookahead;
|
87
|
+
if (get.i == get.l) {
|
88
|
+
return EOF;
|
89
|
+
}
|
90
|
+
theLookahead = EOF;
|
91
|
+
if (c == EOF) {
|
92
|
+
c = input.charAt(get.i);
|
93
|
+
++get.i;
|
94
|
+
}
|
95
|
+
if (c >= ' ' || c == '\n') {
|
96
|
+
return c;
|
97
|
+
}
|
98
|
+
if (c == '\r') {
|
99
|
+
return '\n';
|
100
|
+
}
|
101
|
+
return ' ';
|
102
|
+
}
|
103
|
+
|
104
|
+
get.i = 0;
|
105
|
+
get.l = input.length;
|
106
|
+
|
107
|
+
|
108
|
+
/* peek -- get the next character without getting it.
|
109
|
+
*/
|
110
|
+
|
111
|
+
function peek() {
|
112
|
+
theLookahead = get();
|
113
|
+
return theLookahead;
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
/* next -- get the next character, excluding comments. peek() is used to see
|
118
|
+
if a '/' is followed by a '/' or '*'.
|
119
|
+
*/
|
120
|
+
|
121
|
+
function next() {
|
122
|
+
|
123
|
+
var c = get();
|
124
|
+
if (c == '/') {
|
125
|
+
switch (peek()) {
|
126
|
+
case '/':
|
127
|
+
for (;;) {
|
128
|
+
c = get();
|
129
|
+
if (c <= '\n') {
|
130
|
+
return c;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
break;
|
134
|
+
case '*':
|
135
|
+
get();
|
136
|
+
for (;;) {
|
137
|
+
switch (get()) {
|
138
|
+
case '*':
|
139
|
+
if (peek() == '/') {
|
140
|
+
get();
|
141
|
+
return ' ';
|
142
|
+
}
|
143
|
+
break;
|
144
|
+
case EOF:
|
145
|
+
throw 'Error: Unterminated comment.';
|
146
|
+
}
|
147
|
+
}
|
148
|
+
break;
|
149
|
+
default:
|
150
|
+
return c;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
return c;
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
/* action -- do something! What you do is determined by the argument:
|
158
|
+
1 Output A. Copy B to A. Get the next B.
|
159
|
+
2 Copy B to A. Get the next B. (Delete A).
|
160
|
+
3 Get the next B. (Delete B).
|
161
|
+
action treats a string as a single character. Wow!
|
162
|
+
action recognizes a regular expression if it is preceded by ( or , or =.
|
163
|
+
*/
|
164
|
+
|
165
|
+
function action(d) {
|
166
|
+
|
167
|
+
var r = [];
|
168
|
+
|
169
|
+
if (d == 1) {
|
170
|
+
r.push(a);
|
171
|
+
}
|
172
|
+
|
173
|
+
if (d < 3) {
|
174
|
+
a = b;
|
175
|
+
if (a == '\'' || a == '"') {
|
176
|
+
for (;;) {
|
177
|
+
r.push(a);
|
178
|
+
a = get();
|
179
|
+
if (a == b) {
|
180
|
+
break;
|
181
|
+
}
|
182
|
+
if (a <= '\n') {
|
183
|
+
throw 'Error: unterminated string literal: ' + a;
|
184
|
+
}
|
185
|
+
if (a == '\\') {
|
186
|
+
r.push(a);
|
187
|
+
a = get();
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
b = next();
|
194
|
+
|
195
|
+
if (b == '/' && '(,=:[!&|'.has(a)) {
|
196
|
+
r.push(a);
|
197
|
+
r.push(b);
|
198
|
+
for (;;) {
|
199
|
+
a = get();
|
200
|
+
if (a == '/') {
|
201
|
+
break;
|
202
|
+
} else if (a =='\\') {
|
203
|
+
r.push(a);
|
204
|
+
a = get();
|
205
|
+
} else if (a <= '\n') {
|
206
|
+
throw 'Error: unterminated Regular Expression literal';
|
207
|
+
}
|
208
|
+
r.push(a);
|
209
|
+
}
|
210
|
+
b = next();
|
211
|
+
}
|
212
|
+
|
213
|
+
return r.join('');
|
214
|
+
}
|
215
|
+
|
216
|
+
|
217
|
+
/* m -- Copy the input to the output, deleting the characters which are
|
218
|
+
insignificant to JavaScript. Comments will be removed. Tabs will be
|
219
|
+
replaced with spaces. Carriage returns will be replaced with
|
220
|
+
linefeeds.
|
221
|
+
Most spaces and linefeeds will be removed.
|
222
|
+
*/
|
223
|
+
|
224
|
+
function m() {
|
225
|
+
|
226
|
+
var r = [];
|
227
|
+
a = '\n';
|
228
|
+
|
229
|
+
r.push(action(3));
|
230
|
+
|
231
|
+
while (a != EOF) {
|
232
|
+
switch (a) {
|
233
|
+
case ' ':
|
234
|
+
if (isAlphanum(b)) {
|
235
|
+
r.push(action(1));
|
236
|
+
} else {
|
237
|
+
r.push(action(2));
|
238
|
+
}
|
239
|
+
break;
|
240
|
+
case '\n':
|
241
|
+
switch (b) {
|
242
|
+
case '{':
|
243
|
+
case '[':
|
244
|
+
case '(':
|
245
|
+
case '+':
|
246
|
+
case '-':
|
247
|
+
r.push(action(1));
|
248
|
+
break;
|
249
|
+
case ' ':
|
250
|
+
r.push(action(3));
|
251
|
+
break;
|
252
|
+
default:
|
253
|
+
if (isAlphanum(b)) {
|
254
|
+
r.push(action(1));
|
255
|
+
} else {
|
256
|
+
if (level == 1 && b != '\n') {
|
257
|
+
r.push(action(1));
|
258
|
+
} else {
|
259
|
+
r.push(action(2));
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
break;
|
264
|
+
default:
|
265
|
+
switch (b) {
|
266
|
+
case ' ':
|
267
|
+
if (isAlphanum(a)) {
|
268
|
+
r.push(action(1));
|
269
|
+
break;
|
270
|
+
}
|
271
|
+
r.push(action(3));
|
272
|
+
break;
|
273
|
+
case '\n':
|
274
|
+
if (level == 1 && a != '\n') {
|
275
|
+
r.push(action(1));
|
276
|
+
} else {
|
277
|
+
switch (a) {
|
278
|
+
case '}':
|
279
|
+
case ']':
|
280
|
+
case ')':
|
281
|
+
case '+':
|
282
|
+
case '-':
|
283
|
+
case '"':
|
284
|
+
case '\'':
|
285
|
+
if (level == 3) {
|
286
|
+
r.push(action(3));
|
287
|
+
} else {
|
288
|
+
r.push(action(1));
|
289
|
+
}
|
290
|
+
break;
|
291
|
+
default:
|
292
|
+
if (isAlphanum(a)) {
|
293
|
+
r.push(action(1));
|
294
|
+
} else {
|
295
|
+
r.push(action(3));
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
break;
|
300
|
+
default:
|
301
|
+
r.push(action(1));
|
302
|
+
break;
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
return r.join('');
|
308
|
+
}
|
309
|
+
|
310
|
+
jsmin.oldSize = input.length;
|
311
|
+
var r = m(input);
|
312
|
+
jsmin.newSize = r.length;
|
313
|
+
|
314
|
+
return comment + r;
|
315
|
+
|
316
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/*
|
2
|
+
json.js
|
3
|
+
2006-04-28
|
4
|
+
|
5
|
+
This file adds these methods to JavaScript:
|
6
|
+
|
7
|
+
object.toJSONString()
|
8
|
+
|
9
|
+
This method produces a JSON text from an object. The
|
10
|
+
object must not contain any cyclical references.
|
11
|
+
|
12
|
+
array.toJSONString()
|
13
|
+
|
14
|
+
This method produces a JSON text from an array. The
|
15
|
+
array must not contain any cyclical references.
|
16
|
+
|
17
|
+
string.parseJSON()
|
18
|
+
|
19
|
+
This method parses a JSON text to produce an object or
|
20
|
+
array. It will return false if there is an error.
|
21
|
+
*/
|
22
|
+
(function () {
|
23
|
+
var m = {
|
24
|
+
'\b': '\\b',
|
25
|
+
'\t': '\\t',
|
26
|
+
'\n': '\\n',
|
27
|
+
'\f': '\\f',
|
28
|
+
'\r': '\\r',
|
29
|
+
'"' : '\\"',
|
30
|
+
'\\': '\\\\'
|
31
|
+
},
|
32
|
+
s = {
|
33
|
+
array: function (x) {
|
34
|
+
var a = ['['], b, f, i, l = x.length, v;
|
35
|
+
for (i = 0; i < l; i += 1) {
|
36
|
+
v = x[i];
|
37
|
+
f = s[typeof v];
|
38
|
+
if (f) {
|
39
|
+
v = f(v);
|
40
|
+
if (typeof v == 'string') {
|
41
|
+
if (b) {
|
42
|
+
a[a.length] = ',';
|
43
|
+
}
|
44
|
+
a[a.length] = v;
|
45
|
+
b = true;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
a[a.length] = ']';
|
50
|
+
return a.join('');
|
51
|
+
},
|
52
|
+
'boolean': function (x) {
|
53
|
+
return String(x);
|
54
|
+
},
|
55
|
+
'null': function (x) {
|
56
|
+
return "null";
|
57
|
+
},
|
58
|
+
number: function (x) {
|
59
|
+
return isFinite(x) ? String(x) : 'null';
|
60
|
+
},
|
61
|
+
object: function (x) {
|
62
|
+
if (x) {
|
63
|
+
if (x instanceof Array) {
|
64
|
+
return s.array(x);
|
65
|
+
}
|
66
|
+
var a = ['{'], b, f, i, v;
|
67
|
+
for (i in x) {
|
68
|
+
v = x[i];
|
69
|
+
f = s[typeof v];
|
70
|
+
if (f) {
|
71
|
+
v = f(v);
|
72
|
+
if (typeof v == 'string') {
|
73
|
+
if (b) {
|
74
|
+
a[a.length] = ',';
|
75
|
+
}
|
76
|
+
a.push(s.string(i), ':', v);
|
77
|
+
b = true;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
a[a.length] = '}';
|
82
|
+
return a.join('');
|
83
|
+
}
|
84
|
+
return 'null';
|
85
|
+
},
|
86
|
+
string: function (x) {
|
87
|
+
if (/["\\\x00-\x1f]/.test(x)) {
|
88
|
+
x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
|
89
|
+
var c = m[b];
|
90
|
+
if (c) {
|
91
|
+
return c;
|
92
|
+
}
|
93
|
+
c = b.charCodeAt();
|
94
|
+
return '\\u00' +
|
95
|
+
Math.floor(c / 16).toString(16) +
|
96
|
+
(c % 16).toString(16);
|
97
|
+
});
|
98
|
+
}
|
99
|
+
return '"' + x + '"';
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
Object.toJSON = function(obj) {
|
104
|
+
return s.object(obj);
|
105
|
+
};
|
106
|
+
})();
|
107
|
+
|
108
|
+
String.prototype.parseJSON = function () {
|
109
|
+
try {
|
110
|
+
return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
|
111
|
+
this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
|
112
|
+
eval('(' + this + ')');
|
113
|
+
} catch (e) {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|