╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
234 document.addEventListener("focusin", (event) => { 235 const t = event.target; 236 if (!t || !t.dataset || !t.dataset.focusId) return; 237 // sync the wasm focus to wherever the browser moved focus 238 wasmInstance.exports._setFocus(Number(t.dataset.focusId)); 239 // a click's mousedown fires this focusin before the click event. ticking 240 // here would rebuild #grid and destroy the node before its click lands, 241 // swallowing the navigation and forcing a second click — so don't 242 // re-render for a grid element. overlay controls live outside #grid and 243 // survive the diff, so they still tick. 244 if (!grid.contains(t)) wasmInstance.exports._tick(minRows(), maxCols()); 245 }); 246 247 grid.addEventListener("click", (event) => { 248 const span = event.target.closest(".clickable"); 249 if (!span) return; 250 // leave modified / non-left clicks (open-in-new-tab, etc.) to the browser 251 if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; 252 // wasm routes the click: an in-page link just moves focus and re-renders, 253 // a cross-page one calls _navigate. suppress the <a>'s own navigation so 254 // an in-page link doesn't also trigger a redundant full page load. 255 event.preventDefault(); 256 const focusId = Number(span.dataset.focusId); 257 wasmInstance.exports._onMouseClick(focusId); 258 wasmInstance.exports._tick(minRows(), maxCols()); 259 }); 260 261 let resizeTimer = null; 262 window.addEventListener("resize", () => { 263 clearTimeout(resizeTimer); 264 resizeTimer = setTimeout(() => { 265 wasmInstance.exports._tick(minRows(), maxCols()); 266 }, 100); 267 }); 268 }); 269