console.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <div id="main" class="flex-fill flex-vbox" style="max-height:100%">
  2. <div class="header">
  3. <h1>Microcontroller Console</h1>
  4. </div>
  5. <div class="content flex-fill flex-vbox">
  6. <p>
  7. <a id="reset-button" class="pure-button button-primary" href="#">Reset &#xb5;C</a>
  8. &nbsp; <a id="clear-button" class="pure-button button-primary" href="#">Clear Log</a>
  9. &nbsp; Baud:
  10. <select id="baud-sel" class="pure-button" href="#">
  11. <option value="460800">460800</option>
  12. <option value="250000">250000</option>
  13. <option value="230400">230400</option>
  14. <option value="115200">115200</option>
  15. <option value="57600">57600</option>
  16. <option value="38400">38400</option>
  17. <option value="19200">19200</option>
  18. <option value="9600">9600</option>
  19. <option value="4800">4800</option>
  20. <option value="2400">2400</option>
  21. <option value="1200">1200</option>
  22. <option value="600">600</option>
  23. <option value="300">300</option>
  24. </select>
  25. &nbsp; Fmt:
  26. <select id="fmt-sel" class="pure-button" href="#">
  27. <option value="8N1">8N1</option>
  28. <option value="8E1">8E1</option>
  29. <option value="8N2">8N2</option>
  30. <option value="8E2">8E2</option>
  31. <option value="7N1">7N1</option>
  32. <option value="7E1">7E1</option>
  33. <option value="7N2">7N2</option>
  34. <option value="7E2">7E2</option>
  35. </select>
  36. </p>
  37. <div class="pure-g">
  38. <div class="pure-u-1-4"><legend><b>Console</b></legend></div>
  39. <div class="pure-u-3-4"></div>
  40. </div>
  41. <pre class="console flex-fill" id="console">--- No Content ---</pre>
  42. <div>
  43. <div class="pure-g">
  44. <div class="pure-u-1-4"><legend><b>Console entry</b></legend></div>
  45. <div class="pure-u-2-4">
  46. <legend>(ENTER to submit, ESC to clear)</legend>
  47. </div>
  48. <div class="pure-u-1-4">
  49. <legend>Add:
  50. <input type="checkbox" id="input-add-cr" checked class="inline"><label>CR(\r)</label>
  51. <input type="checkbox" id="input-add-lf" checked class="inline"><label>LF(\n)</label>
  52. </legend>
  53. </div>
  54. </div>
  55. <div class="pure-g">
  56. <div class="pure-u-1-1">
  57. <span style="float:right; width:10px;"></span>
  58. <input type="text" class="console-in" id="input-text" value="">
  59. </div>
  60. </div>
  61. <div class="pure-g">
  62. <div class="pure-u-1-4"><legend><b>History buffer</b></legend></div>
  63. <div class="pure-u-2-4"><legend>(UP/DOWN arrows to select)</legend></div>
  64. <div class="pure-u-1-4"></div>
  65. </div>
  66. <div class="pure-g">
  67. <div class="pure-u-1-1"><select class="console-in" id="send-history" size="5"></select></div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <script type="text/javascript">console_url = "/console/text"</script>
  74. <script src="console.js"></script>
  75. <script type="text/javascript">
  76. onLoad(function() {
  77. fetchText(100, true);
  78. $("#reset-button").addEventListener("click", function(e) {
  79. e.preventDefault();
  80. var co = $("#console");
  81. co.innerHTML = "";
  82. ajaxSpin('POST', "/console/reset",
  83. function(resp) { showNotification("uC reset"); co.textEnd = 0; },
  84. function(s, st) { showWarning("Error resetting uC"); }
  85. );
  86. });
  87. $("#clear-button").addEventListener("click", function(e) {
  88. e.preventDefault();
  89. var co = $("#console");
  90. co.innerHTML = "";
  91. });
  92. ajaxJson('GET', "/console/baud",
  93. function(data) { $("#baud-sel").value = data.rate; },
  94. function(s, st) { showNotification(st); }
  95. );
  96. bnd($("#baud-sel"), "change", function(ev) {
  97. ev.preventDefault();
  98. var baud = $("#baud-sel").value;
  99. ajaxSpin('POST', "/console/baud?rate="+baud,
  100. function(resp) { showNotification("" + baud + " baud set"); },
  101. function(s, st) { showWarning("Error setting baud rate: " + st); }
  102. );
  103. });
  104. ajaxJson('GET', "/console/fmt",
  105. function(data) { $("#fmt-sel").value = data.fmt; },
  106. function(s, st) { showNotification(st); }
  107. );
  108. bnd($("#fmt-sel"), "change", function(ev) {
  109. ev.preventDefault();
  110. var fmt = $("#fmt-sel").value;
  111. ajaxSpin('POST', "/console/fmt?fmt="+fmt,
  112. function(resp) { showNotification("" + fmt + " format set"); },
  113. function(s, st) { showWarning("Error setting format: " + st); }
  114. );
  115. });
  116. consoleSendInit();
  117. addClass($('html')[0], "height100");
  118. addClass($('body')[0], "height100");
  119. addClass($('#layout'), "height100");
  120. addClass($('#layout'), "flex-vbox");
  121. });
  122. </script>
  123. </body></html>