webappedit.tpl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. <title>SquiLuWebAppServer</title>
  5. <link rel="stylesheet" href="/codemirror.css">
  6. <script src="/codemirror-compressed.js"></script>
  7. <link rel="stylesheet" href="/dialogs.css">
  8. <link rel="stylesheet" href="/neat.css">
  9. <link rel="stylesheet" href="/docs.css">
  10. <style type="text/css">
  11. .CodeMirror {border: 1px solid #ccc;}
  12. .CodeMirror-foldmarker {
  13. color: blue;
  14. text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
  15. font-family: arial;
  16. line-height: .3;
  17. cursor: pointer;
  18. }
  19. .CodeMirror-foldgutter {
  20. width: .7em;
  21. }
  22. .CodeMirror-foldgutter-open,
  23. .CodeMirror-foldgutter-folded {
  24. color: #555;
  25. cursor: pointer;
  26. }
  27. .CodeMirror-foldgutter-open:after {
  28. content: "\25BE";
  29. }
  30. .CodeMirror-foldgutter-folded:after {
  31. content: "\25B8";
  32. }
  33. .CodeMirror-focused .cm-matchhighlight {
  34. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
  35. background-position: bottom;
  36. background-repeat: repeat-x;
  37. }
  38. #editTable {
  39. }
  40. table, th, td
  41. {
  42. border: 1px solid #ccc;
  43. }
  44. #editTable td {
  45. vertical-align:top;
  46. }
  47. #filesCell div {
  48. height:30em;
  49. overflow-y: auto;
  50. }
  51. #editCell {
  52. width:80%;
  53. }
  54. #editCell textarea {
  55. width:100%;
  56. height: 30em;
  57. }
  58. li:nth-child(odd) { background-color:#ddd; }
  59. </style>
  60. </head>
  61. <body>
  62. <h3>SquiLu Web App Server</h3>
  63. <form method="post">
  64. <table id="editTable">
  65. <tr><td id="filesCell">
  66. <div>
  67. <h4>Files</h4>
  68. <ol>
  69. <? foreach( k,v in files) { ?>
  70. <li><a href="?file=<?=v?>"><?=v?></a></li>
  71. <? } ?>
  72. </ol>
  73. </div>
  74. </td><td id="editCell">
  75. <input type="submit" name="save" value="Save">
  76. <!--<input type="submit" name="reload" value="Reload">-->
  77. <input type="text" name="file_name" value="<?=file_name?>">
  78. <button type="button" onclick="window.location.href='/SQ/logout';">Logout</button>
  79. <a href="/" target="myweb">View Page</a>
  80. <br>
  81. <textarea name="content" id="code"><?=escapeHtml(content)?></textarea>
  82. <?
  83. function getMode(){
  84. if (!file_name) return "xml";
  85. local ext;
  86. file_name.gmatch("([^.]+)$", function(m) {ext=m; return false;});
  87. if (ext == "css") return "css";
  88. else if (ext == "js") return "javascript";
  89. else if (ext == "nut") return "javascript";
  90. else if (ext == "tpl") return "application/x-ejs";
  91. else if (ext == "html") return "text/html";
  92. return "xml";
  93. }
  94. ?>
  95. <p><input type="text" value="<?=getMode()?>" id="mode">
  96. <button type="button" onclick="change()">change mode</button></p>
  97. </td></tr>
  98. </table>
  99. </form>
  100. <script>
  101. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  102. tabMode: "indent",
  103. matchBrackets: true,
  104. indentWithTabs: true,
  105. lineNumbers: true,
  106. extraKeys: {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }},
  107. foldGutter: {
  108. rangeFinder: new CodeMirror.fold.combine(CodeMirror.fold.brace, CodeMirror.fold.comment)
  109. },
  110. gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
  111. highlightSelectionMatches: {showToken: /\w/},
  112. mode: "<?=getMode()?>"
  113. });
  114. var modeInput = document.getElementById("mode");
  115. CodeMirror.connect(modeInput, "keypress", function(e) {
  116. if (e.keyCode == 13) change();
  117. });
  118. function change() {
  119. editor.setOption("mode", modeInput.value);
  120. }
  121. </script>
  122. </body>
  123. </html>