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. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8. <title>CarBot</title>
  9. <link rel="stylesheet" href="css/bootstrap.min.css">
  10. <style type="text/css" media="screen">
  11. body {
  12. overflow: hidden;
  13. }
  14. #editor {
  15. height: 300px;
  16. width: 100%;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div class="container-fluid">
  22. <div class="row">
  23. <div class="col-md-12">
  24. <div class="row">
  25. <div class="col-md-12">
  26. </div>
  27. </div>
  28. <div class="row">
  29. <div class="col-md-6">
  30. <div id="editor"></div>
  31. </div>
  32. <div class="col-md-6">
  33. <div id="card-544879">
  34. <div class="card">
  35. <div class="card-header">
  36. <a class="card-link" data-toggle="collapse" data-parent="#card-544879" href="#card-element-858398">Snippet 1</a>
  37. </div>
  38. <div id="card-element-858398" class="collapse show">
  39. <div class="card-body">
  40. <div class="jumbotron">
  41. <h2>
  42. Snippet 1
  43. </h2>
  44. <p>
  45. Some python code
  46. </p>
  47. <p>
  48. <a class="btn btn-primary btn-large" href="#">Load</a>
  49. </p>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="card">
  55. <div class="card-header">
  56. <a class="collapsed card-link" data-toggle="collapse" data-parent="#card-544879" href="#card-element-291021">Snippet 2</a>
  57. </div>
  58. <div id="card-element-291021" class="collapse">
  59. <div class="card-body">
  60. <div class="jumbotron">
  61. <h2>
  62. Snippet 1
  63. </h2>
  64. <p>
  65. Some python code
  66. </p>
  67. <p>
  68. <a class="btn btn-primary btn-large" href="#">Load</a>
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="row">
  78. <div class="col-md-12">
  79. <p id="results" class="text-info">
  80. </p>
  81. </div>
  82. </div>
  83. <div class="row">
  84. <div class="col-md-4">
  85. <button type="button" class="btn btn-success btn-lg" id="run">Run</button>
  86. </div>
  87. <div class="col-md-4">
  88. </div>
  89. <div class="col-md-4">
  90. <address>
  91. <strong>Eran Goldman-Malka</strong><br /> erangoldman@gmail.com
  92. </address>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <script src="js/jquery-3.3.1.min.js"></script>
  99. <script src="js/bootstrap.min.js"></script>
  100. <script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
  101. <script src="js/ext-language_tools.js"></script>
  102. <script>
  103. ace.require("ace/ext/language_tools");
  104. var editor = ace.edit("editor");
  105. editor.session.setMode("ace/mode/python");
  106. editor.setTheme("ace/theme/dracula");
  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>