╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
182 // input/focus events from form elements still bubble up to document. 183 document.addEventListener("input", (event) => { 184 const t = event.target; 185 if (!t || t.tagName !== "INPUT" || !t.dataset.focusId) return; 186 sendTextInputValue(Number(t.dataset.focusId), t.value); 187 }); 188 189 document.addEventListener("focusin", (event) => { 190 const t = event.target; 191 if (!t || !t.dataset || !t.dataset.focusId) return; 192 // sync the wasm focus to wherever the browser moved focus 193 wasmInstance.exports._setFocus(Number(t.dataset.focusId)); 194 // a click's mousedown fires this focusin before the click event. ticking 195 // here would rebuild #grid and destroy the node before its click lands, 196 // swallowing the navigation and forcing a second click — so don't 197 // re-render for a grid element. overlay controls live outside #grid and 198 // survive the diff, so they still tick. 199 if (!grid.contains(t)) wasmInstance.exports._tick(minRows(), maxCols()); 200 }); 201 202 grid.addEventListener("click", (event) => { 203 const span = event.target.closest(".clickable"); 204 if (!span) return; 205 const focusId = Number(span.dataset.focusId); 206 wasmInstance.exports._onMouseClick(focusId); 207 wasmInstance.exports._tick(minRows(), maxCols()); 208 }); 209 210 let resizeTimer = null; 211 window.addEventListener("resize", () => { 212 clearTimeout(resizeTimer); 213 resizeTimer = setTimeout(() => { 214 wasmInstance.exports._tick(minRows(), maxCols()); 215 }, 100); 216 }); 217 }); 218