(() => { const today = document.getElementById("spent-today"); if (!today) return; const n = (x) => x.toLocaleString("en"); const read = async () => { const j = await zoo.call("/api/15/usage"); if (j.error) { today.textContent = j.error; return; } today.textContent = n(j.today); document.getElementById("spent-week").textContent = n(j.week); const by = Object.entries(j.apps || {}).map(([a, r]) => a + " " + n(r.today) + " today, " + n(r.week) + " this week").join("; "); document.getElementById("spent-by").textContent = by ? "By app: " + by : "Nothing spent this week."; }; read(); document.getElementById("spent-refresh").addEventListener("click", read); window.addEventListener("zoo-asked", read); // exhibit 14 just asked: re-read, the number rises })();