(() => { const el = document.getElementById("counter"), note = document.getElementById("counter-note"); if (!el) return; const es = new EventSource("/rc/sub/counter/main"); es.onmessage = (m) => { const j = JSON.parse(m.data); el.textContent = j.n; }; es.onerror = () => { note.textContent = "Lost the live connection; retrying…"; }; es.onopen = () => { note.textContent = "Live. Open this page in another tab and press in one."; }; document.getElementById("press").addEventListener("click", () => zoo.call("/api/10/press", {})); })();