jstest.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <script src="js/codemirror.js" type="text/javascript"></script>
  4. <script src="js/mirrorframe.js" type="text/javascript"></script>
  5. <title>CodeMirror: JavaScript demonstration</title>
  6. <link rel="stylesheet" type="text/css" href="css/docs.css"/>
  7. </head>
  8. <body style="padding: 20px;">
  9. <p>This page demonstrates <a href="index.html">CodeMirror</a>'s
  10. JavaScript parser. Note that the ugly buttons at the top are not are
  11. not part of CodeMirror proper -- they demonstrate the way it can be
  12. embedded in a web-application.</p>
  13. <div class="border">
  14. <textarea id="code" cols="120" rows="30">
  15. // Here you see some JavaScript code. Mess around with it to get
  16. // acquainted with CodeMirror's features.
  17. // Press enter inside the object and your new line will be suitably
  18. // indented.
  19. var keyBindings = {
  20. enter: "newline-and-indent",
  21. tab: "reindent-selection",
  22. ctrl_z: "undo",
  23. ctrl_y: "redo",
  24. ctrl_backspace: "undo-for-safari (which blocks ctrl-z)",
  25. ctrl_bracket: "highlight-brackets",
  26. ctrl_shift_bracket: "jump-to-matching-bracket"
  27. };
  28. // Press tab on the next line and the wrong indentation will be fixed.
  29. var regex = /foo|bar/i;
  30. function example(x) {
  31. // Local variables get a different colour than global ones.
  32. var y = 44.4;
  33. return x + y - z;
  34. }
  35. </textarea>
  36. </div>
  37. <script type="text/javascript">
  38. var textarea = document.getElementById('code');
  39. var editor = new MirrorFrame(CodeMirror.replace(textarea), {
  40. height: "350px",
  41. content: textarea.value,
  42. parserfile: ["tokenizejavascript.js", "parsejavascript.js"],
  43. stylesheet: "css/jscolors.css",
  44. path: "js/",
  45. autoMatchParens: true
  46. });
  47. </script>
  48. </body>
  49. </html>