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.

139 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: true,
  72. showFoldWidgets: false,
  73. showLineNumbers: true,
  74. showGutter: false,
  75. autoScrollEditorIntoView: true
  76. });
  77. function updateToolbar() {
  78. document.getElementById("btnUndo") = !editor.session.getUndoManager().hasUndo();
  79. document.getElementById("btnRedo") = !editor.session.getUndoManager().hasRedo();
  80. }
  81. editor.on("input", updateToolbar);
  82. if (localStorage.getItem("acetest") !== null) {
  83. editor.setValue(localStorage.getItem("acetest"));
  84. editor.clearSelection();
  85. }
  86. editor.getSession().on('change', function () {
  87. localStorage.setItem("acetest", editor.getSession().getValue());
  88. });
  89. function save() {
  90. alert("not yet implemented");
  91. }
  92. editor.commands.addCommand({
  93. name: "save",
  94. exec: save,
  95. bindKey: {
  96. win: "ctrl-s",
  97. mac: "cmd-s"
  98. }
  99. });
  100. function toggleFullscreen() {
  101. if (!window.fullScreen) {
  102. var elem = document.documentElement;
  103. if (elem.requestFullscreen) {
  104. elem.requestFullscreen();
  105. } else if (elem.mozRequestFullScreen) { /* Firefox */
  106. elem.mozRequestFullScreen();
  107. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  108. elem.webkitRequestFullscreen();
  109. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  110. elem.msRequestFullscreen();
  111. }
  112. }
  113. else {
  114. if (document.exitFullscreen) {
  115. document.exitFullscreen();
  116. } else if (document.mozCancelFullScreen) {
  117. document.mozCancelFullScreen();
  118. } else if (document.webkitExitFullscreen) {
  119. document.webkitExitFullscreen();
  120. } else if (document.msExitFullscreen) {
  121. document.msExitFullscreen();
  122. }
  123. }
  124. }
  125. window.editor = editor;
  126. </script>
  127. </body>
  128. </html>