envjs 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.jslintrbrc +29 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +3 -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 +287 -0
  14. data/{README → README.rdoc} +24 -3
  15. data/Rakefile +196 -0
  16. data/Wakefile +24 -0
  17. data/build.properties +9 -0
  18. data/build.xml +247 -0
  19. data/gm/jquery.js +6002 -0
  20. data/gm/mainx.js +2648 -0
  21. data/gm/sensx.js +135 -0
  22. data/gm/t.js +6 -0
  23. data/gm/x.html +76 -0
  24. data/htmlparser/BrowserTreeBuilder.java +456 -0
  25. data/htmlparser/README +34 -0
  26. data/htmlparser/build.sh +38 -0
  27. data/jsl/jsl +0 -0
  28. data/jsl/jsl.default.conf +129 -0
  29. data/jsl/jsl.exe +0 -0
  30. data/lib/envjs.rb +2 -0
  31. data/lib/envjs/env.js +22 -3
  32. data/lib/envjs/event_loop.js +2 -0
  33. data/lib/envjs/static.js +155 -21
  34. data/licenses/GPL-LICENSE.txt +278 -0
  35. data/licenses/MIT-LICENSE.txt +20 -0
  36. data/src/base64.js +80 -0
  37. data/src/build.js +6 -0
  38. data/src/cruft/bad.html +24 -0
  39. data/src/cruft/dom.js +606 -0
  40. data/src/cruft/element.js +297 -0
  41. data/src/cruft/good.html +30 -0
  42. data/src/cruft/good.js +32 -0
  43. data/src/cruft/internal.js +81 -0
  44. data/src/cruft/parser.js +458 -0
  45. data/src/css/properties.js +293 -0
  46. data/src/css/rule.js +22 -0
  47. data/src/css/sizzle.js +717 -0
  48. data/src/css/stylesheet.js +52 -0
  49. data/src/dom/attr.js +55 -0
  50. data/src/dom/cdatasection.js +31 -0
  51. data/src/dom/characterdata.js +119 -0
  52. data/src/dom/comment.js +30 -0
  53. data/src/dom/doctype.js +9 -0
  54. data/src/dom/document.js +553 -0
  55. data/src/dom/dom.js +134 -0
  56. data/src/dom/element.js +217 -0
  57. data/src/dom/entities.js +273 -0
  58. data/src/dom/exception.js +28 -0
  59. data/src/dom/fragment.js +37 -0
  60. data/src/dom/implementation.js +602 -0
  61. data/src/dom/instruction.js +51 -0
  62. data/src/dom/namednodemap.js +374 -0
  63. data/src/dom/namespace.js +50 -0
  64. data/src/dom/node.js +618 -0
  65. data/src/dom/nodelist.js +195 -0
  66. data/src/dom/parser.js +1207 -0
  67. data/src/dom/text.js +73 -0
  68. data/src/event/event.js +39 -0
  69. data/src/event/mouseevent.js +4 -0
  70. data/src/event/uievent.js +8 -0
  71. data/src/html/a.js +110 -0
  72. data/src/html/anchor.js +80 -0
  73. data/src/html/area.js +57 -0
  74. data/src/html/base.js +26 -0
  75. data/src/html/blockquote-q.js +19 -0
  76. data/src/html/body.js +19 -0
  77. data/src/html/button.js +21 -0
  78. data/src/html/canvas.js +14 -0
  79. data/src/html/col-colgroup.js +49 -0
  80. data/src/html/collection.js +72 -0
  81. data/src/html/cookie.js +151 -0
  82. data/src/html/del-ins.js +25 -0
  83. data/src/html/div.js +28 -0
  84. data/src/html/document.js +359 -0
  85. data/src/html/element.js +380 -0
  86. data/src/html/fieldset.js +19 -0
  87. data/src/html/form.js +484 -0
  88. data/src/html/frame.js +89 -0
  89. data/src/html/frameset.js +25 -0
  90. data/src/html/head.js +44 -0
  91. data/src/html/html.js +0 -0
  92. data/src/html/htmlparser.js +340 -0
  93. data/src/html/iframe.js +26 -0
  94. data/src/html/image.js +0 -0
  95. data/src/html/img.js +62 -0
  96. data/src/html/input-elements.js +307 -0
  97. data/src/html/input.js +65 -0
  98. data/src/html/label.js +26 -0
  99. data/src/html/legend.js +19 -0
  100. data/src/html/link.js +82 -0
  101. data/src/html/map.js +22 -0
  102. data/src/html/meta.js +37 -0
  103. data/src/html/object.js +89 -0
  104. data/src/html/optgroup.js +25 -0
  105. data/src/html/option.js +97 -0
  106. data/src/html/param.js +38 -0
  107. data/src/html/script.js +122 -0
  108. data/src/html/select.js +129 -0
  109. data/src/html/style.js +31 -0
  110. data/src/html/table.js +199 -0
  111. data/src/html/tbody-thead-tfoot.js +91 -0
  112. data/src/html/td-th.js +18 -0
  113. data/src/html/textarea.js +25 -0
  114. data/src/html/title.js +20 -0
  115. data/src/html/tr.js +114 -0
  116. data/src/intro.js +141 -0
  117. data/src/outro.js +70 -0
  118. data/src/parser/html5.detailed.js +10762 -0
  119. data/src/parser/html5.min.js +503 -0
  120. data/src/parser/html5.pretty.js +10815 -0
  121. data/src/parser/intro.js +42 -0
  122. data/src/parser/outro.js +9 -0
  123. data/src/platform/core.js +323 -0
  124. data/src/platform/johnson.js +479 -0
  125. data/src/platform/rhino.js +327 -0
  126. data/src/platform/static/intro.js +41 -0
  127. data/src/platform/static/outro.js +30 -0
  128. data/src/profile/aop.js +238 -0
  129. data/src/profile/profile.js +402 -0
  130. data/src/serializer/xml.js +21 -0
  131. data/src/svg/animatedstring.js +25 -0
  132. data/src/svg/document.js +25 -0
  133. data/src/svg/element.js +22 -0
  134. data/src/svg/locatable.js +17 -0
  135. data/src/svg/rect.js +18 -0
  136. data/src/svg/rectelement.js +24 -0
  137. data/src/svg/stylable.js +49 -0
  138. data/src/svg/svgelement.js +22 -0
  139. data/src/svg/transformable.js +15 -0
  140. data/src/window/css.js +15 -0
  141. data/src/window/dialog.js +16 -0
  142. data/src/window/document.js +28 -0
  143. data/src/window/event.js +262 -0
  144. data/src/window/history.js +62 -0
  145. data/src/window/location.js +138 -0
  146. data/src/window/navigator.js +48 -0
  147. data/src/window/screen.js +53 -0
  148. data/src/window/timer.js +21 -0
  149. data/src/window/window.js +284 -0
  150. data/src/window/xhr.js +127 -0
  151. data/src/xpath/expression.js +49 -0
  152. data/src/xpath/implementation.js +2482 -0
  153. data/src/xpath/result.js +67 -0
  154. data/src/xpath/util.js +551 -0
  155. data/src/xpath/xmltoken.js +149 -0
  156. data/src/xslt/COPYING +34 -0
  157. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  158. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  159. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  160. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  161. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  162. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  163. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  164. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  165. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  166. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  167. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  168. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  169. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  170. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  171. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  172. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  173. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  174. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  175. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  176. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  177. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  178. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  179. data/src/xslt/implementation.js +625 -0
  180. data/src/xslt/processor.js +37 -0
  181. data/src/xslt/util.js +449 -0
  182. data/test/foo.html +8 -0
  183. data/test/foo.js +40 -0
  184. data/test/jquery.js +6002 -0
  185. data/test/x.js +1 -0
  186. data/test/y.js +1 -0
  187. metadata +245 -14
