summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorwuhei <wuhei@users.noreply.github.com>2026-11-19 13:43:24 +0100
committerwuhei <wuhei@users.noreply.github.com>2026-11-19 13:43:24 +0100
commitf5181ead5b0969fc1806fb714097b17b8d62d53b (patch)
treed6cbbc49c2635e2f4b0028e86f92af91e9db6fc9 /web
parentd991dca38bd8676c2fc0fe4bc4356d62ccc8e1b1 (diff)
downloadlilchinese-f5181ead5b0969fc1806fb714097b17b8d62d53b.tar.gz
cut screen, per-sentence colour alternation, no one-character last frame
- Backspace/Delete/c in the kiosk: the screen goes red, the recogniser is reset and the in-progress sentence is dropped, so a misheard sentence can be said again. It returns to the normal colours as soon as the retake is heard. Under -record the red frame also marks the retake in the video. - colours alternate black-on-white / white-on-black at each sentence boundary. - slide cutting no longer leaves a stub: a length break needs -preview characters to remain, so '我自学中文已经五年了。' shows as one phrase instead of '了'. - translation window default 40 chars (was 28): fragments cut mid-clause were producing odd English. - tests for slide cutting, colour flip, cut, and the sticky English line
Diffstat (limited to 'web')
-rw-r--r--web/index.html24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/index.html b/web/index.html
index 5179370..677fe14 100644
--- a/web/index.html
+++ b/web/index.html
@@ -8,6 +8,7 @@
html, body {
margin: 0; padding: 0; height: 100%; overflow: hidden;
background: #fff; color: #000; cursor: none;
+ transition: background-color 90ms linear, color 90ms linear;
-webkit-user-select: none; user-select: none;
font-family: "Noto Sans CJK SC Black", "Noto Sans SC Black", "Source Han Sans SC",
"Noto Sans CJK JP Black", "PingFang SC", sans-serif;
@@ -42,6 +43,9 @@
display: none;
}
body.en #en { display: block; }
+ /* sentence alternates black-on-white and white-on-black; Backspace = red retake */
+ body.invert { background: #000; color: #fff; }
+ body.cut { background: #d10d0d; color: #fff; }
@keyframes pop {
from { opacity: .5; transform: scale(.955); }
to { opacity: 1; transform: scale(1); }
@@ -63,6 +67,7 @@
const zh = document.getElementById('zh');
const en = document.getElementById('en');
const d = document.getElementById('d');
+ const body = document.body;
const q = new URLSearchParams(location.search);
const debug = q.has('debug');
const wantEN = q.has('en');
@@ -105,6 +110,13 @@
if (reserve) en.textContent = '';
}
+ function cut() {
+ body.classList.add('cut'); // instant feedback, server confirms it
+ curZh = ''; curEn = '';
+ zh.textContent = ''; en.textContent = '';
+ fetch('/cut', { method: 'POST', keepalive: true }).catch(function () {});
+ }
+
function render(text, translation, cap) {
if (!text) return;
const newPhrase = text !== curZh;
@@ -142,6 +154,12 @@
addEventListener('resize', function () { measurePad(); fit(); });
addEventListener('keydown', function (e) {
+ 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();
+ cut();
+ return;
+ }
if (e.key === 'f' || e.key === 'F') {
if (document.fullscreenElement) document.exitFullscreen();
else document.documentElement.requestFullscreen();
@@ -150,6 +168,9 @@
measurePad();
+ if (q.has('invert')) body.classList.add('invert');
+ if (q.has('cut')) { body.classList.add('cut'); return; }
+
if (q.has('text')) { // design preview: index.html?en=1&text=你好&t=hello
render(q.get('text'), q.get('t') || '', 0);
return;
@@ -159,6 +180,9 @@
es.onmessage = function (e) {
try {
const s = JSON.parse(e.data);
+ body.classList.toggle('invert', !!s.invert);
+ body.classList.toggle('cut', !!s.cut);
+ if (s.cut) { curZh = ''; curEn = ''; zh.textContent = ''; en.textContent = ''; return; }
render(s.text, s.en, s.cap);
} catch (_) {}
};