index.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. <title>Editor</title>
  7. <style link rel="stylesheet" href="css/bootstrap.min.css">
  8. <style type="text/css" media="screen">
  9. body {
  10. overflow: hidden;
  11. }
  12. #editor {
  13. height: 300px;
  14. width: 45%;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div class="container-fluid">
  20. <div class="row">
  21. <div class="col-xs-6 col-md-6">
  22. <div id="editor"></div>
  23. </div>
  24. <div class="col-xs-6 col-md-6">
  25. <p> snippets </p>
  26. </div>
  27. </div>
  28. <div class="row">
  29. <div class="col-md-4">
  30. <button id="run" type="button" class="btn btn-success btn-lg">Run</button>
  31. </div>
  32. <div class="col-md-4">
  33. </div>
  34. <div class="col-md-4">
  35. </div>
  36. </div>
  37. </div>
  38. <script src="js/jquery-3.3.1.min.js"></script>
  39. <script src="js/bootstrap.bundle.min.js"></script>
  40. <script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
  41. <script src="js/ext-language_tools.js"></script>
  42. <script>
  43. // trigger extension
  44. ace.require("ace/ext/language_tools");
  45. var editor = ace.edit("editor");
  46. editor.session.setMode("ace/mode/python");
  47. editor.setTheme("ace/theme/dracula");
  48. // enable autocompletion and snippets
  49. editor.setOptions({
  50. enableBasicAutocompletion: true,
  51. enableSnippets: true,
  52. enableLiveAutocompletion: false
  53. });
  54. var ws = new WebSocket('ws://'+window.location.host+':8080/');
  55. ws.onopen = function(event) {
  56. console.log("open ws connection");
  57. console.log(event.data);
  58. };
  59. ws.onclose = function() {
  60. console.log("close ws connection");
  61. };
  62. ws.onmessage = function(event) {
  63. console.log("Got data :");
  64. console.log(event.data);
  65. };
  66. $("#run").click(function(){
  67. ws.send(editor.session.getValue())
  68. ws.send('go')
  69. })
  70. </script>
  71. </body>
  72. </html>