summaryrefslogtreecommitdiff
path: root/web/index.html
diff options
context:
space:
mode:
authorwuhei <wuhei@users.noreply.github.com>2026-11-19 18:36:43 +0100
committerwuhei <wuhei@users.noreply.github.com>2026-11-19 18:36:43 +0100
commitb457d19d9b2c634570300d0f73087e18b4ec4a4a (patch)
tree36e066cbe7abb486cb215ba9ccab6ba1550bb315 /web/index.html
parentf5181ead5b0969fc1806fb714097b17b8d62d53b (diff)
downloadlilchinese-b457d19d9b2c634570300d0f73087e18b4ec4a4a.tar.gz
Enter keeps the sentence: green on screen, appended to a session log
- Enter (kiosk) turns the sentence green and appends it to a Markdown session log, default sessions/session-<timestamp>.md, -log to override. Written lazily, so a run that kept nothing leaves no file. - logs the whole sentence rather than the 9 characters on screen; the snapshot waits 450ms so the model's lookahead has decoded the final syllables - the English in the log is a fresh translation of that sentence, done on a single ordered worker off the audio path, so it never delays recognition - green clears with the next sentence, like the red cut screen - double Enter within 2s does not duplicate a line - tests: keep state, sentence selection, log format and dedupe
Diffstat (limited to 'web/index.html')
-rw-r--r--web/index.html16
1 files changed, 16 insertions, 0 deletions
diff --git a/web/index.html b/web/index.html
index 677fe14..404b367 100644
--- a/web/index.html
+++ b/web/index.html
@@ -46,6 +46,9 @@
/* sentence alternates black-on-white and white-on-black; Backspace = red retake */
body.invert { background: #000; color: #fff; }
body.cut { background: #d10d0d; color: #fff; }
+ /* Enter: the sentence was kept and written to the session log */
+ body.keep { color: #0a7d3a; }
+ body.invert.keep { color: #4ade80; }
@keyframes pop {
from { opacity: .5; transform: scale(.955); }
to { opacity: 1; transform: scale(1); }
@@ -110,6 +113,11 @@
if (reserve) en.textContent = '';
}
+ function keep() {
+ body.classList.add('keep'); // instant feedback, server confirms it
+ fetch('/keep', { method: 'POST', keepalive: true }).catch(function () {});
+ }
+
function cut() {
body.classList.add('cut'); // instant feedback, server confirms it
curZh = ''; curEn = '';
@@ -154,6 +162,11 @@
addEventListener('resize', function () { measurePad(); fit(); });
addEventListener('keydown', function (e) {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ keep();
+ return;
+ }
if (e.key === 'Backspace' || e.key === 'Delete' || e.key === 'c') {
// "that was wrong, say it again": red screen, then straight back to work
e.preventDefault();
@@ -169,6 +182,7 @@
measurePad();
if (q.has('invert')) body.classList.add('invert');
+ if (q.has('keep')) body.classList.add('keep');
if (q.has('cut')) { body.classList.add('cut'); return; }
if (q.has('text')) { // design preview: index.html?en=1&text=你好&t=hello
@@ -182,7 +196,9 @@
const s = JSON.parse(e.data);
body.classList.toggle('invert', !!s.invert);
body.classList.toggle('cut', !!s.cut);
+ body.classList.toggle('keep', !!s.keep);
if (s.cut) { curZh = ''; curEn = ''; zh.textContent = ''; en.textContent = ''; return; }
+ if (s.keep && s.text === curZh) return; // only the colour changed
render(s.text, s.en, s.cap);
} catch (_) {}
};