You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
5.4KB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  7. <meta name="HandheldFriendly" content="True" />
  8. <title>Editor</title>
  9. <style type="text/css" media="screen">
  10. body {
  11. overflow: hidden;
  12. background: #232B30; /* old browsers */
  13. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  14. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  15. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  16. }
  17. .inner {
  18. margin-top: 36px;
  19. position: absolute;
  20. top: 0;
  21. bottom: 0;
  22. left: 0;
  23. right: 0;
  24. }
  25. .btn {
  26. outline: 0;
  27. padding: 3px 8px;
  28. color: #9fa8b0;
  29. font-weight: bold;
  30. text-shadow: 1px 1px #1f272b;
  31. border: 1px solid #1c252b;
  32. border-radius: 3px;
  33. -moz-border-radius: 3px;
  34. -webkit-border-radius: 3px;
  35. background: #232B30; /* old browsers */
  36. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  37. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  38. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  39. box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* CSS3 */
  40. -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Firefox */
  41. -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Safari, Chrome */
  42. }
  43. .btn_g {
  44. margin-right: 10px;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="toolbar">
  50. <!--<button id="btnSave" onClick="save()" class="btn btn_g">save</button>-->
  51. <button id="btnUndo" onClick="editor.undo()" class="btn">↶</button>
  52. <button id="btnRedo" onClick="editor.redo()" class="btn btn_g">↷</button>
  53. <button id="btnFs" onclick="toggleFullscreen() class="btn"">◻</button>
  54. </div>
  55. <div class="inner" id="editor"></div>
  56. <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  57. <script>
  58. var buildDom = ace.require("ace/lib/dom").buildDom;
  59. var editor = ace.edit("editor");
  60. editor.setOptions({
  61. mode: "ace/mode/text",
  62. theme: "ace/theme/ambiance",
  63. showPrintMargin: false,
  64. wrap: true,
  65. indentedSoftWrap: true,
  66. showFoldWidgets: false,
  67. showLineNumbers: true,
  68. showGutter: false,
  69. autoScrollEditorIntoView: true
  70. });
  71. function updateToolbar() {
  72. document.getElementById("btnUndo") = !editor.session.getUndoManager().hasUndo();
  73. document.getElementById("btnRedo") = !editor.session.getUndoManager().hasRedo();
  74. }
  75. editor.on("input", updateToolbar);
  76. if (localStorage.getItem("acetest") !== null) {
  77. editor.setValue(localStorage.getItem("acetest"));
  78. editor.clearSelection();
  79. }
  80. editor.getSession().on('change', function () {
  81. localStorage.setItem("acetest", editor.getSession().getValue());
  82. });
  83. function save() {
  84. alert("not yet implemented");
  85. }
  86. editor.commands.addCommand({
  87. name: "save",
  88. exec: save,
  89. bindKey: {
  90. win: "ctrl-s",
  91. mac: "cmd-s"
  92. }
  93. });
  94. function toggleFullscreen() {
  95. if (window.fullScreen) {
  96. var elem = document.documentElement;
  97. if (elem.requestFullscreen) {
  98. elem.requestFullscreen();
  99. } else if (elem.mozRequestFullScreen) { /* Firefox */
  100. elem.mozRequestFullScreen();
  101. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  102. elem.webkitRequestFullscreen();
  103. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  104. elem.msRequestFullscreen();
  105. }
  106. }
  107. else {
  108. if (document.exitFullscreen) {
  109. document.exitFullscreen();
  110. } else if (document.mozCancelFullScreen) {
  111. document.mozCancelFullScreen();
  112. } else if (document.webkitExitFullscreen) {
  113. document.webkitExitFullscreen();
  114. } else if (document.msExitFullscreen) {
  115. document.msExitFullscreen();
  116. }
  117. }
  118. }
  119. window.editor = editor;
  120. </script>
  121. </body>
  122. </html>