╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
211 // sync the wasm focus to wherever the browser moved focus 212 wasmInstance.exports._setFocus(Number(t.dataset.focusId)); 213 // a click's mousedown fires this focusin before the click event. ticking 214 // here would rebuild #grid and destroy the node before its click lands, 215 // swallowing the navigation and forcing a second click — so don't 216 // re-render for a grid element. overlay controls live outside #grid and 217 // survive the diff, so they still tick. 218 if (!grid.contains(t)) wasmInstance.exports._tick(minRows(), maxCols()); 219 }); 220 221 grid.addEventListener("click", (event) => { 222 const span = event.target.closest(".clickable"); 223 if (!span) return; 224 // leave modified / non-left clicks (open-in-new-tab, etc.) to the browser 225 if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; 226 // wasm routes the click: an in-page link just moves focus and re-renders, 227 // a cross-page one calls _navigate. suppress the <a>'s own navigation so 228 // an in-page link doesn't also trigger a redundant full page load. 229 event.preventDefault(); 230 const focusId = Number(span.dataset.focusId); 231 wasmInstance.exports._onMouseClick(focusId); 232 wasmInstance.exports._tick(minRows(), maxCols()); 233 }); 234 235 let resizeTimer = null; 236 window.addEventListener("resize", () => { 237 clearTimeout(resizeTimer); 238 resizeTimer = setTimeout(() => { 239 wasmInstance.exports._tick(minRows(), maxCols()); 240 }, 100); 241 }); 242 }); 243