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.

index.html 5.8KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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="btnSave" onClick="save()" class="btn btn_g">save</button>-->
  60. <button id="btnUndo" onClick="editor.undo()" class="btn">↶</button>
  61. <button id="btnRedo" onClick="editor.redo()" class="btn btn_g">↷</button>
  62. <button id="btnFs" onclick="toggleFullscreen()" class="btn">◻</button>
  63. </div>
  64. <div class="inner" id="editor"></div>
  65. <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
  66. <script>
  67. var buildDom = ace.require("ace/lib/dom").buildDom;
  68. var editor = ace.edit("editor");
  69. editor.setOptions({
  70. mode: "ace/mode/text",
  71. theme: "ace/theme/ambiance",
  72. showPrintMargin: false,
  73. wrap: true,
  74. indentedSoftWrap: false,
  75. showFoldWidgets: false,
  76. showLineNumbers: true,
  77. showGutter: false,
  78. autoScrollEditorIntoView: true,
  79. fontSize: 14
  80. });
  81. function updateToolbar() {
  82. document.getElementById("btnUndo").disabled = !editor.session.getUndoManager().hasUndo();
  83. document.getElementById("btnRedo").disabled = !editor.session.getUndoManager().hasRedo();
  84. if (!window.fullscreen) {
  85. document.getElementById("btnFs").style.display = "none";
  86. } else {
  87. document.getElementById("btnFs").style.display = "block";
  88. }
  89. }
  90. editor.on("input", updateToolbar);
  91. if (localStorage.getItem("acetest") !== null) {
  92. editor.setValue(localStorage.getItem("acetest"));
  93. editor.clearSelection();
  94. }
  95. editor.getSession().on('change', function () {
  96. localStorage.setItem("acetest", editor.getSession().getValue());
  97. });
  98. function save() {
  99. alert("not yet implemented");
  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. }
  122. else {
  123. if (document.exitFullscreen) {
  124. document.exitFullscreen();
  125. } else if (document.mozCancelFullScreen) {
  126. document.mozCancelFullScreen();
  127. } else if (document.webkitExitFullscreen) {
  128. document.webkitExitFullscreen();
  129. } else if (document.msExitFullscreen) {
  130. document.msExitFullscreen();
  131. }
  132. }
  133. }
  134. window.editor = editor;
  135. </script>
  136. </body>
  137. </html>