summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruser@node5.net <user@node5.net>2026-07-10 14:09:43 +0200
committeruser@node5.net <user@node5.net>2026-07-10 14:54:29 +0200
commitf51cbd438a07538d51bb017e77eb76c64787692b (patch)
treee7d0dfe6d9d032d9a164b4ee4f0f7fbbc633d113 /src
parentf5e3a880cd74ebc0101d8510ec3b1996859057a1 (diff)
update - handle errorsHEADmaster
retain content, log what happened, show indicator in bar
Diffstat (limited to 'src')
-rw-r--r--src/static/main.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/static/main.js b/src/static/main.js
index 45b7f9b..0900c41 100644
--- a/src/static/main.js
+++ b/src/static/main.js
@@ -1,9 +1,23 @@
+topE = document.querySelector("#top");
+programE = document.querySelector("#program");
+
async function update() {
- const html = await (await fetch("/update")).text();
- document.querySelector("#top").innerHTML = html.split("\n").slice(0, 1)[0];
- document.querySelector("#program").outerHTML = html.split("\n").slice(1).join("\n");
+ try {
+ const response = await fetch("/update");
+ if (response.status == 200) {
+ html = await response.text();
+ topE.innerHTML = html.split("\n").slice(0, 1)[0];
+ programE.outerHTML = html.split("\n").slice(1).join("\n");
+ }
+ } catch (err) {
+ // Happens when the server is closed / unreachable
+ if (!topE.textContent.endsWith("❗")) {
+ topE.textContent = (topE.textContent.slice(0, -1) || topE.textContent) + "❗";
+ }
+ console.log("Fetch failed:", err);
+ }
}
setInterval(() => {
- update()
+ update()
}, 5000);