╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
432 document.addEventListener("focusin", (event) => { 433 const t = event.target; 434 if (!t || !t.dataset || !t.dataset.focusId) return; 435 // sync the wasm focus to wherever the browser moved focus 436 wasmInstance.exports._setFocus(Number(t.dataset.focusId)); 437 // keyed controls survive a redraw before click. cell links live in the 438 // replaceable backdrop, so their click handler redraws after activation. 439 if (nodeKey(t)?.startsWith("control:")) wasmInstance.exports._tick(minRows(), maxCols()); 440 }); 441 442 grid.addEventListener("click", (event) => { 443 if (event.target.matches("input[readonly]")) { 444 wasmInstance.exports._tick(minRows(), maxCols()); 445 return; 446 } 447 // a link inside a cell's text opens in a new tab on its own 448 if (event.target.closest("a.cell-link")) return; 449 const span = event.target.closest(".clickable"); 450 if (!span) return; 451 // leave modified / non-left clicks (open-in-new-tab, etc.) to the browser 452 if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; 453 // wasm routes the click: an in-page link updates focus and re-renders, 454 // a cross-page one calls _navigate. suppress the <a>'s own navigation so 455 // an in-page link doesn't also trigger a redundant full page load. 456 event.preventDefault(); 457 const focusId = Number(span.dataset.focusId); 458 wasmInstance.exports._onMouseClick(focusId); 459 wasmInstance.exports._tick(minRows(), maxCols()); 460 }); 461 462 let resizeTimer = null; 463 window.addEventListener("resize", () => { 464 clearTimeout(resizeTimer); 465 resizeTimer = setTimeout(() => { 466 wasmInstance.exports._tick(minRows(), maxCols()); 467 }, 100); 468 }); 469 }); 470