From 4e63c7390464289c0ac1c701a03ad576630d8306 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Tue, 17 Nov 2026 13:43:30 +0100 Subject: [PATCH] Vote page: remember the zoom that read the ring for the next scans, quicker zoom search --- static/js/vote.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/static/js/vote.js b/static/js/vote.js index 20f8d3f..ea47db1 100644 --- a/static/js/vote.js +++ b/static/js/vote.js @@ -118,7 +118,10 @@ function makeScanner(video, onToken, onOther) { track.applyConstraints({ advanced: [{ zoom: z }] }).catch(() => { zs = null; zoom.hidden = true; }); } function steer(d, now) { - if (!zs || !zs.auto) return; + if (!zs) return; + // people keep their seat between votes: the zoom that read the ring is where the next scan starts + if (d.token) lsSet(ZOOM_KEY, String(zs.now)); + if (!zs.auto) return; const z = zoomPlan(zs, d, now); if (z != null) setZoom(z); } @@ -133,6 +136,8 @@ function makeScanner(video, onToken, onOther) { zoom.textContent = "1×"; video.srcObject = s; await video.play(); + const saved = +lsGet(ZOOM_KEY); + if (zs && saved > zs.base) setZoom(Math.min(zs.max, saved)); } zoom.onclick = () => { if (!zs) return; @@ -191,19 +196,19 @@ function zoomPlan(zs, d, now) { // a zoom too many costs nothing, so a weak sync ring is enough to steer on const w = d.where, seen = !!w && (d.score ?? 0) >= 0.4; if (seen) zs.lastSeen = now; - if (now - zs.lastMove < 900) return null; + if (now - zs.lastMove < 600) return null; let z = null; - if (seen && !d.token && now - zs.lastRead > 1200 && w.d < 0.24 && zs.now < zs.max) { + if (seen && !d.token && now - zs.lastRead > 900 && w.d < 0.24 && zs.now < zs.max) { const off = Math.max(Math.abs(w.x - 0.5), Math.abs(w.y - 0.5)); const fit = (zs.now * 0.45) / (off + w.d / 2); z = Math.min(zs.max, fit, zs.now * Math.min(2, 0.4 / w.d)); if (z < zs.now + 0.15) z = null; } else if (seen && w.d > 0.8 && zs.now > zs.base) { z = Math.max(zs.base, zs.now * 0.6); - } else if (!seen && now - zs.lastSeen > 2500 && zs.now > zs.base) { + } else if (!seen && now - zs.lastSeen > 1800 && zs.now > zs.base) { z = zs.base; zs.lastSeen = now; - } else if (!seen && zs.now === zs.base && now - zs.lastSeen > 1500 && now - zs.lastMove > 1500) { + } else if (!seen && zs.now === zs.base && now - zs.lastSeen > 800 && now - zs.lastMove > 800) { // from the back rows the ring is too small to be found at all: look closer where the person aims, the // middle, and fall back to wide again (branch above) when nothing shows up there either z = Math.min(zs.max, zs.base * 2); @@ -214,6 +219,7 @@ function zoomPlan(zs, d, now) { } const CAM_KEY = "rv_cam"; +const ZOOM_KEY = `rv_zoom_${pid}`; const FRONT = /front|user|avant|facetime|selfie/i, ODD = /ultra|wide|grand.angle|macro|tele|télé|depth|infra|dual|triple|double/i, BACK = /back|rear|arri[eè]re|environment/i; function openCamera(deviceId) {