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 line
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: 28px;
  17. position: absolute;
  18. top: 0;
  19. bottom: 0;
  20. left: 0;
  21. right: 0;
  22. }
  23. .toolbar {
  24. height: 28px;
  25. background: #232B30; /* old browsers */
  26. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  27. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  28. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  29. }
  30. .btn {
  31. height: 25px;
  32. outline: 0;
  33. padding: 3px 8px;
  34. color: #9fa8b0;
  35. font-weight: bold;
  36. text-shadow: 1px 1px #1f272b;
  37. border: 1px solid #1c252b;
  38. border-radius: 3px;
  39. -moz-border-radius: 3px;
  40. -webkit-border-radius: 3px;
  41. background: #232B30; /* old browsers */
  42. background: -moz-linear-gradient(top, #3D4850 3%, #313d45 4%, #232B30 100%); /* firefox */
  43. background: -webkit-gradient(linear, left top, left bottom, color-stop(3%,#3D4850), color-stop(4%,#313d45), color-stop(100%,#232B30)); /* webkit */
  44. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3D4850', endColorstr='#232B30',GradientType=0 ); /* ie */
  45. box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* CSS3 */
  46. -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Firefox */
  47. -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.2); /* Safari, Chrome */
  48. }
  49. .btn_g {
  50. margin-right: 10px;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <div class="toolbar">
  56. <!--<button id="btnSave" onClick="save()" class="btn btn_g">save</button>-->
  57. <button id="btnUndo" onClick="editor.undo()" class="btn">↶</button>
  58. <button id="btnRedo" onClick="editor.redo()" class="btn btn_g">↷</button>
  59. <button id="btnFs" onclick="toggleFullscreen()" class="btn">◻</button>
  60. </div>
  61. <div class="inner" id="editor"></div>
  62. <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  63. <script>
  64. var buildDom = ace.require("ace/lib/dom").buildDom;
  65. var editor = ace.edit("editor");
  66. editor.setOptions({
  67. mode: "ace/mode/text",
  68. theme: "ace/theme/ambiance",
  69. showPrintMargin: false,
  70. wrap: true,
  71. indentedSoftWrap: false,
  72. showFoldWidgets: false,
  73. showLineNumbers: true,
  74. showGutter: false,
  75. autoScrollEditorIntoView: true,
  76. fontSize: 14
  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>