5 <title>CodeMirror: Lazy Mode Loading Demo</title>
6 <link rel="stylesheet" href="../lib/codemirror.css">
7 <script src="../lib/codemirror.js"></script>
8 <script src="../addon/mode/loadmode.js"></script>
9 <link rel="stylesheet" href="../doc/docs.css">
11 <style type="text/css">
12 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
16 <h1>CodeMirror: Lazy Mode Loading</h1>
18 <form><textarea id="code" name="code">This is the editor.
19 // It starts out in plain text mode,
20 # use the control below to load and apply a mode
21 "you'll see the highlighting of" this text /*change*/.
23 <p><input type=text value=javascript id=mode> <button type=button onclick="change()">change mode</button></p>
26 CodeMirror.modeURL = "../mode/%N/%N.js";
27 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
30 var modeInput = document.getElementById("mode");
31 CodeMirror.on(modeInput, "keypress", function(e) {
32 if (e.keyCode == 13) change();
35 editor.setOption("mode", modeInput.value);
36 CodeMirror.autoLoadMode(editor, modeInput.value);