aboutsummaryrefslogtreecommitdiff
path: root/site
diff options
context:
space:
mode:
authorstuebinm2022-09-11 13:07:02 +0200
committerstuebinm2022-09-11 13:07:02 +0200
commit46a24c8a90d4e6e794a2c6ed79da94e02e2c7eab (patch)
tree3fd4dac9910d58034a0d3a487a30fa2453dfc4a1 /site
parent9cb73aa181a8e28aea2268b8fdfd65332710a9fe (diff)
on-board-unit: display estimated delay etc.
Diffstat (limited to 'site')
-rw-r--r--site/obu.hamlet15
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();
}