diff --git a/html/console.tpl b/html/console.tpl index b828cce..17d0c13 100644 --- a/html/console.tpl +++ b/html/console.tpl @@ -9,12 +9,12 @@
The Microcontroller console shows the last 1024 characters received from UART0, to which a microcontroller is typically attached.
- Reset µC + Reset µC Baud: - 57600 - 115200 - 230400 - 460800 + 57600 + 115200 + 230400 + 460800
@@ -36,14 +36,14 @@ if(xhr.status !== 200) { //console.log("handleEv error cb"); - errCb(xhr); + if (errCb != null) errCb(xhr); return; } // all is well if(xhr.readyState === 4) { //console.log("handleEv success cb"); - okCb(xhr, JSON.parse(xhr.responseText)); + if (okCb != null) okCb(xhr, JSON.parse(xhr.responseText)); } } catch(e) {return;} } @@ -59,7 +59,7 @@ el.innerHTML = ""; } window.setTimeout(function() { - loadJSON("/console?start=" + el.textEnd, updateText, retryLoad); + loadJSON("/console/text?start=" + el.textEnd, updateText, retryLoad); }, delay); } @@ -87,8 +87,28 @@ fetchText(1000); } + function baudButton(baud) { + document.getElementById(""+baud+"-button").addEventListener("click", function(e) { + console.log("switching to", baud, "baud"); + e.preventDefault(); + loadJSON("/console/baud?rate="+baud); + }); + } + window.onload = function() { fetchText(100); + + document.getElementById("reset-button").addEventListener("click", function(e) { + el = document.getElementById("console"); + e.preventDefault(); + //console.log("reset click"); + el.innerHTML = ""; + loadJSON("/console/reset"); + }); + baudButton(57600); + baudButton(115200); + baudButton(230400); + baudButton(460800); }