Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

179 řádky
7.0KB

  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="btnLoad" onclick="load()" class="btn">⇑</button>
  60. <button id="btnSave" onClick="save()" class="btn btn_g">⇩</button>
  61. <button id="btnUndo" onClick="editor.undo()" class="btn">↶</button>
  62. <button id="btnRedo" onClick="editor.redo()" class="btn btn_g">↷</button>
  63. <button id="btnFs" onclick="toggleFullscreen()" class="btn">◻</button>
  64. </div>
  65. <div class="inner" id="editor"></div>
  66. <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  67. <script>
  68. var buildDom = ace.require("ace/lib/dom").buildDom;
  69. var editor = ace.edit("editor");
  70. editor.setOptions({
  71. mode: "ace/mode/text",
  72. theme: "ace/theme/ambiance",
  73. showPrintMargin: false,
  74. wrap: true,
  75. indentedSoftWrap: false,
  76. showFoldWidgets: false,
  77. showLineNumbers: true,
  78. showGutter: false,
  79. autoScrollEditorIntoView: true,
  80. fontSize: 14
  81. });
  82. function updateToolbar() {
  83. document.getElementById("btnUndo").disabled = !editor.session.getUndoManager().hasUndo();
  84. document.getElementById("btnRedo").disabled = !editor.session.getUndoManager().hasRedo();
  85. if (!window.fullscreen) {
  86. document.getElementById("btnFs").style.display = "compact";
  87. }
  88. }
  89. editor.on("input", updateToolbar);
  90. if (localStorage.getItem("acetest") !== null) {
  91. editor.setValue(localStorage.getItem("acetest"));
  92. editor.clearSelection();
  93. }
  94. editor.getSession().on('change', function () {
  95. localStorage.setItem("acetest", editor.getSession().getValue());
  96. });
  97. function save() {
  98. var file = prompt("Name the file:", "text.txt");
  99. download(file, editor.getSession().getValue());
  100. }
  101. editor.commands.addCommand({
  102. name: "save",
  103. exec: save,
  104. bindKey: {
  105. win: "ctrl-s",
  106. mac: "cmd-s"
  107. }
  108. });
  109. function toggleFullscreen() {
  110. if (!window.fullScreen) {
  111. var elem = document.documentElement;
  112. if (elem.requestFullscreen) {
  113. elem.requestFullscreen();
  114. } else if (elem.mozRequestFullScreen) { /* Firefox */
  115. elem.mozRequestFullScreen();
  116. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  117. elem.webkitRequestFullscreen();
  118. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  119. elem.msRequestFullscreen();
  120. }
  121. document.getElementById("btnFs").style.display = "none";
  122. }
  123. else {
  124. if (document.exitFullscreen) {
  125. document.exitFullscreen();
  126. } else if (document.mozCancelFullScreen) {
  127. document.mozCancelFullScreen();
  128. } else if (document.webkitExitFullscreen) {
  129. document.webkitExitFullscreen();
  130. } else if (document.msExitFullscreen) {
  131. document.msExitFullscreen();
  132. }
  133. }
  134. }
  135. function download(filename, text) {
  136. var element = document.createElement('a');
  137. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  138. element.setAttribute('download', filename);
  139. element.style.display = 'none';
  140. document.body.appendChild(element);
  141. element.click();
  142. document.body.removeChild(element);
  143. }
  144. function load() {
  145. var input = document.createElement('input');
  146. input.type = 'file';
  147. input.onchange = e => {
  148. var file = e.target.files[0];
  149. var reader = new FileReader();
  150. reader.readAsText(file,'UTF-8');
  151. reader.onload = readerEvent => {
  152. editor.setValue(readerEvent.target.result);
  153. editor.clearSelection();
  154. }
  155. }
  156. input.click();
  157. }
  158. window.editor = editor;
  159. </script>
  160. </body>
  161. </html>