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 | f12c3a1b5b0fbb7459b50739a46b92a9de9445cb (patch) | |
| tree | 321095564aa31a7f01ac836e7457a1426ebed3e1 /src/api/dashboard/dashboard.html | |
| parent | 8b8ed72a91a211092fd2d0c2e2797dbde0b55a04 (diff) | |
dashboard: 24h-clock
Diffstat (limited to 'src/api/dashboard/dashboard.html')
| -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); |
