rafmacalaba commited on
Commit
197ba14
·
verified ·
1 Parent(s): 23b9b98

real-time flag before advance

Browse files
Files changed (1) hide show
  1. review.html +12 -7
review.html CHANGED
@@ -341,7 +341,7 @@ function light() {
341
  lightMeta();
342
  }
343
  function show(ni, ns) {
344
- // same passage: text stays fixed, only the highlight moves.
345
  // recenter only when the target span lies outside the shown window.
346
  if (ni !== i) { i = ni; s = ns; needCenter = true; render(); return; }
347
  s = Math.max(0, Math.min(ns, cur().spans.length - 1));
@@ -376,13 +376,18 @@ async function rule(v) {
376
  saved = await sinkCommit(entry);
377
  }
378
  lastSaved = saved;
379
- // next unruled span in passage, else next passage
380
- const o = cur();
381
- const nx = o.spans.findIndex((x, n) => n > s && !R[x.key]);
382
- if (nx >= 0) show(i, nx);
383
- else if (i < ITEMS.length - 1) show(i + 1, 0);
384
- else { light(); }
 
 
 
385
  }
 
 
386
  async function sinkCommit(entry) {
387
  // shared sink (Cloudflare Worker) if configured, else the annotator's
388
  // own token, else local-only. The sink holds no shared secret: with HF
 
341
  lightMeta();
342
  }
343
  function show(ni, ns) {
344
+ cancelAdv();
345
  // recenter only when the target span lies outside the shown window.
346
  if (ni !== i) { i = ni; s = ns; needCenter = true; render(); return; }
347
  s = Math.max(0, Math.min(ns, cur().spans.length - 1));
 
376
  saved = await sinkCommit(entry);
377
  }
378
  lastSaved = saved;
379
+ // show the agree/disagree flag on this span first, advance after a beat
380
+ cancelAdv();
381
+ light();
382
+ advTimer = setTimeout(() => {
383
+ const o = cur();
384
+ const nx = o.spans.findIndex((x, n) => n > s && !R[x.key]);
385
+ if (nx >= 0) show(i, nx);
386
+ else if (i < ITEMS.length - 1) show(i + 1, 0);
387
+ }, 1100);
388
  }
389
+ let advTimer = null;
390
+ function cancelAdv() { if (advTimer) { clearTimeout(advTimer); advTimer = null; } }
391
  async function sinkCommit(entry) {
392
  // shared sink (Cloudflare Worker) if configured, else the annotator's
393
  // own token, else local-only. The sink holds no shared secret: with HF