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.

161 lines
6.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. margin: 0;
  12. padding: 0;
  13. overflow: hidden;
  14. background: #232B30;
  15. }
  16. .inner {
  17. margin-top: 28px;
  18. margin-left: 6px;
  19. margin-right: 6px;
  20. position: absolute;
  21. top: 0;
  22. bottom: 0;
  23. left: 0;
  24. right: 0;
  25. }
  26. .toolbar {
  27. height: 28px;
  28. background: #232B30; /* old browsers */
  29. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  30. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  31. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  32. }
  33. .btn {
  34. height: 25px;
  35. outline: 0;
  36. padding: 3px 8px;
  37. color: #9fa8b0;
  38. font-weight: bold;
  39. text-shadow: 1px 1px #1f272b;
  40. border: 1px solid #1c252b;
  41. border-radius: 3px;
  42. -moz-border-radius: 3px;
  43. -webkit-border-radius: 3px;
  44. background: #232B30; /* old browsers */
  45. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  46. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  47. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  48. box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* CSS3 */
  49. -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Firefox */
  50. -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Safari, Chrome */
  51. }
  52. .btn_g {
  53. margin-right: 10px;
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <div class="toolbar">
  59. <!--<button id="btnSave" onClick="save()" class="btn btn_g">save</button>-->
  60. <button id="btnUndo" onClick="editor.undo()" class="btn">↶</button>
  61. <button id="btnRedo" onClick="editor.redo()" class="btn btn_g">↷</button>
  62. <button id="btnFs" onclick="toggleFullscreen()" class="btn">◻</button>
  63. </div>
  64. <div class="inner" id="editor"></div>
  65. <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  66. <script>
  67. var buildDom = ace.require("ace/lib/dom").buildDom;
  68. var editor = ace.edit("editor");
  69. editor.setOptions({
  70. mode: "ace/mode/text",
  71. theme: "ace/theme/ambiance",
  72. showPrintMargin: false,
  73. wrap: true,
  74. indentedSoftWrap: false,
  75. showFoldWidgets: false,
  76. showLineNumbers: true,
  77. showGutter: false,
  78. autoScrollEditorIntoView: true,
  79. fontSize: 14
  80. });
  81. function updateToolbar() {
  82. document.getElementById("btnUndo").disabled = !editor.session.getUndoManager().hasUndo();
  83. document.getElementById("btnRedo").disabled = !editor.session.getUndoManager().hasRedo();
  84. if (!window.fullscreen) {
  85. document.getElementById("btnFs").style.display = "block";
  86. }
  87. }
  88. editor.on("input", updateToolbar);
  89. if (localStorage.getItem("acetest") !== null) {
  90. editor.setValue(localStorage.getItem("acetest"));
  91. editor.clearSelection();
  92. }
  93. editor.getSession().on('change', function () {
  94. localStorage.setItem("acetest", editor.getSession().getValue());
  95. });
  96. function save() {
  97. var file = prompt("Name the file:", "text.txt");
  98. download(file, editor.getSession().getValue());
  99. }
  100. editor.commands.addCommand({
  101. name: "save",
  102. exec: save,
  103. bindKey: {
  104. win: "ctrl-s",
  105. mac: "cmd-s"
  106. }
  107. });
  108. function toggleFullscreen() {
  109. if (!window.fullScreen) {
  110. var elem = document.documentElement;
  111. if (elem.requestFullscreen) {
  112. elem.requestFullscreen();
  113. } else if (elem.mozRequestFullScreen) { /* Firefox */
  114. elem.mozRequestFullScreen();
  115. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  116. elem.webkitRequestFullscreen();
  117. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  118. elem.msRequestFullscreen();
  119. }
  120. document.getElementById("btnFs").style.display = "none";
  121. }
  122. else {
  123. if (document.exitFullscreen) {
  124. document.exitFullscreen();
  125. } else if (document.mozCancelFullScreen) {
  126. document.mozCancelFullScreen();
  127. } else if (document.webkitExitFullscreen) {
  128. document.webkitExitFullscreen();
  129. } else if (document.msExitFullscreen) {
  130. document.msExitFullscreen();
  131. }
  132. }
  133. }
  134. function download(filename, text) {
  135. var element = document.createElement('a');
  136. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  137. element.setAttribute('download', filename);
  138. element.style.display = 'none';
  139. document.body.appendChild(element);
  140. element.click();
  141. document.body.removeChild(element);
  142. }
  143. window.editor = editor;
  144. </script>
  145. </body>
  146. </html>