╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ script.js ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
139 if (tag === "INPUT" && (event.key === "ArrowUp" || event.key === "ArrowDown")) { 140 // up/down moves between widgets; left/right stay in the input 141 document.activeElement.blur(); 142 } else if (tag === "BUTTON" && isArrow) { 143 // arrows navigate away from a focused submit button 144 document.activeElement.blur(); 145 } else if (tag === "INPUT" || tag === "BUTTON") { 146 // Enter (submit), typing, Tab — handled natively by the browser 147 return; 148 } 149 } 150 if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown", "Home", "End"].includes(event.key)) { 151 event.preventDefault(); 152 } 153 wasmInstance.exports._onKeyDown(event.keyCode); 154 wasmInstance.exports._tick(minRows(), maxCols()); 155 }); 156 157 // listeners on document (not #grid) since the form lives outside #grid; 158 // input/focus events from form elements still bubble up to document. 159 document.addEventListener("input", (event) => { 160 const t = event.target; 161 if (!t || t.tagName !== "INPUT" || !t.dataset.focusId) return; 162 sendTextInputValue(Number(t.dataset.focusId), t.value); 163 }); 164 165 document.addEventListener("focusin", (event) => { 166 const t = event.target; 167 if (!t || !t.dataset || !t.dataset.focusId) return; 168 wasmInstance.exports._onMouseClick(Number(t.dataset.focusId)); 169 wasmInstance.exports._tick(minRows(), maxCols()); 170 }); 171 172 grid.addEventListener("click", (event) => { 173 const span = event.target.closest(".clickable"); 174 if (!span) return; 175 const focusId = Number(span.dataset.focusId); 176 wasmInstance.exports._onMouseClick(focusId); 177 wasmInstance.exports._tick(minRows(), maxCols()); 178 }); 179 180 let resizeTimer = null; 181 window.addEventListener("resize", () => { 182 clearTimeout(resizeTimer); 183 resizeTimer = setTimeout(() => { 184 wasmInstance.exports._tick(minRows(), maxCols()); 185 }, 100); 186 }); 187 }); 188