index.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. <samp>
  45. import RPi.GPIO as GPIO
  46. import time
  47. GPIO.setmode(GPIO.BCM)
  48. GPIO.setup(20, GPIO.OUT)
  49. GPIO.output(20,1)
  50. GPIO.setup(21, GPIO.OUT)
  51. GPIO.output(21,1)
  52. GPIO.setup(8, GPIO.OUT)
  53. GPIO.output(8,1)
  54. GPIO.setup(7, GPIO.OUT)
  55. GPIO.output(7,1)
  56. </samp>
  57. <p>
  58. <a class="btn btn-primary btn-large" onclick="(function(){alert(this);})()">Load</a>
  59. </p>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="card">
  65. <div class="card-header">
  66. <a class="collapsed card-link" data-toggle="collapse" data-parent="#card-544879" href="#card-element-291021">Snippet 2</a>
  67. </div>
  68. <div id="card-element-291021" class="collapse">
  69. <div class="card-body">
  70. <div class="jumbotron">
  71. <h2>
  72. Snippet 1
  73. </h2>
  74. <p>
  75. Some python code
  76. </p>
  77. <p>
  78. <a class="btn btn-primary btn-large" href="#">Load</a>
  79. </p>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="row">
  88. <div class="col-md-12">
  89. <p id="results" class="text-info">
  90. </p>
  91. </div>
  92. </div>
  93. <div class="row">
  94. <div class="col-md-4">
  95. <button type="button" class="btn btn-success btn-lg" id="run">Run</button>
  96. </div>
  97. <div class="col-md-4">
  98. </div>
  99. <div class="col-md-4">
  100. <address>
  101. <strong>Eran Goldman-Malka</strong><br /> erangoldman@gmail.com
  102. </address>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <script src="js/jquery-3.3.1.min.js"></script>
  109. <script src="js/bootstrap.min.js"></script>
  110. <script src="js/ace.js" type="text/javascript" charset="utf-8"></script>
  111. <script src="js/ext-language_tools.js"></script>
  112. <script>
  113. ace.require("ace/ext/language_tools");
  114. var editor = ace.edit("editor");
  115. editor.session.setMode("ace/mode/python");
  116. editor.setTheme("ace/theme/dracula");
  117. editor.setOptions({
  118. enableBasicAutocompletion: true,
  119. enableSnippets: true,
  120. enableLiveAutocompletion: false
  121. });
  122. var ws = new WebSocket('ws://'+window.location.host+':8080/');
  123. ws.onopen = function(event) {
  124. console.log("open ws connection");
  125. console.log(event.data);
  126. };
  127. ws.onclose = function() {
  128. console.log("close ws connection");
  129. };
  130. ws.onmessage = function(event) {
  131. $("#results").append(event.data)
  132. console.log("Got data :");
  133. console.log(event.data);
  134. };
  135. $("#run").click(function(){
  136. ws.send(editor.session.getValue())
  137. ws.send('go')
  138. $("#results").html("")
  139. })
  140. </script>
  141. </body>
  142. </html>