// animation speeds cause why not const TYPING_SPEED = 60; const ERASE_SPEED = 80; const STATUS_UPDATE_INTERVAL = 60000; // 1min updates const TIME_UPDATE_INTERVAL = 1; // 1ms updates (yeah its bad) // status warning stuff const LATENCY_WARNING_THRESHOLD = 500000; // lazy group name mapping const GROUP_NAMES = { 4: "INFRASTRUCTURE", 5: "SERVICES", 6: "API", }; // does the fancy typing animation for nav labels // its way overcomplicated but whatever function writeoutnavlabel(label) { if (label.getAttribute("data-animating") === "true") return; const text = label.getAttribute("data-text") || label.textContent; label.setAttribute("data-text", text); label.textContent = ""; label.style.opacity = "1"; label.setAttribute("data-animating", "true"); let i = 0; let animationInterval = setInterval(() => { if (i < text.length) { label.textContent += text.charAt(i); i++; } else { clearInterval(animationInterval); label.setAttribute("data-animating", "false"); const icon = label.closest(".nav-icon"); if (icon) { icon.isAnimating = false; icon.hoverAnimationDone = true; } } }, TYPING_SPEED); label.setAttribute("data-animation-interval", animationInterval); } // erases the nav labels // just as terrible as the typing but matches function eraselabel(label) { if (label.getAttribute("data-animating") === "true") { const existingInterval = label.getAttribute("data-animation-interval"); if (existingInterval) clearInterval(existingInterval); } label.setAttribute("data-animating", "true"); let eraseInterval = setInterval(() => { const currentText = label.textContent; if (currentText.length > 0) { label.textContent = currentText.slice(0, -1); } else { clearInterval(eraseInterval); label.setAttribute("data-animating", "false"); label.style.opacity = "0"; } }, ERASE_SPEED); label.setAttribute("data-animation-interval", eraseInterval); } // we get the client info from the headers // unclean but it works function updateClientInfo() { const locationElement = document.querySelector(".location"); if (!locationElement) { console.warn("Location element not found in DOM"); return; } 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(); requestAnimationFrame(() => { locationElement.textContent = cleanClientInfo; locationElement.classList.remove("loading"); locationElement.classList.add("loaded"); }); }) .catch((error) => { console.error("Failed to update client info:", error); requestAnimationFrame(() => { locationElement.textContent = "CLIENT INFO UNAVAILABLE"; locationElement.classList.remove("loading"); locationElement.classList.add("loaded", "error"); }); }); } // updates the time display // probably updates too much but eh function updateTime() { const now = new Date(); const timeString = now .toLocaleString("en-US", { month: "2-digit", day: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit", fractionalSecondDigits: 3, hour12: true, }) .toUpperCase(); document.getElementById("current-time").textContent = timeString; } // bunch of status helper functions for formatting and stuff function calculateAverageUptime(services) { if (!services || services.length === 0) return 0; const totalUptime = services.reduce( (sum, service) => sum + service.online_24_hours, 0, ); return (totalUptime / services.length).toFixed(2); } function formatLatency(latency) { return (Math.round((latency / 1000) * 10) / 10).toFixed(1); } function formatUptime(uptime) { return uptime.toFixed(2); } function getStatusClass(service) { if (!service.online) return "status-offline"; if (service.latency > LATENCY_WARNING_THRESHOLD) return "status-warning"; return "status-online"; } function getGroupName(groupId) { return GROUP_NAMES[groupId] || `GROUP ${groupId}`; } // builds all the html for status page // groups everything by group_id cause organization function createStatusHTML(services) { const groups = services.reduce((acc, service) => { const groupId = service.group_id; if (!acc[groupId]) acc[groupId] = []; acc[groupId].push(service); return acc; }, {}); return Object.entries(groups) .map( ([groupId, groupServices]) => `