diff options
Diffstat (limited to 'site')
-rw-r--r-- | site/obu.hamlet | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/site/obu.hamlet b/site/obu.hamlet index 9aec4c0..7068014 100644 --- a/site/obu.hamlet +++ b/site/obu.hamlet @@ -10,6 +10,11 @@ <p><strong>Accuracy: </strong><span id="acc"> <section> + <h2>_{MsgEstimated} + <p><strong>_{MsgDelay}</strong>: <span id="delay"> + <p><strong>_{MsgSequence}</strong>: <span id="sequence"> + +<section> <h2>Status <p id="status">_{MsgNone} <p id>_{MsgError}: <span id="error"> @@ -57,6 +62,14 @@ setTimeout(openWebsocket, 1000); } + function wsMsg(msg) { + let json = JSON.parse(msg.data); + console.log(json); + document.getElementById("delay").innerText = + `${json.delay}s (${Math.floor(json.delay / 60)}min)`; + document.getElementById("sequence").innerText = json.sequence; + } + function initGeopos() { document.getElementById("error").innerText = ""; @@ -72,7 +85,7 @@ ws = new WebSocket((location.protocol == "http:" ? "ws" : "wss") + "://" + location.host + "/api/train/ping/ws"); ws.onerror = wsError; ws.onclose = wsClose; - ws.onmessage = (msg) => console.log(msg.data); // TODO: display delays etc. + ws.onmessage = wsMsg ws.onopen = (event) => initGeopos(); } |