github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/public/codemirror/mode/vb/index.html (about)

     1  <!doctype html>
     2  
     3  <title>CodeMirror: VB.NET mode</title>
     4  <meta charset="utf-8"/>
     5  <link rel=stylesheet href="../../doc/docs.css">
     6  
     7  <link rel="stylesheet" href="../../lib/codemirror.css">
     8  <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
     9  <script src="../../lib/codemirror.js"></script>
    10  <script src="vb.js"></script>
    11  <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
    12  <style>
    13        .CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
    14        .CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
    15        .CodeMirror pre { font-family: Inconsolata; font-size: 14px}
    16      </style>
    17  <div id=nav>
    18    <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
    19  
    20    <ul>
    21      <li><a href="../../index.html">Home</a>
    22      <li><a href="../../doc/manual.html">Manual</a>
    23      <li><a href="https://github.com/codemirror/codemirror">Code</a>
    24    </ul>
    25    <ul>
    26      <li><a href="../index.html">Language modes</a>
    27      <li><a class=active href="#">VB.NET</a>
    28    </ul>
    29  </div>
    30  
    31  <article>
    32  <h2>VB.NET mode</h2>
    33  
    34  <script type="text/javascript">
    35  function test(golden, text) {
    36    var ok = true;
    37    var i = 0;
    38    function callback(token, style, lineNo, pos){
    39  		//console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
    40      var result = [String(token), String(style)];
    41      if (golden[i][0] != result[0] || golden[i][1] != result[1]){
    42        return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
    43        ok = false;
    44      }
    45      i++;
    46    }
    47    CodeMirror.runMode(text, "text/x-vb",callback); 
    48  
    49    if (ok) return "Tests OK";
    50  }
    51  function testTypes() {
    52    var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
    53    var text =  "Integer Float";
    54    return test(golden,text);
    55  }
    56  function testIf(){
    57    var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
    58    var text = 'If True End If';
    59    return test(golden, text);
    60  }
    61  function testDecl(){
    62     var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
    63     var text = 'Dim x as Integer';
    64     return test(golden, text);
    65  }
    66  function testAll(){
    67    var result = "";
    68  
    69    result += testTypes() + "\n";
    70    result += testIf() + "\n";
    71    result += testDecl() + "\n";
    72    return result;
    73  
    74  }
    75  function initText(editor) {
    76    var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
    77    editor.setValue(content);
    78    for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
    79  }
    80  function init() {
    81      editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
    82          lineNumbers: true,
    83          mode: "text/x-vb",
    84          readOnly: false
    85      });
    86      runTest();
    87  }
    88  function runTest() {
    89  	document.getElementById('testresult').innerHTML = testAll();
    90    initText(editor);
    91  	
    92  }
    93  document.body.onload = init;
    94  </script>
    95  
    96    <div id="edit">
    97    <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
    98    </div>
    99    <pre id="testresult"></pre>
   100    <p>MIME type defined: <code>text/x-vb</code>.</p>
   101  
   102  </article>