diff options
author | Eric Guzman | 2012-02-16 00:22:43 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-16 00:22:43 -0800 |
commit | 82b1a273219f0ae3d119e156c7acccdbe478f441 (patch) | |
tree | 74c45e5e3afc6706b2f7a7918807f72c54cdcfc5 /imports/codemirror/mode/javascript/index.html | |
parent | af20ca9b11133dd5cefb9275dbe8fb101c3380d0 (diff) | |
parent | 966f0adaf1d4b7f2dd5a6e31643df58bff713884 (diff) | |
download | ninja-82b1a273219f0ae3d119e156c7acccdbe478f441.tar.gz |
Merge branch 'refs/heads/TreeComponents' into PresetsPanel
Diffstat (limited to 'imports/codemirror/mode/javascript/index.html')
-rwxr-xr-x | imports/codemirror/mode/javascript/index.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/imports/codemirror/mode/javascript/index.html b/imports/codemirror/mode/javascript/index.html new file mode 100755 index 00000000..c3ab91dc --- /dev/null +++ b/imports/codemirror/mode/javascript/index.html | |||
@@ -0,0 +1,77 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror: JavaScript mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="javascript.js"></script> | ||
8 | <link rel="stylesheet" href="../../doc/docs.css"> | ||
9 | <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> | ||
10 | </head> | ||
11 | <body> | ||
12 | <h1>CodeMirror: JavaScript mode</h1> | ||
13 | |||
14 | <div><textarea id="code" name="code"> | ||
15 | // Demo code (the actual new parser character stream implementation) | ||
16 | |||
17 | function StringStream(string) { | ||
18 | this.pos = 0; | ||
19 | this.string = string; | ||
20 | } | ||
21 | |||
22 | StringStream.prototype = { | ||
23 | done: function() {return this.pos >= this.string.length;}, | ||
24 | peek: function() {return this.string.charAt(this.pos);}, | ||
25 | next: function() { | ||
26 | if (this.pos < this.string.length) | ||
27 | return this.string.charAt(this.pos++); | ||
28 | }, | ||
29 | eat: function(match) { | ||
30 | var ch = this.string.charAt(this.pos); | ||
31 | if (typeof match == "string") var ok = ch == match; | ||
32 | else var ok = ch && match.test ? match.test(ch) : match(ch); | ||
33 | if (ok) {this.pos++; return ch;} | ||
34 | }, | ||
35 | eatWhile: function(match) { | ||
36 | var start = this.pos; | ||
37 | while (this.eat(match)); | ||
38 | if (this.pos > start) return this.string.slice(start, this.pos); | ||
39 | }, | ||
40 | backUp: function(n) {this.pos -= n;}, | ||
41 | column: function() {return this.pos;}, | ||
42 | eatSpace: function() { | ||
43 | var start = this.pos; | ||
44 | while (/\s/.test(this.string.charAt(this.pos))) this.pos++; | ||
45 | return this.pos - start; | ||
46 | }, | ||
47 | match: function(pattern, consume, caseInsensitive) { | ||
48 | if (typeof pattern == "string") { | ||
49 | function cased(str) {return caseInsensitive ? str.toLowerCase() : str;} | ||
50 | if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) { | ||
51 | if (consume !== false) this.pos += str.length; | ||
52 | return true; | ||
53 | } | ||
54 | } | ||
55 | else { | ||
56 | var match = this.string.slice(this.pos).match(pattern); | ||
57 | if (match && consume !== false) this.pos += match[0].length; | ||
58 | return match; | ||
59 | } | ||
60 | } | ||
61 | }; | ||
62 | </textarea></div> | ||
63 | |||
64 | <script> | ||
65 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
66 | lineNumbers: true, | ||
67 | matchBrackets: true | ||
68 | }); | ||
69 | </script> | ||
70 | |||
71 | <p>JavaScript mode supports a single configuration | ||
72 | option, <code>json</code>, which will set the mode to expect JSON | ||
73 | data rather than a JavaScript program.</p> | ||
74 | |||
75 | <p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>.</p> | ||
76 | </body> | ||
77 | </html> | ||