Skip to content

Commit b6510a3

Browse files
committed
Add click-to-select data entry, with undo/rollback support
1 parent 3851239 commit b6510a3

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

‎wdl/index.html‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,16 @@
324324
padding: 9px 12px;
325325
border-radius: 9px;
326326
background: var(--surface);
327+
cursor: pointer;
328+
-webkit-tap-highlight-color: transparent;
329+
transition: background 0.1s;
327330
}
331+
.word-item:active { background: var(--surface2); }
328332
.word-item.top-item {
329333
background: var(--surface2);
330334
border: 1px solid var(--border);
331335
}
336+
.word-item.top-item:active { background: var(--border); }
332337
.word-rank {
333338
font-family: 'IBM Plex Mono', monospace;
334339
font-size: 11px;
@@ -677,8 +682,20 @@ <h1>wdl·filter</h1>
677682
}
678683

679684
// ─────────────────────────────────────────────
680-
// RENDER
685+
// FILL WORD FROM RESULTS LIST
681686
// ─────────────────────────────────────────────
687+
function fillWord(word) {
688+
currentWord = word;
689+
tileStates = ['_','_','_','_','_'];
690+
const inp = document.getElementById('word-input');
691+
inp.value = word;
692+
renderTiles();
693+
// Scroll input into view on mobile
694+
inp.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
695+
inp.focus();
696+
}
697+
698+
682699
function renderAll() {
683700
renderTiles();
684701
renderGuesses();
@@ -770,7 +787,7 @@ <h1>wdl·filter</h1>
770787
if (guesses.length === 0) {
771788
section.innerHTML = `
772789
<div class="empty-state">
773-
<p>Type a word, tap the tiles to set each letter's result,<br>then press <strong>Add guess</strong>.</p>
790+
<p>Type a word, tap the tiles to set each letter's result,<br>then press <strong>Add guess</strong>.<br><br>Tap any word in the results list to fill it in automatically.</p>
774791
</div>`;
775792
return;
776793
}
@@ -819,6 +836,7 @@ <h1>wdl·filter</h1>
819836
? '<span class="no-data">no data</span>'
820837
: freq.toFixed(4)}</div>
821838
</div>`;
839+
item.addEventListener('click', () => fillWord(word));
822840
listEl.appendChild(item);
823841
});
824842

@@ -910,4 +928,3 @@ <h1>wdl·filter</h1>
910928
</script>
911929
</body>
912930
</html>
913-

0 commit comments

Comments
 (0)