openfile.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. {include file="public/frame_head" /}
  5. <link href="{__PLUG_PATH}codemirror/lib/codemirror.css" rel="stylesheet">
  6. <link href="{__PLUG_PATH}codemirror/theme/monokai.css" rel="stylesheet">
  7. <script src="{__PLUG_PATH}codemirror/lib/codemirror.js"></script>
  8. <script src="{__PLUG_PATH}codemirror/mode/php/php.js"></script>
  9. <script src="{__PLUG_PATH}codemirror/mode/javascript/javascript.js"></script>
  10. <script src="{__PLUG_PATH}codemirror/mode/clike/clike.js"></script>
  11. <script src="{__PLUG_PATH}codemirror/mode/css/css.js"></script>
  12. <script src="{__PLUG_PATH}codemirror/mode/sql/sql.js"></script>
  13. <script src="{__PLUG_PATH}codemirror/mode/htmlmixed/htmlmixed.js"></script>
  14. <script src="{__PLUG_PATH}codemirror/mode/xml/xml.js"></script>
  15. <script src="{__PLUG_PATH}jquery-1.4.1.min.js"></script>
  16. <script>
  17. var $eb = parent._mpApi;
  18. // if(!$eb) top.location.reload();
  19. </script>
  20. <title></title>
  21. <style type="text/css">
  22. .lineblock { display: inline-block; margin: 1px; height: 5px; }
  23. .CodeMirror {border: 1px solid #aaa; height: 700px}
  24. .savestyle{
  25. color: #fff;
  26. background-color: #2d8cf0;
  27. border-color: #2d8cf0;
  28. width: 100px;
  29. padding: 6px 15px 7px 15px;
  30. font-size: 14px;
  31. border-radius: 4px;
  32. margin: 10px auto;
  33. margin-left: 45%;
  34. }
  35. .savestyle:hover{
  36. color: #fff;
  37. background-color: #57a3f3;
  38. border-color: #57a3f3;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <div class="row">
  44. <div class="col-lg-12">
  45. <div class="btn-group p-xxs">
  46. <button type="button" class="btn btn-sm btn-white" id="savefile"><i class="fa fa-save"></i>保存</button>
  47. <button type="button" class="btn btn-sm btn-white" id="undo"><i class="fa fa-undo"></i>撤销</button>
  48. <button type="button" class="btn btn-sm btn-white" id="redo"><i class="fa fa-rotate-right"></i>回退</button>
  49. <button type="button" class="btn btn-sm btn-white" id="refresh"><i class="fa fa-refresh"></i>刷新</button>
  50. <!-- <button type="button" class="btn btn-sm btn-white" id="replaceRange"><i class="fa fa-exchange"></i>刷新</button>-->
  51. </div>
  52. <div class="ibox-content no-padding" >
  53. <form>
  54. <textarea class="form-control" id="code" name="code">{$content}</textarea>
  55. </form>
  56. </div>
  57. </div>
  58. </div>
  59. <script>
  60. var editor = CodeMirror.fromTextArea(document.getElementById("code"), { // 标识到textarea
  61. value : "http://www.crmeb.com", // 文本域默认显示的文本
  62. mode : "{$mode}", // 模式
  63. theme : "monokai", // CSS样式选择
  64. indentUnit : 2, // 缩进单位,默认2
  65. smartIndent : true, // 是否智能缩进
  66. tabSize : 4, // Tab缩进,默认4
  67. readOnly : false, // 是否只读,默认false
  68. showCursorWhenSelecting : true,
  69. lineNumbers : true // 是否显示行号
  70. // .. 还有好多,翻译不完。需要的去看http://codemirror.net/doc/manual.html#config
  71. });
  72. reiframesize();//设置编辑框的尺寸
  73. $("#savefile").click(function(){
  74. $.post("{:Url('savefile')}",{comment:editor.getValue(),filepath:'{$filepath}'},function (res) {
  75. $eb.message('success',res.msg);
  76. },'json');
  77. });
  78. $("#undo").click(function(){
  79. editor.undo();
  80. });
  81. $("#redo").click(function(){
  82. editor.redo();
  83. });
  84. $("#refresh").click(function(){
  85. editor.refresh();
  86. });
  87. // editor.on('keydown', function() {
  88. // editor.showHint(); //满足自动触发自动联想功能
  89. // });
  90. //editor.getValue()//获取经过转义的编辑器文本内容
  91. window.onresize=function(){
  92. reiframesize();
  93. };
  94. function reiframesize(){
  95. var w = document.documentElement.clientWidth+3;
  96. var h = document.documentElement.clientHeight-48;
  97. editor.setSize(w,h);
  98. }
  99. </script>
  100. </body>
  101. </html>