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