aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LocalFilesEditor/codemirror/mode/javascript/index.html
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-04-12 11:12:51 +0000
committerpatdenice <patdenice@piwigo.org>2011-04-12 11:12:51 +0000
commita740ef91e6689f86011b70c7bbe2589abf78ae6b (patch)
treebb4a6deb7395b0f545bb760cf34f093e910f1cff /plugins/LocalFilesEditor/codemirror/mode/javascript/index.html
parentbb7c28f86febddd376ee0400807507991a2d7b48 (diff)
feature:2262
Replace editarea by Codemirror: http://codemirror.net git-svn-id: http://piwigo.org/svn/trunk@10307 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins/LocalFilesEditor/codemirror/mode/javascript/index.html')
-rw-r--r--plugins/LocalFilesEditor/codemirror/mode/javascript/index.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/LocalFilesEditor/codemirror/mode/javascript/index.html b/plugins/LocalFilesEditor/codemirror/mode/javascript/index.html
new file mode 100644
index 000000000..7b528e041
--- /dev/null
+++ b/plugins/LocalFilesEditor/codemirror/mode/javascript/index.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror 2: JavaScript mode</title>
+ <link rel="stylesheet" href="../../lib/codemirror.css">
+ <script src="../../lib/codemirror.js"></script>
+ <script src="javascript.js"></script>
+ <link rel="stylesheet" href="javascript.css">
+ <link rel="stylesheet" href="../../css/docs.css">
+ <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+ </head>
+ <body>
+ <h1>CodeMirror 2: JavaScript mode</h1>
+
+<div><textarea id="code" name="code">
+// Demo code (the actual new parser character stream implementation)
+
+function StringStream(string) {
+ this.pos = 0;
+ this.string = string;
+}
+
+StringStream.prototype = {
+ done: function() {return this.pos >= this.string.length;},
+ peek: function() {return this.string.charAt(this.pos);},
+ next: function() {
+ if (this.pos &lt; this.string.length)
+ return this.string.charAt(this.pos++);
+ },
+ eat: function(match) {
+ var ch = this.string.charAt(this.pos);
+ if (typeof match == "string") var ok = ch == match;
+ else var ok = ch &amp;&amp; match.test ? match.test(ch) : match(ch);
+ if (ok) {this.pos++; return ch;}
+ },
+ eatWhile: function(match) {
+ var start = this.pos;
+ while (this.eat(match));
+ if (this.pos > start) return this.string.slice(start, this.pos);
+ },
+ backUp: function(n) {this.pos -= n;},
+ column: function() {return this.pos;},
+ eatSpace: function() {
+ var start = this.pos;
+ while (/\s/.test(this.string.charAt(this.pos))) this.pos++;
+ return this.pos - start;
+ },
+ match: function(pattern, consume, caseInsensitive) {
+ if (typeof pattern == "string") {
+ function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
+ if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
+ if (consume !== false) this.pos += str.length;
+ return true;
+ }
+ }
+ else {
+ var match = this.string.slice(this.pos).match(pattern);
+ if (match &amp;&amp; consume !== false) this.pos += match[0].length;
+ return match;
+ }
+ }
+};
+</textarea></div>
+
+ <script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ matchBrackets: true
+ });
+ </script>
+
+ <p>JavaScript mode supports a single configuration
+ option, <code>json</code>, which will set the mode to expect JSON
+ data rather than a JavaScript program.</p>
+
+ <p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>.</p>
+ </body>
+</html>