index.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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-md-12">
  22. <div class="row">
  23. <div class="col-md-12">
  24. </div>
  25. </div>
  26. <div class="row">
  27. <div class="col-md-6">
  28. <div id="editor"></div>
  29. </div>
  30. <div class="col-md-6">
  31. <div id="card-544879">
  32. <div class="card">
  33. <div class="card-header">
  34. <a class="card-link" data-toggle="collapse" data-parent="#card-544879" href="#card-element-858398">Snippet 1</a>
  35. </div>
  36. <div id="card-element-858398" class="collapse show">
  37. <div class="card-body">
  38. <div class="jumbotron">
  39. <h2>
  40. Snippet 1
  41. </h2>
  42. <p>
  43. Some python code
  44. </p>
  45. <p>
  46. <a class="btn btn-primary btn-large" href="#">Load</a>
  47. </p>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="card">
  53. <div class="card-header">
  54. <a class="collapsed card-link" data-toggle="collapse" data-parent="#card-544879" href="#card-element-291021">Snippet 2</a>
  55. </div>
  56. <div id="card-element-291021" class="collapse">
  57. <div class="card-body">
  58. <div class="jumbotron">
  59. <h2>
  60. Snippet 1
  61. </h2>
  62. <p>
  63. Some python code
  64. </p>
  65. <p>
  66. <a class="btn btn-primary btn-large" href="#">Load</a>
  67. </p>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <div class="row">
  76. <div class="col-md-12">
  77. <p id="results" class="text-info">
  78. </p>
  79. </div>
  80. </div>
  81. <div class="row">
  82. <div class="col-md-4">
  83. <button type="button" class="btn btn-success btn-lg" id="run">Run</button>
  84. </div>
  85. <div class="col-md-4">
  86. </div>
  87. <div class="col-md-4">
  88. <address>
  89. <strong>Eran Goldman-Malka</strong><br /> erangoldman@gmail.com
  90. </address>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. <script src="js/jquery-3.3.1.min.js"></script>
  97. <script src="js/bootstrap.bundle.min.js"></script>
  98. <script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
  99. <script src="js/ext-language_tools.js"></script>
  100. <script>
  101. // trigger extension
  102. ace.require("ace/ext/language_tools");
  103. var editor = ace.edit("editor");
  104. editor.session.setMode("ace/mode/python");
  105. editor.setTheme("ace/theme/dracula");
  106. // enable autocompletion and snippets
  107. editor.setOptions({
  108. enableBasicAutocompletion: true,
  109. enableSnippets: true,
  110. enableLiveAutocompletion: false
  111. });
  112. var ws = new WebSocket('ws://'+window.location.host+':8080/');
  113. ws.onopen = function(event) {
  114. console.log("open ws connection");
  115. console.log(event.data);
  116. };
  117. ws.onclose = function() {
  118. console.log("close ws connection");
  119. };
  120. ws.onmessage = function(event) {
  121. $("#results").append(event.data)
  122. console.log("Got data :");
  123. console.log(event.data);
  124. };
  125. $("#run").click(function(){
  126. ws.send(editor.session.getValue())
  127. ws.send('go')
  128. $("#results").html("")
  129. })
  130. </script>
  131. </body>
  132. </html>