summaryrefslogtreecommitdiff
path: root/public/my_uptime.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/my_uptime.js')
-rw-r--r--public/my_uptime.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/public/my_uptime.js b/public/my_uptime.js
new file mode 100644
index 0000000..25f549a
--- /dev/null
+++ b/public/my_uptime.js
@@ -0,0 +1,18 @@
+async function updateUptime() {
+ try {
+ const res = await fetch("/api/my-uptime");
+ if (!res.ok) return;
+ const data = await res.json();
+
+ const text = document.getElementById("Uptime");
+
+ if (text && text.textContent !== data.uptime) {
+ text.textContent = data.uptime;
+ }
+ } catch (e) {}
+}
+
+// Run on page load after all DOM elements loaded
+DOMContentLoaded(updateUptime());
+
+setInterval(updateUptime, 5 * 1000); // in ms