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.

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