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.

140 lines
5.5KB

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