// The homepage front end. It reads status.json and services.json once on load // (no auto-refresh, Q41), renders one TUI panel per service for this page's // category, offers the styling toggle (Q27), and shows the last master // deployment datetime (Q43). It never alters the user's cursor (Q28). const CATEGORY = window.location.pathname.indexOf('/admin') !== -1 ? 'admin' : 'user'; function load(url) { return fetch(url, { cache: 'no-store' }).then(function (r) { return r.json(); }); } function esc(s) { return String(s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function renderPanels(services, status) { const stateByName = {}; for (const s of (status.services || [])) stateByName[s.name] = s.state; const grid = document.getElementById('grid'); grid.innerHTML = ''; let up = 0, down = 0, wip = 0; for (const svc of services) { if (svc.category !== CATEGORY) continue; const state = svc.wip ? 'wip' : (stateByName[svc.name] || 'down'); if (state === 'up') up++; else if (state === 'down') down++; else wip++; const panel = document.createElement('div'); panel.className = 'panel ' + state; const links = []; if (svc.showLink && svc.url) links.push('open'); if (svc.docs) links.push('docs'); panel.innerHTML = '