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