From 3c8fe59e8c218c687b0177c05daef9a20babd067 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 5 Nov 2024 01:56:01 +0100 Subject: [PATCH] Fix client info --- assets/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/index.js b/assets/index.js index 798181e..4643474 100644 --- a/assets/index.js +++ b/assets/index.js @@ -77,24 +77,31 @@ function updateClientInfo() { return; } - // say we're loading locationElement.classList.add("loading"); fetch(window.location.href) .then((response) => { const clientInfo = response.headers.get("X-Client-Info"); - if (!clientInfo) { throw new Error("X-Client-Info header not present"); } + // Clean up the time value and convert units const cleanClientInfo = clientInfo + // Replace UTF-8 encoded microsecond symbols .replace(/\u00C2\u00B5s/g, "µs") .replace(/µs/g, "µs") + // Convert microseconds to picoseconds for display + .replace(/(\d+\.?\d*)\s*µs/g, (match, number) => { + const picoseconds = parseFloat(number) * 1000000; + return `${picoseconds.toLocaleString(undefined, { + maximumFractionDigits: 2, + })} ps`; + }) + // Remove any other non-ASCII characters .replace(/[\u0080-\u00FF]/g, "") .trim(); - // dumb smooth transition lmao requestAnimationFrame(() => { locationElement.textContent = cleanClientInfo; locationElement.classList.remove("loading");