This commit is contained in:
parent
6fde19a991
commit
3c8fe59e8c
@ -77,24 +77,31 @@ function updateClientInfo() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// say we're loading
|
|
||||||
locationElement.classList.add("loading");
|
locationElement.classList.add("loading");
|
||||||
|
|
||||||
fetch(window.location.href)
|
fetch(window.location.href)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const clientInfo = response.headers.get("X-Client-Info");
|
const clientInfo = response.headers.get("X-Client-Info");
|
||||||
|
|
||||||
if (!clientInfo) {
|
if (!clientInfo) {
|
||||||
throw new Error("X-Client-Info header not present");
|
throw new Error("X-Client-Info header not present");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clean up the time value and convert units
|
||||||
const cleanClientInfo = clientInfo
|
const cleanClientInfo = clientInfo
|
||||||
|
// Replace UTF-8 encoded microsecond symbols
|
||||||
.replace(/\u00C2\u00B5s/g, "µs")
|
.replace(/\u00C2\u00B5s/g, "µs")
|
||||||
.replace(/µs/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, "")
|
.replace(/[\u0080-\u00FF]/g, "")
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
// dumb smooth transition lmao
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
locationElement.textContent = cleanClientInfo;
|
locationElement.textContent = cleanClientInfo;
|
||||||
locationElement.classList.remove("loading");
|
locationElement.classList.remove("loading");
|
||||||
|
Loading…
Reference in New Issue
Block a user