Вход Регистрация
Файл: engine/skins/mirror/mode/javascript/index.html
Строк: 141
<?php
<!doctype html>

<
title>CodeMirrorJavaScript mode</title>
<
meta charset="utf-8"/>
<
link rel=stylesheet href="../../doc/docs.css">

<
link rel="stylesheet" href="../../lib/codemirror.css">
<
script src="../../lib/codemirror.js"></script>
<
script src="../../addon/edit/matchbrackets.js"></script>
<
script src="../../addon/comment/continuecomment.js"></script>
<
script src="../../addon/comment/comment.js"></script>
<
script src="javascript.js"></script>
<
style type="text/css">.CodeMirror {border-top1px solid blackborder-bottom1px solid black;}</style>
<
div id=nav>
  <
a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>

  <
ul>
    <
li><a href="../../index.html">Home</a>
    <
li><a href="../../doc/manual.html">Manual</a>
    <
li><a href="https://github.com/marijnh/codemirror">Code</a>
  </
ul>
  <
ul>
    <
li><a href="../index.html">Language modes</a>
    <
li><class=active href="#">JavaScript</a>
  </
ul>
</
div>

<
article>
<
h2>JavaScript mode</h2>


<
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 &ltthis.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;&ampmatch.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(startthis.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(patternconsumecaseInsensitive) {
    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 !== falsethis.pos += str.length;
        return 
true;
      }
    }
    else {
      var 
match this.string.slice(this.pos).match(pattern);
      if (
match &amp;&ampconsume !== falsethis.pos += match[0].length;
      return 
match;
    }
  }
};
</
textarea></div>

    <
script>
      var 
editor CodeMirror.fromTextArea(document.getElementById("code"), {
        
lineNumberstrue,
        
matchBracketstrue,
        
continueComments"Enter",
        
extraKeys: {"Ctrl-Q""toggleComment"}
      });
    </
script>

    <
p>
      
JavaScript mode supports several configuration options:
      <
ul>
        <
li><code>json</codewhich will set the mode to expect JSON
        data rather than a JavaScript program
.</li>
        <
li><code>jsonld</codewhich will set the mode to expect
        
<a href="http://json-ld.org">JSON-LD</alinked data rather
        than a JavaScript program 
(<a href="json-ld.html">demo</a>).</li>
        <
li><code>typescript</codewhich will activate additional
        syntax highlighting 
and some other things for TypeScript code
        
(<a href="typescript.html">demo</a>).</li>
        <
li><code>statementIndent</codewhich (given a numberwill
        determine the amount of indentation to 
use for statements
        continued on a 
new line.</li>
      </
ul>
    </
p>

    <
p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>, <code>application/ld+json</code>, <code>text/typescript</code>, <code>application/typescript</code>.</p>
  </
article>
?>
Онлайн: 0
Реклама