1
0

theme.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>CodeMirror 2: Theme Demo</title>
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <link rel="stylesheet" href="../theme/default.css">
  8. <link rel="stylesheet" href="../theme/neat.css">
  9. <link rel="stylesheet" href="../theme/elegant.css">
  10. <link rel="stylesheet" href="../theme/night.css">
  11. <script src="../mode/javascript/javascript.js"></script>
  12. <link rel="stylesheet" href="../css/docs.css">
  13. <style type="text/css">
  14. .CodeMirror {border: 1px solid black;}
  15. </style>
  16. </head>
  17. <body>
  18. <h1>CodeMirror 2: Theme demo</h1>
  19. <form><textarea id="code" name="code">
  20. function findSequence(goal) {
  21. function find(start, history) {
  22. if (start == goal)
  23. return history;
  24. else if (start > goal)
  25. return null;
  26. else
  27. return find(start + 5, "(" + history + " + 5)") ||
  28. find(start * 3, "(" + history + " * 3)");
  29. }
  30. return find(1, "1");
  31. }</textarea></form>
  32. <p>Select a theme: <select onchange="selectTheme(this)">
  33. <option selected>default</option>
  34. <option>night</option>
  35. <option>neat</option>
  36. <option>elegant</option>
  37. </select>
  38. </p>
  39. <script>
  40. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  41. lineNumbers: true
  42. });
  43. function selectTheme(node) {
  44. var theme = node.options[node.selectedIndex].innerHTML;
  45. editor.setOption("theme", theme);
  46. }
  47. </script>
  48. </body>
  49. </html>