╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
407 document.addEventListener("input", (event) => { 408 const t = event.target; 409 if (!t || (t.tagName !== "INPUT" && t.tagName !== "TEXTAREA") || !t.dataset.focusId) return; 410 sendTextInputValue(Number(t.dataset.focusId), t.value); 411 }); 412 413 document.addEventListener("focusin", (event) => { 414 const t = event.target; 415 if (!t || !t.dataset || !t.dataset.focusId) return; 416 // sync the wasm focus to wherever the browser moved focus 417 wasmInstance.exports._setFocus(Number(t.dataset.focusId)); 418 // keyed controls survive a redraw before click. cell links live in the 419 // replaceable backdrop, so their click handler redraws after activation. 420 if (nodeKey(t)?.startsWith("control:")) wasmInstance.exports._tick(minRows(), maxCols()); 421 }); 422 423 grid.addEventListener("click", (event) => { 424 if (event.target.matches("input[readonly]")) { 425 wasmInstance.exports._tick(minRows(), maxCols()); 426 return; 427 } 428 const span = event.target.closest(".clickable"); 429 if (!span) return; 430 // leave modified / non-left clicks (open-in-new-tab, etc.) to the browser 431 if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; 432 // wasm routes the click: an in-page link updates focus and re-renders, 433 // a cross-page one calls _navigate. suppress the <a>'s own navigation so 434 // an in-page link doesn't also trigger a redundant full page load. 435 event.preventDefault(); 436 const focusId = Number(span.dataset.focusId); 437 wasmInstance.exports._onMouseClick(focusId); 438 wasmInstance.exports._tick(minRows(), maxCols()); 439 }); 440 441 let resizeTimer = null; 442 window.addEventListener("resize", () => { 443 clearTimeout(resizeTimer); 444 resizeTimer = setTimeout(() => { 445 wasmInstance.exports._tick(minRows(), maxCols()); 446 }, 100); 447 }); 448 }); 449