diff options
| author | tv <tv@krebsco.de> | 2026-11-01 20:15:29 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 20:15:29 +0100 |
| commit | 246133cbd44412cd4571bef599a6023d52bc8bad (patch) | |
| tree | 95096a105f7b1097d188684512d6e45ee714cc77 | |
| parent | fc4f3398c3029b1b77903095b81223f7c4705c90 (diff) | |
dashboard: 24h-clock
| -rw-r--r-- | src/api/dashboard/dashboard.html | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html index 6a365a8..f31808d 100644 --- a/src/api/dashboard/dashboard.html +++ b/src/api/dashboard/dashboard.html @@ -1701,6 +1701,9 @@ function trafficArrived() { // every update (the same counts as the map's messages), the latest at the bottom, // `CONSOLE_LINES` at most. Scrolled along while at the bottom. --- const CONSOLE_LINES = 200; +// A time of day on the 24-hour clock, whatever the browser's locale: 18:04:05. +const clockTime = date => [date.getHours(), date.getMinutes(), date.getSeconds()] + .map(part => String(part).padStart(2, "0")).join(":"); const size = bytes => bytes < 1024 ? bytes + " B" : bytes < 1048576 ? (bytes / 1024).toFixed(1) + " KiB" : (bytes / 1048576).toFixed(1) + " MiB"; // The lines, kept while the box is collapsed and drawn when it's opened (`showConsole`). @@ -1716,7 +1719,7 @@ function consoleLine([when, text, kinds]) { } function logTraffic(way, peer, total, kinds) { const bytes = Object.values(kinds).reduce((sum, grown) => sum + grown.bytes, 0); - const line = [new Date().toLocaleTimeString(), + const line = [clockTime(new Date()), (way === "sent" ? "→ " : "← ") + name(peer) + ": " + total + ", " + size(bytes), Object.entries(kinds).map(([kind, grown]) => [kind, grown.messages])]; consoleLines.push(line); |