@@ -0,0 +1,327 @@
1
+ /*
2
+ * env.rhino.js
3
+ */
4
+ (function($env){
5
+
6
+ $env.log = function(msg, level){
7
+ print(' '+ (level?level:'LOG') + ':\t['+ new Date()+"] {ENVJS} "+msg);
8
+ };
9
+
10
+ $env.lineSource = function(e){
11
+ return e&&e.rhinoException?e.rhinoException.lineSource():"(line ?)";
12
+ };
13
+
14
+ $env.sync = sync;
15
+ $env.sleep = function(t){
16
+ java.lang.Thread.currentThread().sleep(sleep);
17
+ }
18
+
19
+ //For Java the window.location object is a java.net.URL
20
+ $env.location = function(path, base){
21
+ var protocol = new RegExp('(^file\:|^http\:|^https\:)');
22
+ var m = protocol.exec(path);
23
+ if(m&&m.length>1){
24
+ return new java.net.URL(path).toString()+'';
25
+ }else if(base){
26
+ return new java.net.URL(new java.net.URL(base), path).toString()+'';
27
+ }else{
28
+ //return an absolute url from a url relative to the window location
29
+ base = window.location.href.substring(0, window.location.href.lastIndexOf('/'));
30
+ if(window.location.href.length > 0){
31
+ return base + '/' + path;
32
+ }else{
33
+ return new java.io.File( path ).toURL().toString()+'';
34
+ }
35
+ }
36
+ };
37
+
38
+ //Since we're running in rhino I guess we can safely assume
39
+ //java is 'enabled'. I'm sure this requires more thought
40
+ //than I've given it here
41
+ $env.javaEnabled = true;
42
+
43
+
44
+ //Used in the XMLHttpRquest implementation to run a
45
+ // request in a seperate thread
46
+ $env.onInterrupt = function(){};
47
+ $env.runAsync = function(fn){
48
+ $env.debug("running async");
49
+ var running = true;
50
+
51
+ var run = sync(function(){ //while happening only thing in this timer
52
+ //$env.debug("running timed function");
53
+ fn();
54
+ });
55
+
56
+ try{
57
+ spawn(run);
58
+ }catch(e){
59
+ $env.error("error while running async", e);
60
+ $env.onInterrupt();
61
+ }
62
+ };
63
+
64
+ //Used to write to a local file
65
+ $env.writeToFile = function(text, url){
66
+ $env.debug("writing text to url : " + url);
67
+ var out = new java.io.FileWriter(
68
+ new java.io.File(
69
+ new java.net.URI(url.toString())));
70
+ out.write( text, 0, text.length );
71
+ out.flush();
72
+ out.close();
73
+ };
74
+
75
+ //Used to write to a local file
76
+ $env.writeToTempFile = function(text, suffix){
77
+ $env.debug("writing text to temp url : " + suffix);
78
+ // Create temp file.
79
+ var temp = java.io.File.createTempFile("envjs-tmp", suffix);
80
+
81
+ // Delete temp file when program exits.
82
+ temp.deleteOnExit();
83
+
84
+ // Write to temp file
85
+ var out = new java.io.FileWriter(temp);
86
+ out.write(text, 0, text.length);
87
+ out.close();
88
+ return temp.getAbsolutePath().toString()+'';
89
+ };
90
+
91
+ //Used to delete a local file
92
+ $env.deleteFile = function(url){
93
+ var file = new java.io.File( new java.net.URI( url ) );
94
+ file["delete"]();
95
+ };
96
+
97
+ $env.connection = function(xhr, responseHandler, data){
98
+ var url = java.net.URL(xhr.url);//, $w.location);
99
+ var connection;
100
+ if ( /^file\:/.test(url) ) {
101
+ try{
102
+ if ( xhr.method == "PUT" ) {
103
+ var text = data || "" ;
104
+ $env.writeToFile(text, url);
105
+ } else if ( xhr.method == "DELETE" ) {
106
+ $env.deleteFile(url);
107
+ } else {
108
+ connection = url.openConnection();
109
+ connection.connect();
110
+ //try to add some canned headers that make sense
111
+
112
+ try{
113
+ if(xhr.url.match(/html$/)){
114
+ xhr.responseHeaders["Content-Type"] = 'text/html';
115
+ }else if(xhr.url.match(/.xml$/)){
116
+ xhr.responseHeaders["Content-Type"] = 'text/xml';
117
+ }else if(xhr.url.match(/.js$/)){
118
+ xhr.responseHeaders["Content-Type"] = 'text/javascript';
119
+ }else if(xhr.url.match(/.json$/)){
120
+ xhr.responseHeaders["Content-Type"] = 'application/json';
121
+ }else{
122
+ xhr.responseHeaders["Content-Type"] = 'text/plain';
123
+ }
124
+ //xhr.responseHeaders['Last-Modified'] = connection.getLastModified();
125
+ //xhr.responseHeaders['Content-Length'] = headerValue+'';
126
+ //xhr.responseHeaders['Date'] = new Date()+'';*/
127
+ }catch(e){
128
+ $env.error('failed to load response headers',e);
129
+ }
130
+
131
+ }
132
+ }catch(e){
133
+ $env.error('failed to open file '+ url, e);
134
+ connection = null;
135
+ xhr.readyState = 4;
136
+ xhr.statusText = "Local File Protocol Error";
137
+ xhr.responseText = "<html><head/><body><p>"+ e+ "</p></body></html>";
138
+ }
139
+ } else {
140
+ connection = url.openConnection();
141
+ connection.setRequestMethod( xhr.method );
142
+
143
+ // Add headers to Java connection
144
+ for (var header in xhr.headers){
145
+ connection.addRequestProperty(header+'', xhr.headers[header]+'');
146
+ }
147
+
148
+ //write data to output stream if required
149
+ if(data&&data.length&&data.length>0){
150
+ if ( xhr.method == "PUT" || xhr.method == "POST" ) {
151
+ connection.setDoOutput(true);
152
+ var outstream = connection.getOutputStream(),
153
+ outbuffer = new java.lang.String(data).getBytes('UTF-8');
154
+
155
+ outstream.write(outbuffer, 0, outbuffer.length);
156
+ outstream.close();
157
+ }
158
+ }else{
159
+ connection.connect();
160
+ }
161
+
162
+
163
+ }
164
+ if(connection){
165
+ try{
166
+ var respheadlength = connection.getHeaderFields().size();
167
+ // Stick the response headers into responseHeaders
168
+ for (var i = 0; i < respheadlength; i++) {
169
+ var headerName = connection.getHeaderFieldKey(i);
170
+ var headerValue = connection.getHeaderField(i);
171
+ if (headerName)
172
+ xhr.responseHeaders[headerName+''] = headerValue+'';
173
+ }
174
+ }catch(e){
175
+ $env.error('failed to load response headers',e);
176
+ }
177
+
178
+ xhr.readyState = 4;
179
+ xhr.status = parseInt(connection.responseCode,10) || undefined;
180
+ xhr.statusText = connection.responseMessage || "";
181
+
182
+ var contentEncoding = connection.getContentEncoding() || "utf-8",
183
+ baos = new java.io.ByteArrayOutputStream(),
184
+ buffer = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024),
185
+ length,
186
+ stream = null,
187
+ responseXML = null;
188
+
189
+ try{
190
+ stream = (contentEncoding.equalsIgnoreCase("gzip") || contentEncoding.equalsIgnoreCase("decompress") )?
191
+ new java.util.zip.GZIPInputStream(connection.getInputStream()) :
192
+ connection.getInputStream();
193
+ }catch(e){
194
+ if (connection.getResponseCode() == 404)
195
+ $env.info('failed to open connection stream \n' +
196
+ e.toString(), e);
197
+ else
198
+ $env.error('failed to open connection stream \n' +
199
+ e.toString(), e);
200
+ stream = connection.getErrorStream();
201
+ }
202
+
203
+ while ((length = stream.read(buffer)) != -1) {
204
+ baos.write(buffer, 0, length);
205
+ }
206
+
207
+ baos.close();
208
+ stream.close();
209
+
210
+ xhr.responseText = java.nio.charset.Charset.forName("UTF-8").
211
+ decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+"";
212
+
213
+ }
214
+ if(responseHandler){
215
+ $env.debug('calling ajax response handler');
216
+ responseHandler();
217
+ }
218
+ };
219
+
220
+ var htmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
221
+ htmlDocBuilder.setNamespaceAware(false);
222
+ htmlDocBuilder.setValidating(false);
223
+
224
+ var tidy;
225
+ $env.tidyHTML = false;
226
+ $env.tidy = function(htmlString){
227
+ $env.debug('Cleaning html :\n'+htmlString);
228
+ var xmlString,
229
+ baos = new java.io.ByteArrayOutputStream(),
230
+ bais = new java.io.ByteArrayInputStream(
231
+ (new java.lang.String(htmlString)).
232
+ getBytes("UTF8"));
233
+ try{
234
+ if(!tidy){
235
+ tidy = new org.w3c.tidy.Tidy();
236
+ }
237
+ $env.debug('tidying');
238
+ tidy.parse(bais,baos);
239
+ xmlString = java.nio.charset.Charset.forName("UTF-8").
240
+ decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+"";
241
+ $env.debug('finished tidying');
242
+ }catch(e){
243
+ $env.error('error in html tidy', e);
244
+ }finally{
245
+ try{
246
+ bais.close();
247
+ baos.close();
248
+ }catch(ee){
249
+ //swallow
250
+ }
251
+ }
252
+ $env.debug('Cleaned html :\n'+xmlString);
253
+ return xmlString;
254
+ };
255
+
256
+ var xmlDocBuilder = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
257
+ xmlDocBuilder.setNamespaceAware(true);
258
+ xmlDocBuilder.setValidating(false);
259
+
260
+ $env.parseXML = function(xmlstring){
261
+ return xmlDocBuilder.newDocumentBuilder().parse(
262
+ new java.io.ByteArrayInputStream(
263
+ (new java.lang.String(xmlstring)).getBytes("UTF8")));
264
+ };
265
+
266
+
267
+ $env.xpath = function(expression, doc){
268
+ return Packages.javax.xml.xpath.
269
+ XPathFactory.newInstance().newXPath().
270
+ evaluate(expression, doc, javax.xml.xpath.XPathConstants.NODESET);
271
+ };
272
+
273
+ var jsonmlxslt;
274
+ $env.jsonml = function(xmlstring){
275
+ jsonmlxslt = jsonmlxslt||$env.xslt($env.xml2jsonml.toXMLString());
276
+ var jsonml = $env.transform(jsonmlxslt, xmlstring);
277
+ //$env.debug('jsonml :\n'+jsonml);
278
+ return eval(jsonml);
279
+ };
280
+ var transformerFactory;
281
+ $env.xslt = function(xsltstring){
282
+ transformerFactory = transformerFactory||
283
+ Packages.javax.xml.transform.TransformerFactory.newInstance();
284
+ return transformerFactory.newTransformer(
285
+ new javax.xml.transform.dom.DOMSource(
286
+ $env.parseXML(xsltstring)
287
+ )
288
+ );
289
+ };
290
+ $env.transform = function(xslt, xmlstring){
291
+ var baos = new java.io.ByteArrayOutputStream();
292
+ xslt.transform(
293
+ new javax.xml.transform.dom.DOMSource($env.parseHTML(xmlstring)),
294
+ new javax.xml.transform.stream.StreamResult(baos)
295
+ );
296
+ return java.nio.charset.Charset.forName("UTF-8").
297
+ decode(java.nio.ByteBuffer.wrap(baos.toByteArray())).toString()+"";
298
+ };
299
+
300
+ $env.tmpdir = java.lang.System.getProperty("java.io.tmpdir");
301
+ $env.os_name = java.lang.System.getProperty("os.name");
302
+ $env.os_arch = java.lang.System.getProperty("os.arch");
303
+ $env.os_version = java.lang.System.getProperty("os.version");
304
+ $env.lang = java.lang.System.getProperty("user.lang");
305
+ $env.platform = "Rhino ";//how do we get the version
306
+
307
+ $env.scriptTypes = {
308
+ "text/javascript" :false,
309
+ "text/envjs" :true
310
+ };
311
+
312
+
313
+ $env.loadInlineScript = function(script){
314
+ var tmpFile = $env.writeToTempFile(script.text, 'js') ;
315
+ $env.debug("loading " + tmpFile);
316
+ $env.loadIntoFnsScope(tmpFile);
317
+ };
318
+
319
+ //injected by org.mozilla.javascript.tools.envjs.
320
+ $env.getFreshScopeObj = getFreshScopeObj;
321
+ $env.getProxyFor = getProxyFor;
322
+ $env.getScope = getScope;
323
+ $env.setScope = setScope;
324
+ $env.configureScope = configureScope;
325
+ $env.restoreScope = restoreScope;
326
+
327
+ })(Envjs);
@@ -0,0 +1,41 @@
1
+ var $debug = function() {
2
+ // $master["print"].apply(this,arguments);
3
+ };
4
+
5
+ var $warn = function() {
6
+ // $master["print"].apply(this,arguments);
7
+ };
8
+
9
+ var $info = function() {
10
+ // $master["print"].apply(this,arguments);
11
+ };
12
+
13
+ var $error = function() {
14
+ $master["print"].apply(this,arguments);
15
+ if (arguments[0].stack) {
16
+ $master["print"](arguments[0].stack);
17
+ }
18
+ };
19
+
20
+ var __extend__ = function (a,b) {
21
+ for ( var i in b ) {
22
+ var g = b.__lookupGetter__(i), s = b.__lookupSetter__(i);
23
+ if ( g || s ) {
24
+ if ( g ) a.__defineGetter__(i, g);
25
+ if ( s ) a.__defineSetter__(i, s);
26
+ } else
27
+ a[i] = b[i];
28
+ } return a;
29
+ };
30
+
31
+ var __setArray__ = function ( target, array ) {
32
+ // Resetting the length to 0, then using the native Array push
33
+ // is a super-fast way to populate an object with array-like properties
34
+ target.length = 0;
35
+ Array.prototype.push.apply( target, array );
36
+ };
37
+
38
+ function trim( str ){
39
+ return (str || "").replace( /^\s+|\s+$/g, "" );
40
+
41
+ };
@@ -0,0 +1,30 @@
1
+ if(false){
2
+ (function(){
3
+
4
+ var master = this.$master;
5
+ var print = master["print"];
6
+
7
+ delete this.$master;
8
+ delete this.$debug;
9
+
10
+ for(var v in master.symbols) {
11
+ if(master.symbols[v] === "Ruby") continue;
12
+ delete this[master.symbols[v]];
13
+ }
14
+
15
+ print("exported symbols");
16
+ for(var v in this) {
17
+ if(v !== "Ruby" &&v !== "Johnson" && v !== "__FILE__" ) {
18
+ print(v);
19
+ //master.seal(this[v],true);
20
+ }
21
+ }
22
+ }());
23
+ }
24
+
25
+ // Local Variables:
26
+ // espresso-indent-level:4
27
+ // c-basic-offset:4
28
+ // tab-width:4
29
+ // mode:auto-revert
30
+ // End:
@@ -0,0 +1,238 @@
1
+ /**
2
+ * jQuery AOP - jQuery plugin to add features of aspect-oriented programming (AOP) to jQuery.
3
+ * http://jquery-aop.googlecode.com/
4
+ *
5
+ * Licensed under the MIT license:
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ *
8
+ * Version: 1.1
9
+ */
10
+ window.$profiler;
11
+
12
+ (function() {
13
+
14
+ var _after = 1;
15
+ var _before = 2;
16
+ var _around = 3;
17
+ var _intro = 4;
18
+ var _regexEnabled = true;
19
+
20
+ /**
21
+ * Private weaving function.
22
+ */
23
+ var weaveOne = function(source, method, advice) {
24
+
25
+ var old = source[method];
26
+
27
+ var aspect;
28
+ if (advice.type == _after)
29
+ aspect = function() {
30
+ var returnValue = old.apply(this, arguments);
31
+ return advice.value.apply(this, [returnValue, method]);
32
+ };
33
+ else if (advice.type == _before)
34
+ aspect = function() {
35
+ advice.value.apply(this, [arguments, method]);
36
+ return old.apply(this, arguments);
37
+ };
38
+ else if (advice.type == _intro)
39
+ aspect = function() {
40
+ return advice.value.apply(this, arguments);
41
+ };
42
+ else if (advice.type == _around) {
43
+ aspect = function() {
44
+ var invocation = { object: this, args: arguments };
45
+ return advice.value.apply(invocation.object, [{ arguments: invocation.args, method: method, proceed :
46
+ function() {
47
+ return old.apply(invocation.object, invocation.args);
48
+ }
49
+ }] );
50
+ };
51
+ }
52
+
53
+ aspect.unweave = function() {
54
+ source[method] = old;
55
+ pointcut = source = aspect = old = null;
56
+ };
57
+
58
+ source[method] = aspect;
59
+
60
+ return aspect;
61
+
62
+ };
63
+
64
+
65
+ /**
66
+ * Private weaver and pointcut parser.
67
+ */
68
+ var weave = function(pointcut, advice)
69
+ {
70
+
71
+ var source = (typeof(pointcut.target.prototype) != 'undefined') ? pointcut.target.prototype : pointcut.target;
72
+ var advices = [];
73
+
74
+ // If it's not an introduction and no method was found, try with regex...
75
+ if (advice.type != _intro && typeof(source[pointcut.method]) == 'undefined')
76
+ {
77
+
78
+ for (var method in source)
79
+ {
80
+ if (source[method] != null && source[method] instanceof Function && method.match(pointcut.method))
81
+ {
82
+ advices[advices.length] = weaveOne(source, method, advice);
83
+ }
84
+ }
85
+
86
+ if (advices.length == 0)
87
+ throw 'No method: ' + pointcut.method;
88
+
89
+ }
90
+ else
91
+ {
92
+ // Return as an array of one element
93
+ advices[0] = weaveOne(source, pointcut.method, advice);
94
+ }
95
+
96
+ return _regexEnabled ? advices : advices[0];
97
+
98
+ };
99
+
100
+ window.$profiler =
101
+ {
102
+ /**
103
+ * Creates an advice after the defined point-cut. The advice will be executed after the point-cut method
104
+ * has completed execution successfully, and will receive one parameter with the result of the execution.
105
+ * This function returns an array of weaved aspects (Function).
106
+ *
107
+ * @example jQuery.aop.after( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );
108
+ * @result Array<Function>
109
+ *
110
+ * @example jQuery.aop.after( {target: String, method: 'indexOf'}, function(index) { alert('Result found at: ' + index + ' on:' + this); } );
111
+ * @result Array<Function>
112
+ *
113
+ * @name after
114
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
115
+ * @option Object target Target object to be weaved.
116
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
117
+ * @param Function advice Function containing the code that will get called after the execution of the point-cut. It receives one parameter
118
+ * with the result of the point-cut's execution.
119
+ *
120
+ * @type Array<Function>
121
+ * @cat Plugins/General
122
+ */
123
+ after : function(pointcut, advice)
124
+ {
125
+ return weave( pointcut, { type: _after, value: advice } );
126
+ },
127
+
128
+ /**
129
+ * Creates an advice before the defined point-cut. The advice will be executed before the point-cut method
130
+ * but cannot modify the behavior of the method, or prevent its execution.
131
+ * This function returns an array of weaved aspects (Function).
132
+ *
133
+ * @example jQuery.aop.before( {target: window, method: 'MyGlobalMethod'}, function() { alert('About to execute MyGlobalMethod'); } );
134
+ * @result Array<Function>
135
+ *
136
+ * @example jQuery.aop.before( {target: String, method: 'indexOf'}, function(index) { alert('About to execute String.indexOf on: ' + this); } );
137
+ * @result Array<Function>
138
+ *
139
+ * @name before
140
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
141
+ * @option Object target Target object to be weaved.
142
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
143
+ * @param Function advice Function containing the code that will get called before the execution of the point-cut.
144
+ *
145
+ * @type Array<Function>
146
+ * @cat Plugins/General
147
+ */
148
+ before : function(pointcut, advice)
149
+ {
150
+ return weave( pointcut, { type: _before, value: advice } );
151
+ },
152
+
153
+
154
+ /**
155
+ * Creates an advice 'around' the defined point-cut. This type of advice can control the point-cut method execution by calling
156
+ * the functions '.proceed()' on the 'invocation' object, and also, can modify the arguments collection before sending them to the function call.
157
+ * This function returns an array of weaved aspects (Function).
158
+ *
159
+ * @example jQuery.aop.around( {target: window, method: 'MyGlobalMethod'}, function(invocation) {
160
+ * alert('# of Arguments: ' + invocation.arguments.length);
161
+ * return invocation.proceed();
162
+ * } );
163
+ * @result Array<Function>
164
+ *
165
+ * @example jQuery.aop.around( {target: String, method: 'indexOf'}, function(invocation) {
166
+ * alert('Searching: ' + invocation.arguments[0] + ' on: ' + this);
167
+ * return invocation.proceed();
168
+ * } );
169
+ * @result Array<Function>
170
+ *
171
+ * @example jQuery.aop.around( {target: window, method: /Get(\d+)/}, function(invocation) {
172
+ * alert('Executing ' + invocation.method);
173
+ * return invocation.proceed();
174
+ * } );
175
+ * @desc Matches all global methods starting with 'Get' and followed by a number.
176
+ * @result Array<Function>
177
+ *
178
+ *
179
+ * @name around
180
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
181
+ * @option Object target Target object to be weaved.
182
+ * @option String method Name of the function to be weaved. Regex are supported, but not on built-in objects.
183
+ * @param Function advice Function containing the code that will get called around the execution of the point-cut. This advice will be called with one
184
+ * argument containing one function '.proceed()', the collection of arguments '.arguments', and the matched method name '.method'.
185
+ *
186
+ * @type Array<Function>
187
+ * @cat Plugins/General
188
+ */
189
+ around : function(pointcut, advice)
190
+ {
191
+ return weave( pointcut, { type: _around, value: advice } );
192
+ },
193
+
194
+ /**
195
+ * Creates an introduction on the defined point-cut. This type of advice replaces any existing methods with the same
196
+ * name. To restore them, just unweave it.
197
+ * This function returns an array with only one weaved aspect (Function).
198
+ *
199
+ * @example jQuery.aop.introduction( {target: window, method: 'MyGlobalMethod'}, function(result) { alert('Returned: ' + result); } );
200
+ * @result Array<Function>
201
+ *
202
+ * @example jQuery.aop.introduction( {target: String, method: 'log'}, function() { alert('Console: ' + this); } );
203
+ * @result Array<Function>
204
+ *
205
+ * @name introduction
206
+ * @param Map pointcut Definition of the point-cut to apply the advice. A point-cut is the definition of the object/s and method/s to be weaved.
207
+ * @option Object target Target object to be weaved.
208
+ * @option String method Name of the function to be weaved.
209
+ * @param Function advice Function containing the code that will be executed on the point-cut.
210
+ *
211
+ * @type Array<Function>
212
+ * @cat Plugins/General
213
+ */
214
+ introduction : function(pointcut, advice)
215
+ {
216
+ return weave( pointcut, { type: _intro, value: advice } );
217
+ },
218
+
219
+ /**
220
+ * Configures global options.
221
+ *
222
+ * @name setup
223
+ * @param Map settings Configuration options.
224
+ * @option Boolean regexMatch Enables/disables regex matching of method names.
225
+ *
226
+ * @example jQuery.aop.setup( { regexMatch: false } );
227
+ * @desc Disable regex matching.
228
+ *
229
+ * @type Void
230
+ * @cat Plugins/General
231
+ */
232
+ setup: function(settings)
233
+ {
234
+ _regexEnabled = settings.regexMatch;
235
+ }
236
+ };
237
+
238
+ })();