dehezhang2 commited on
Commit
d9ae7ea
·
verified ·
1 Parent(s): 906c39f

deploy rater (Docker/FastAPI): registration + completeness gate + /api/submit → dataset

Browse files
Files changed (1) hide show
  1. static/index.html +723 -167
static/index.html CHANGED
@@ -280,37 +280,31 @@
280
  <div class="toast" id="toast"></div>
281
 
282
  <!-- One-time registration: name + email. No password. Shown until both fields are
283
- filled, then hidden until the user clears their state. -->
 
284
  <div id="loginOverlay" class="overlay hidden" role="dialog" aria-modal="true">
285
  <div class="reg-card">
286
- <h2>Register to start rating</h2>
287
- <p class="lead">
288
- We record who submitted each set of ratings so we can match results back to
289
- participants and resolve duplicates. No password — just your name and an
290
- email address that uniquely identifies you.
291
- </p>
292
- <label for="regName">Your name</label>
293
- <input id="regName" type="text" autocomplete="name"
294
- placeholder="e.g. Alex Chen" maxlength="80" />
295
- <label for="regEmail">Email</label>
296
- <input id="regEmail" type="email" autocomplete="email"
297
- placeholder="e.g. alex@example.com" maxlength="120" />
298
- <label for="regNote">Affiliation / notes (optional)</label>
299
- <textarea id="regNote" maxlength="280"
300
- placeholder="e.g. INSAIT, internal pilot, etc."></textarea>
301
  <div class="reg-err" id="regErr"></div>
302
  <div class="row-actions">
303
- <button class="btn primary" id="regGoBtn">Continue →</button>
304
- <span style="color:var(--muted-2);font-size:11px">
305
- Your ratings are saved locally as you go. Submission is a single
306
- final action when 100% complete.
307
- </span>
308
- </div>
309
- <div class="reg-foot">
310
- You can change your name later in the toolbar. Once you submit the study,
311
- your name + email + ratings are written to the
312
- <code>dehezhang2/Frameworker_User_Study</code> dataset on Hugging Face.
313
  </div>
 
314
  </div>
315
  </div>
316
 
@@ -322,8 +316,8 @@
322
  <p id="submittedDetail"></p>
323
  <p style="font-size:12px"><code id="submittedRef">—</code></p>
324
  <div class="row-actions">
325
- <button class="btn ghost" onclick="hideSubmittedOverlay()">Close</button>
326
- <button class="btn" onclick="exportJSON()">↓ Also download backup JSON</button>
327
  </div>
328
  </div>
329
  </div>
@@ -402,17 +396,493 @@ const DIMENSIONS = [
402
  },
403
  ];
404
 
405
- const SCALE_LABELS = {
406
- 1: "Very poor",
407
- 2: "Poor",
408
- 3: "Fair",
409
- 4: "Good",
410
- 5: "Excellent",
411
- };
412
-
413
  const STORAGE_KEY = "user_study_video_ratings_v1";
414
  const TOTAL_QUESTIONS = DIMENSIONS.reduce((n, d) => n + d.questions.length, 0);
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  /* =========================================================================
417
  * State
418
  * ========================================================================= */
@@ -450,6 +920,7 @@ function saveState() {
450
  const blob = {
451
  rater: RATER,
452
  anonymize,
 
453
  shuffle: SHUFFLE,
454
  ratings: RATINGS,
455
  saved_at: new Date().toISOString(),
@@ -457,7 +928,7 @@ function saveState() {
457
  try {
458
  localStorage.setItem(STORAGE_KEY, JSON.stringify(blob));
459
  } catch (e) {
460
- showToast("⚠ failed to save: " + e.message, true);
461
  }
462
  }
463
 
@@ -524,7 +995,7 @@ function setRating(caseId, slotIdx, qkey, score) {
524
  RATER.submitted_at = null;
525
  saveState();
526
  setSyncStatus(SYNC_STATUS === "local-only" ? "local-only" : "idle",
527
- "ratings changed after submission — submit again to update");
528
  }
529
  }
530
 
@@ -581,7 +1052,7 @@ function studyCompleteness() {
581
 
582
  async function submitWholeStudy() {
583
  if (!RATER.email || !RATER.name) {
584
- showToast("Please sign in before submitting", true);
585
  showLoginOverlay(true);
586
  return;
587
  }
@@ -589,9 +1060,7 @@ async function submitWholeStudy() {
589
  if (comp.missing.length > 0) {
590
  const first = comp.missing.slice(0, 3)
591
  .map(m => `${m.case_id}/${m.slot}/${m.q}`).join(", ");
592
- showToast(
593
- `${comp.missing.length} ratings still missing — first: ${first}`,
594
- true);
595
  // Jump to the first incomplete case to make it easy to finish.
596
  const firstCaseId = comp.missing[0].case_id;
597
  const idx = CASES.findIndex(c => c.id === firstCaseId);
@@ -599,13 +1068,11 @@ async function submitWholeStudy() {
599
  return;
600
  }
601
  if (SYNC_STATUS === "local-only") {
602
- showToast(
603
- "No server reachable — use ↓ Export JSON to save your submission",
604
- true);
605
  return;
606
  }
607
 
608
- setSyncStatus("submitting", "uploading to dataset…");
609
  const payload = buildFullSubmissionPayload();
610
  try {
611
  const resp = await fetch(API_SUBMIT, {
@@ -618,20 +1085,20 @@ async function submitWholeStudy() {
618
  RATER.submitted_at = new Date().toISOString();
619
  saveState();
620
  setSyncStatus("submitted",
621
- `recorded as ${body.stored_as || "submission"} (${body.n_scores ?? "?"} scores)`);
622
  updateSubmitButton();
623
  showSubmittedOverlay(body);
624
  } else if (resp.status === 404 || resp.status === 503) {
625
- setSyncStatus("local-only", `server not configured (HTTP ${resp.status})`);
626
- showToast("Server not configured — Export JSON instead", true);
627
  } else {
628
  const text = await resp.text().catch(() => "");
629
  setSyncStatus("error", `HTTP ${resp.status}: ${text.slice(0, 120)}`);
630
- showToast(`Submit failed (HTTP ${resp.status})`, true);
631
  }
632
  } catch (e) {
633
  setSyncStatus("local-only", "POST /api/submit failed: " + e.message);
634
- showToast("Submit failed: " + e.message, true);
635
  }
636
  }
637
 
@@ -640,16 +1107,16 @@ function setSyncStatus(state, detail) {
640
  if (detail) SYNC_LAST_DETAIL = detail;
641
  const pill = document.getElementById("syncPill");
642
  if (!pill) return;
643
- const label = {
644
- idle: "● server ready",
645
- submitting: "↻ submitting…",
646
- submitted: "✓ submitted",
647
- "local-only": "💾 local-only",
648
- error: "✕ submit error",
649
- }[state] || state;
650
- pill.textContent = label;
651
  pill.dataset.state = state;
652
- pill.title = SYNC_LAST_DETAIL || "click 'Submit study' when 100% complete";
653
  }
654
 
655
  async function probeSyncEndpoint() {
@@ -659,15 +1126,13 @@ async function probeSyncEndpoint() {
659
  const j = await resp.json().catch(() => ({}));
660
  const ok = j.ok && j.has_token;
661
  setSyncStatus(ok ? "idle" : "local-only",
662
- ok ? `server ready — submissions go to ${j.dataset || "dataset"}`
663
- : (j.has_token === false
664
- ? "server reachable but HF_TOKEN secret is missing"
665
- : "server unhealthy"));
666
  } else {
667
- setSyncStatus("local-only", `health probe HTTP ${resp.status}`);
668
  }
669
  } catch (e) {
670
- setSyncStatus("local-only", "no /api/submit endpoint reachable");
671
  }
672
  }
673
 
@@ -747,9 +1212,9 @@ function renderShell() {
747
  function renderHeader() {
748
  return el("header", { class: "top" },
749
  el("div", {},
750
- el("div", { class: "title" }, "Video user study — side-by-side rating"),
751
  el("div", { class: "subtitle" },
752
- `${CASES.length} cases · 4 dimensions · ${TOTAL_QUESTIONS} sub-questions per video · 1–5 Likert`),
753
  ),
754
  el("div", { class: "progress" },
755
  el("div", { class: "progress-bar" },
@@ -759,25 +1224,45 @@ function renderHeader() {
759
  );
760
  }
761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
  function renderToolbar() {
763
  const tb = el("div", { class: "toolbar" });
764
 
765
  const nameInput = el("input", {
766
  type: "text",
767
- placeholder: "your name",
768
  value: RATER.name || "",
769
- title: "click to edit name",
770
  onchange: (e) => {
771
  const newName = e.target.value.trim();
772
  if (!newName) { e.target.value = RATER.name; return; }
773
  RATER.name = newName;
774
  saveState();
775
- renderDetail();
 
776
  },
777
  });
778
 
779
  tb.appendChild(el("div", { class: "rater-box" },
780
- el("span", {}, "Rater:"),
781
  nameInput,
782
  el("span", {
783
  style: "color:var(--muted-2);font-size:11px;font-family:ui-monospace,monospace"
@@ -786,24 +1271,27 @@ function renderToolbar() {
786
 
787
  if (RATER.submitted_at) {
788
  tb.appendChild(el("span", { class: "submitted-badge",
789
- title: "you've already submitted; further edits clear this flag" },
790
- "✓ submitted"));
791
  }
792
 
793
  tb.appendChild(el("div", { class: "sep" }));
794
 
795
- tb.appendChild(el("button", {
796
- class: "btn ghost",
797
- onclick: toggleAnon,
798
- }, anonymize ? "🔒 Anonymized" : "👁 Reveal models"));
799
-
800
- tb.appendChild(el("div", { class: "sep" }));
 
 
 
801
 
802
  tb.appendChild(el("span", {
803
  id: "syncPill", class: "sync-pill",
804
  "data-state": SYNC_STATUS,
805
- title: SYNC_LAST_DETAIL || "click 'Submit study' when 100% complete",
806
- }, "● checking…"));
807
 
808
  tb.appendChild(el("div", { class: "sep" }));
809
 
@@ -812,24 +1300,30 @@ function renderToolbar() {
812
  class: "btn submit-primary",
813
  onclick: submitWholeStudy,
814
  disabled: "",
815
- title: "rate every question to enable",
816
- }, "Submit study"));
817
 
818
  tb.appendChild(el("button", {
819
  class: "btn ghost",
820
  onclick: exportJSON,
821
- title: "save a local backup of your ratings",
822
- }, "↓ Export JSON"));
823
 
824
  tb.appendChild(el("button", {
825
  class: "btn ghost",
826
  onclick: resetCurrentCase,
827
- }, "↺ Reset case"));
828
 
829
  tb.appendChild(el("button", {
830
  class: "btn ghost",
831
  onclick: resetAll,
832
- }, "✕ Reset all"));
 
 
 
 
 
 
833
 
834
  return tb;
835
  }
@@ -841,22 +1335,22 @@ function updateSubmitButton() {
841
  const remaining = comp.expected - comp.done;
842
  if (remaining > 0) {
843
  btn.disabled = true;
844
- btn.textContent = `Submit study (${remaining} left)`;
845
- btn.title = `rate every question to enable — ${remaining} of ${comp.expected} still missing`;
846
  } else if (SYNC_STATUS === "submitted") {
847
  btn.disabled = false;
848
- btn.textContent = "✓ Re-submit";
849
- btn.title = "you've already submitted; click again to overwrite";
850
  } else {
851
  btn.disabled = false;
852
- btn.textContent = `Submit study (${comp.expected} ratings)`;
853
- btn.title = "post your full rating set to the dataset";
854
  }
855
  }
856
 
857
  function renderSidebar() {
858
  const aside = el("aside", { class: "list" });
859
- aside.appendChild(el("div", { class: "list-header" }, `Cases (${CASES.length})`));
860
  CASES.forEach((c, i) => {
861
  const p = caseProgress(c);
862
  let cls = "case-row";
@@ -882,8 +1376,8 @@ function renderFooter() {
882
  return el("footer", { class: "bottom" },
883
  el("div", { class: "summary", id: "footerSummary" }),
884
  el("div", { class: "nav-btns" },
885
- el("button", { class: "btn", onclick: () => step(-1) }, "← Prev"),
886
- el("button", { class: "btn", onclick: () => step(1) }, "Next →"),
887
  ),
888
  );
889
  }
@@ -915,38 +1409,36 @@ function renderDetail() {
915
  function renderInstructions(forceOpen) {
916
  const det = el("details", { class: "instructions" });
917
  if (forceOpen) det.setAttribute("open", "");
918
- det.appendChild(el("summary", {},
919
- "How to rate (click to expand) — 4 dimensions, " + TOTAL_QUESTIONS + " sub-questions, 1–5 each"));
920
 
921
  const body = el("div");
922
  body.innerHTML = `
923
- <p>For each case, watch all videos side by side, then rate <strong>each video independently</strong>
924
- on every sub-question. The rating table groups sub-questions by dimension; videos appear as columns.</p>
925
 
926
- <h4>Likert scale (1 = worst, 5 = best)</h4>
927
  <div class="scale-row">
928
- <span class="scale-pill" style="background:var(--score-1)">1 · Very poor</span>
929
- <span class="scale-pill" style="background:var(--score-2)">2 · Poor</span>
930
- <span class="scale-pill" style="background:var(--score-3)">3 · Fair</span>
931
- <span class="scale-pill" style="background:var(--score-4)">4 · Good</span>
932
- <span class="scale-pill" style="background:var(--score-5)">5 · Excellent</span>
933
  </div>
934
 
935
- <h4>Dimensions</h4>
936
  <ul>
937
- <li><strong>Instruction following</strong> — controllability, editing correctness, prompt adherence.</li>
938
- <li><strong>Visual quality</strong> — aesthetics, sharpness, realism.</li>
939
- <li><strong>Temporal consistency</strong> — anti-flicker, person / object / environment stability.</li>
940
- <li><strong>Motion realism</strong> — physics, movement, camera motion.</li>
941
  </ul>
942
 
943
- <h4>Tips</h4>
944
  <ul>
945
- <li>Use <kbd>Space</kbd> to play / pause all videos in sync, <kbd>R</kbd> to restart, <kbd>L</kbd> to toggle loop.</li>
946
- <li>Use <kbd>←</kbd> / <kbd>→</kbd> (or <kbd>j</kbd> / <kbd>k</kbd>) to jump between cases.</li>
947
- <li>Ratings autosave to your browser's localStorage. Click <code>↓ Export JSON</code> when finished.</li>
948
- <li>Videos are <strong>anonymized by default</strong> — model identity is hidden until you toggle reveal.</li>
949
- <li>If a tile shows "no video file", the manifest path doesn't exist on disk yet — drop a real <code>.mp4</code> at that path and refresh.</li>
950
  </ul>
951
  `;
952
  det.appendChild(body);
@@ -958,13 +1450,13 @@ function renderCaseHeader(c) {
958
  const left = el("div", { style: "flex:0 0 auto;display:flex;flex-direction:column;gap:4px" },
959
  el("span", { class: "case-id" }, c.id),
960
  el("span", { class: "case-counter" },
961
- `Case ${currentIdx + 1} of ${CASES.length}`),
962
  );
963
  wrap.appendChild(left);
964
 
965
  const promptBox = el("div", { class: "prompt-box" });
966
- promptBox.appendChild(el("div", { class: "label" }, "Prompt / instruction"));
967
- promptBox.appendChild(el("div", {}, c.prompt || "(no prompt provided)"));
968
  wrap.appendChild(promptBox);
969
 
970
  if (c.reference_image) {
@@ -985,11 +1477,12 @@ function renderVideoGrid(c) {
985
  slots.forEach((origIdx, slotIdx) => {
986
  const v = c.videos[origIdx];
987
  const tile = el("div", { class: "video-tile" });
 
988
  const labelText = anonymize
989
- ? `Video ${String.fromCharCode(65 + slotIdx)}`
990
- : `Video ${String.fromCharCode(65 + slotIdx)} · ${v.model}`;
991
  tile.appendChild(el("div", { class: "slot-label" },
992
- el("span", { class: "slot-num" }, String.fromCharCode(65 + slotIdx)),
993
  el("span", {}, labelText),
994
  ));
995
 
@@ -1006,10 +1499,10 @@ function renderVideoGrid(c) {
1006
 
1007
  const empty = el("div", { class: "empty-state", style: "display:none" },
1008
  el("div", { class: "icon" }, "▶"),
1009
- el("div", {}, "no video file at this path"),
1010
  el("div", { class: "path" }, v.path),
1011
  el("div", { style: "font-size:11px;color:var(--muted-2);margin-top:4px" },
1012
- "drop the .mp4 there, then refresh"),
1013
  );
1014
  frame.appendChild(video);
1015
  frame.appendChild(empty);
@@ -1034,27 +1527,27 @@ function renderVideoControls(c) {
1034
  const ctl = el("div", { class: "video-controls" });
1035
  ctl.appendChild(el("button", {
1036
  class: "ctl-btn", onclick: playAll,
1037
- }, "▶ Play all"));
1038
  ctl.appendChild(el("button", {
1039
  class: "ctl-btn", onclick: pauseAll,
1040
- }, "⏸ Pause"));
1041
  ctl.appendChild(el("button", {
1042
  class: "ctl-btn", onclick: restartAll,
1043
- }, "⏮ Restart"));
1044
 
1045
  const loopBtn = el("button", {
1046
  class: "ctl-btn", id: "loopBtn",
1047
  onclick: () => toggleLoop(loopBtn),
1048
- }, "↻ Loop");
1049
  ctl.appendChild(loopBtn);
1050
 
1051
  const muteBtn = el("button", {
1052
  class: "ctl-btn", id: "muteBtn",
1053
  onclick: () => toggleMute(muteBtn),
1054
- }, "🔇 Mute");
1055
  ctl.appendChild(muteBtn);
1056
 
1057
- ctl.appendChild(el("span", { style: "margin-left:auto" }, "Speed:"));
1058
  const speedSel = el("select", {
1059
  onchange: (e) => setSpeed(parseFloat(e.target.value)),
1060
  });
@@ -1074,12 +1567,13 @@ function renderRatingsTable(c) {
1074
  const table = el("table");
1075
  const thead = el("thead");
1076
  const headRow = el("tr");
1077
- headRow.appendChild(el("th", { class: "q-col" }, "Sub-question"));
1078
  slots.forEach((origIdx, slotIdx) => {
1079
  const v = c.videos[origIdx];
 
1080
  const label = anonymize
1081
- ? `Video ${String.fromCharCode(65 + slotIdx)}`
1082
- : `${String.fromCharCode(65 + slotIdx)} · ${v.model}`;
1083
  headRow.appendChild(el("th", { class: "video-col" }, label));
1084
  });
1085
  thead.appendChild(headRow);
@@ -1089,16 +1583,16 @@ function renderRatingsTable(c) {
1089
  for (const dim of DIMENSIONS) {
1090
  const dimRow = el("tr", { class: "dim-row" });
1091
  const dimCell = el("td", { colspan: String(slots.length + 1) });
1092
- dimCell.appendChild(el("span", {}, dim.name));
1093
- dimCell.appendChild(el("span", { class: "dim-hint" }, dim.hint));
1094
  dimRow.appendChild(dimCell);
1095
  tbody.appendChild(dimRow);
1096
 
1097
  for (const q of dim.questions) {
1098
  const row = el("tr");
1099
  const qCell = el("td", { class: "q-cell" });
1100
- qCell.appendChild(el("div", { class: "q-name" }, q.name));
1101
- qCell.appendChild(el("div", { class: "q-desc" }, q.desc));
1102
  row.appendChild(qCell);
1103
 
1104
  slots.forEach((origIdx, slotIdx) => {
@@ -1119,7 +1613,7 @@ function renderLikertCell(caseId, slotIdx, qkey) {
1119
  for (let s = 1; s <= 5; s++) {
1120
  const btn = el("button", {
1121
  "data-score": String(s),
1122
- title: `${s} — ${SCALE_LABELS[s]}`,
1123
  onclick: () => {
1124
  setRating(caseId, slotIdx, qkey, s);
1125
  // re-render only this group
@@ -1197,10 +1691,13 @@ function updateFooterSummary() {
1197
  const p = caseProgress(c);
1198
  const el = document.getElementById("footerSummary");
1199
  if (!el) return;
1200
- el.innerHTML =
1201
- `Case <span class="num">${currentIdx + 1}</span> / ${CASES.length} · ` +
1202
- `<span class="num">${p.done}</span> / ${p.expected} ratings on this case` +
1203
- (p.done === p.expected && p.expected > 0 ? " · ✓ complete" : "");
 
 
 
1204
  }
1205
 
1206
  function updateCaseStatus(caseId) {
@@ -1221,6 +1718,7 @@ function updateCaseStatus(caseId) {
1221
  * Toolbar actions
1222
  * ========================================================================= */
1223
  function toggleAnon() {
 
1224
  anonymize = !anonymize;
1225
  // Re-shuffle (or un-shuffle) since the visual order can change
1226
  SHUFFLE = {};
@@ -1231,18 +1729,18 @@ function toggleAnon() {
1231
 
1232
  function resetCurrentCase() {
1233
  const c = CASES[currentIdx];
1234
- if (!confirm(`Reset all ratings for ${c.id}?`)) return;
1235
  delete RATINGS[c.id];
1236
  saveState();
1237
  renderDetail();
1238
  document.querySelector(`[data-case-id="${c.id}"]`)?.classList.remove("partial", "complete");
1239
  updateProgress();
1240
  updateCaseStatus(c.id);
1241
- showToast("Cleared ratings for " + c.id);
1242
  }
1243
 
1244
  function resetAll() {
1245
- if (!confirm("Reset all ratings, registration, and rater id? This cannot be undone.")) return;
1246
  RATINGS = {};
1247
  SHUFFLE = {};
1248
  RATER = { id: genRaterId(), name: "", email: "", note: "",
@@ -1250,7 +1748,7 @@ function resetAll() {
1250
  buildShuffle(CASES);
1251
  saveState();
1252
  showLoginOverlay(true);
1253
- showToast("All ratings reset");
1254
  }
1255
 
1256
  /* =========================================================================
@@ -1286,9 +1784,9 @@ function handleRegistrationSubmit() {
1286
  const note = document.getElementById("regNote").value.trim();
1287
  const err = document.getElementById("regErr");
1288
  err.textContent = "";
1289
- if (!name) { err.textContent = "Please enter your name."; return; }
1290
  if (!EMAIL_RE.test(email)) {
1291
- err.textContent = "Please enter a valid email address.";
1292
  return;
1293
  }
1294
  RATER.name = name;
@@ -1307,7 +1805,51 @@ function handleRegistrationSubmit() {
1307
  hideLoginOverlay();
1308
  renderShell();
1309
  probeSyncEndpoint();
1310
- showToast(`Registered as ${name}`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1311
  }
1312
 
1313
  /* =========================================================================
@@ -1319,11 +1861,10 @@ function showSubmittedOverlay(body) {
1319
  const detail = document.getElementById("submittedDetail");
1320
  const ref = document.getElementById("submittedRef");
1321
  if (detail) {
1322
- detail.textContent =
1323
- `Thanks, ${RATER.name}. We recorded ${body.n_scores ?? "?"} ratings ` +
1324
- `across ${body.n_videos ?? "?"} videos to the dataset.`;
1325
  }
1326
- if (ref) ref.textContent = body.stored_as || "(no filename returned)";
1327
  ov.classList.remove("hidden");
1328
  }
1329
 
@@ -1362,7 +1903,7 @@ function exportJSON() {
1362
  });
1363
  document.body.appendChild(a); a.click(); a.remove();
1364
  URL.revokeObjectURL(url);
1365
- showToast("Exported JSON");
1366
  }
1367
 
1368
  /* =========================================================================
@@ -1371,11 +1912,10 @@ function exportJSON() {
1371
  function renderEmptyApp(reason) {
1372
  document.getElementById("app").innerHTML = `
1373
  <div class="empty-app">
1374
- <h2>Video user study</h2>
1375
  <p style="color:var(--bad)">${escapeHtml(reason)}</p>
1376
- <p>This page expects a manifest at <code>./cases.json</code> describing the cases to rate.
1377
- A working example lives at <code>./cases.example.json</code>.</p>
1378
- <h3 style="color:var(--accent-strong);font-size:13px;text-transform:uppercase;letter-spacing:0.4px">cases.json format</h3>
1379
  <pre>[
1380
  {
1381
  "id": "case_001",
@@ -1387,12 +1927,11 @@ function renderEmptyApp(reason) {
1387
  ]
1388
  }
1389
  ]</pre>
1390
- <p>Then serve this directory and open the page:</p>
1391
  <pre>cd evals/user_study
1392
  python -m http.server 8765
1393
  # open http://localhost:8765/</pre>
1394
- <p style="color:var(--muted-2)">Tip: missing video files render as a striped "no video" placeholder, so you
1395
- can scaffold the rating UI before any real <code>.mp4</code>s exist.</p>
1396
  </div>`;
1397
  }
1398
 
@@ -1441,15 +1980,29 @@ document.getElementById("regGoBtn")?.addEventListener("click", handleRegistratio
1441
  });
1442
 
1443
  (async function init() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1444
  const found = await fetchManifest();
1445
  if (!found) {
1446
- renderEmptyApp("Could not load ./cases.json or ./cases.example.json — " +
1447
- "either run via python -m http.server, or drop a manifest in this directory.");
1448
  return;
1449
  }
1450
  CASES = found.data || [];
1451
  if (!Array.isArray(CASES) || CASES.length === 0) {
1452
- renderEmptyApp("Manifest is empty — add at least one case to cases.json.");
1453
  return;
1454
  }
1455
 
@@ -1468,6 +2021,9 @@ document.getElementById("regGoBtn")?.addEventListener("click", handleRegistratio
1468
  RATER = blankRater();
1469
  }
1470
 
 
 
 
1471
  buildShuffle(CASES);
1472
  saveState();
1473
 
@@ -1480,7 +2036,7 @@ document.getElementById("regGoBtn")?.addEventListener("click", handleRegistratio
1480
  }
1481
 
1482
  if (found.path.endsWith("example.json")) {
1483
- showToast("Loaded cases.example.json — drop a real cases.json to override");
1484
  }
1485
  // Probe the /api/submit endpoint. Done after registration so the pill, which
1486
  // lives in the toolbar, exists in the DOM.
 
280
  <div class="toast" id="toast"></div>
281
 
282
  <!-- One-time registration: name + email. No password. Shown until both fields are
283
+ filled, then hidden until the user clears their state. Strings are filled
284
+ in by applyRegistrationOverlayI18n() based on LANG. -->
285
  <div id="loginOverlay" class="overlay hidden" role="dialog" aria-modal="true">
286
  <div class="reg-card">
287
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px">
288
+ <h2 id="regHeader">Register to start rating</h2>
289
+ <div style="display:flex;align-items:center;gap:6px;font-size:11px;color:var(--muted)">
290
+ <span id="regLangLabel">Language</span>
291
+ <select id="regLangSelect"
292
+ onchange="LANG=this.value;document.documentElement.lang=LANG;saveState();applyRegistrationOverlayI18n();"></select>
293
+ </div>
294
+ </div>
295
+ <p class="lead" id="regLead"></p>
296
+ <label for="regName" id="regNameLabel">Your name</label>
297
+ <input id="regName" type="text" autocomplete="name" maxlength="80" />
298
+ <label for="regEmail" id="regEmailLabel">Email</label>
299
+ <input id="regEmail" type="email" autocomplete="email" maxlength="120" />
300
+ <label for="regNote" id="regNoteLabel">Affiliation / notes (optional)</label>
301
+ <textarea id="regNote" maxlength="280"></textarea>
302
  <div class="reg-err" id="regErr"></div>
303
  <div class="row-actions">
304
+ <button class="btn primary" id="regGoBtn"><span id="regContinueText">Continue →</span></button>
305
+ <span style="color:var(--muted-2);font-size:11px" id="regSideNote"></span>
 
 
 
 
 
 
 
 
306
  </div>
307
+ <div class="reg-foot" id="regFootText"></div>
308
  </div>
309
  </div>
310
 
 
316
  <p id="submittedDetail"></p>
317
  <p style="font-size:12px"><code id="submittedRef">—</code></p>
318
  <div class="row-actions">
319
+ <button class="btn ghost" id="submittedCloseBtn" onclick="hideSubmittedOverlay()">Close</button>
320
+ <button class="btn" id="submittedDownloadBtn" onclick="exportJSON()">↓ Also download backup JSON</button>
321
  </div>
322
  </div>
323
  </div>
 
396
  },
397
  ];
398
 
 
 
 
 
 
 
 
 
399
  const STORAGE_KEY = "user_study_video_ratings_v1";
400
  const TOTAL_QUESTIONS = DIMENSIONS.reduce((n, d) => n + d.questions.length, 0);
401
 
402
+ /* =========================================================================
403
+ * Admins — these names see the "Reveal models" toggle.
404
+ * Matched case-insensitively against RATER.name. Spoofable by typing the
405
+ * name in the registration form, but cases.json on the wire contains the
406
+ * model names anyway — the gate is a UX nicety, not a security boundary.
407
+ * ========================================================================= */
408
+ const ADMIN_NAMES = new Set([
409
+ "deheng zhang",
410
+ "zhendong li",
411
+ ]);
412
+ function isAdmin() {
413
+ const n = (RATER.name || "").toLowerCase().trim();
414
+ return ADMIN_NAMES.has(n);
415
+ }
416
+
417
+ /* =========================================================================
418
+ * i18n — English / 简体中文 / Български
419
+ * t(key, ...args) does positional {0}, {1} substitution.
420
+ * Rubric translations live in RUBRIC_I18N keyed by dim/question.
421
+ * ========================================================================= */
422
+ const LANGUAGES = [
423
+ { code: "en", label: "English" },
424
+ { code: "zh", label: "中文" },
425
+ { code: "bg", label: "Български" },
426
+ ];
427
+ let LANG = "en";
428
+
429
+ const STRINGS = {
430
+ en: {
431
+ "title": "Video user study — side-by-side rating",
432
+ "subtitle": "{0} cases · 4 dimensions · {1} sub-questions per video · 1–5 Likert",
433
+ "lang_label": "Language",
434
+ "rater": "Rater:",
435
+ "rater_placeholder": "your name",
436
+ "rater_edit_title": "click to edit name",
437
+ "anonymized": "🔒 Anonymized",
438
+ "reveal_models": "👁 Reveal models",
439
+ "submit_pending": "Submit study ({0} left)",
440
+ "submit_ready": "Submit study ({0} ratings)",
441
+ "submit_resubmit": "✓ Re-submit",
442
+ "submit_disabled_title": "rate every question to enable — {0} of {1} still missing",
443
+ "submit_ready_title": "post your full rating set to the dataset",
444
+ "submit_resubmit_title": "you've already submitted; click again to overwrite",
445
+ "submit_enable_hint": "rate every question to enable",
446
+ "export_json": "↓ Export JSON",
447
+ "export_title": "save a local backup of your ratings",
448
+ "reset_case": "↺ Reset case",
449
+ "reset_all": "✕ Reset all",
450
+ "submitted_badge": "✓ submitted",
451
+ "submitted_badge_title": "you've already submitted; further edits clear this flag",
452
+ "pill_idle": "● server ready",
453
+ "pill_submitting": "↻ submitting…",
454
+ "pill_submitted": "✓ submitted",
455
+ "pill_local_only": "💾 local-only",
456
+ "pill_error": "✕ submit error",
457
+ "pill_checking": "● checking…",
458
+ "pill_default_title": "click 'Submit study' when 100% complete",
459
+ "cases_n": "Cases ({0})",
460
+ "case_n_of_m": "Case {0} of {1}",
461
+ "prompt_label": "Prompt / instruction",
462
+ "no_prompt": "(no prompt provided)",
463
+ "play_all": "▶ Play all",
464
+ "pause": "⏸ Pause",
465
+ "restart": "⏮ Restart",
466
+ "loop": "↻ Loop",
467
+ "mute": "🔇 Mute",
468
+ "muted": "🔇 Muted",
469
+ "sound": "🔊 Sound",
470
+ "speed": "Speed:",
471
+ "sub_question_col": "Sub-question",
472
+ "video_label_anon": "Video {0}",
473
+ "video_label_revealed": "Video {0} · {1}",
474
+ "video_col_anon": "Video {0}",
475
+ "video_col_revealed": "{0} · {1}",
476
+ "no_video_file": "no video file at this path",
477
+ "drop_mp4_hint": "drop the .mp4 there, then refresh",
478
+ "footer_summary": "Case {0} / {1} · {2} / {3} ratings on this case",
479
+ "footer_complete_suffix": " · ✓ complete",
480
+ "prev": "← Prev",
481
+ "next": "Next →",
482
+ "instructions_toggle": "How to rate (click to expand) — 4 dimensions, {0} sub-questions, 1–5 each",
483
+ "instructions_intro": "For each case, watch all videos side by side, then rate <strong>each video independently</strong> on every sub-question. The rating table groups sub-questions by dimension; videos appear as columns.",
484
+ "scale_legend": "Likert scale (1 = worst, 5 = best)",
485
+ "dimensions_header": "Dimensions",
486
+ "dim_inst_short": "<strong>Instruction following</strong> — controllability, editing correctness, prompt adherence.",
487
+ "dim_visual_short": "<strong>Visual quality</strong> — aesthetics, sharpness, realism.",
488
+ "dim_temporal_short": "<strong>Temporal consistency</strong> — anti-flicker, person / object / environment stability.",
489
+ "dim_motion_short": "<strong>Motion realism</strong> — physics, movement, camera motion.",
490
+ "tips_header": "Tips",
491
+ "tip_keys": "Use <kbd>Space</kbd> to play / pause all videos in sync, <kbd>R</kbd> to restart, <kbd>L</kbd> to toggle loop.",
492
+ "tip_nav": "Use <kbd>←</kbd> / <kbd>→</kbd> (or <kbd>j</kbd> / <kbd>k</kbd>) to jump between cases.",
493
+ "tip_autosave": "Ratings autosave to your browser's localStorage. Click <code>↓ Export JSON</code> when finished.",
494
+ "tip_anon": "Videos are anonymized by default — model identity is hidden unless an admin toggles reveal.",
495
+ "tip_missing": "If a tile shows \"no video file\", the manifest path doesn't exist on disk yet — drop a real <code>.mp4</code> at that path and refresh.",
496
+ "scale_1": "Very poor",
497
+ "scale_2": "Poor",
498
+ "scale_3": "Fair",
499
+ "scale_4": "Good",
500
+ "scale_5": "Excellent",
501
+ "reg_title": "Register to start rating",
502
+ "reg_lead": "We record who submitted each set of ratings so we can match results back to participants and resolve duplicates. No password — just your name and an email address that uniquely identifies you.",
503
+ "reg_name": "Your name",
504
+ "reg_name_ph": "e.g. Alex Chen",
505
+ "reg_email": "Email",
506
+ "reg_email_ph": "e.g. alex@example.com",
507
+ "reg_note": "Affiliation / notes (optional)",
508
+ "reg_note_ph": "e.g. INSAIT, internal pilot, etc.",
509
+ "reg_continue": "Continue →",
510
+ "reg_side_note": "Your ratings are saved locally as you go. Submission is a single final action when 100% complete.",
511
+ "reg_foot": "You can change your name later in the toolbar. Once you submit the study, your name + email + ratings are written to the <code>dehezhang2/Frameworker_User_Study</code> dataset on Hugging Face.",
512
+ "reg_err_name": "Please enter your name.",
513
+ "reg_err_email": "Please enter a valid email address.",
514
+ "submitted_title": "Submission recorded",
515
+ "submitted_thanks": "Thanks, {0}. We recorded {1} ratings across {2} videos to the dataset.",
516
+ "submitted_close": "Close",
517
+ "submitted_download": "↓ Also download backup JSON",
518
+ "toast_registered_as": "Registered as {0}",
519
+ "toast_pls_signin": "Please sign in before submitting",
520
+ "toast_missing_first": "{0} ratings still missing — first: {1}",
521
+ "toast_no_server": "No server reachable — use ↓ Export JSON to save your submission",
522
+ "toast_submit_failed_http": "Submit failed (HTTP {0})",
523
+ "toast_submit_failed": "Submit failed: {0}",
524
+ "toast_exported": "Exported JSON",
525
+ "toast_cleared_case": "Cleared ratings for {0}",
526
+ "toast_reset_all": "All ratings reset",
527
+ "toast_loaded_example": "Loaded cases.example.json — drop a real cases.json to override",
528
+ "toast_server_not_configured": "Server not configured — Export JSON instead",
529
+ "toast_save_failed": "⚠ failed to save: {0}",
530
+ "confirm_reset_case": "Reset all ratings for {0}?",
531
+ "confirm_reset_all": "Reset all ratings, registration, and rater id? This cannot be undone.",
532
+ "pill_server_ready_detail": "server ready — submissions go to {0}",
533
+ "pill_no_token_detail": "server reachable but HF_TOKEN secret is missing",
534
+ "pill_unhealthy": "server unhealthy",
535
+ "pill_health_http": "health probe HTTP {0}",
536
+ "pill_no_endpoint": "no /api/submit endpoint reachable",
537
+ "pill_uploading": "uploading to dataset…",
538
+ "pill_recorded_as": "recorded as {0} ({1} scores)",
539
+ "pill_changed_after_submit": "ratings changed after submission — submit again to update",
540
+ "empty_app_title": "Video user study",
541
+ "empty_app_intro_html": "This page expects a manifest at <code>./cases.json</code> describing the cases to rate. A working example lives at <code>./cases.example.json</code>.",
542
+ "empty_app_format_header": "cases.json format",
543
+ "empty_app_serve_header": "Then serve this directory and open the page:",
544
+ "empty_app_missing_tip_html": "Tip: missing video files render as a striped \"no video\" placeholder, so you can scaffold the rating UI before any real <code>.mp4</code>s exist.",
545
+ "empty_app_load_error": "Could not load ./cases.json or ./cases.example.json — either run via python -m http.server, or drop a manifest in this directory.",
546
+ "empty_app_empty_manifest": "Manifest is empty — add at least one case to cases.json.",
547
+ },
548
+ zh: {
549
+ "title": "视频用户研究 — 并排评分",
550
+ "subtitle": "{0} 个案例 · 4 个维度 · 每个视频 {1} 个子问题 · 1–5 分李克特量表",
551
+ "lang_label": "语言",
552
+ "rater": "评分人:",
553
+ "rater_placeholder": "您的姓名",
554
+ "rater_edit_title": "点击修改姓名",
555
+ "anonymized": "🔒 已匿名",
556
+ "reveal_models": "👁 显示模型名称",
557
+ "submit_pending": "提交研究(还剩 {0} 项)",
558
+ "submit_ready": "提交研究({0} 项评分)",
559
+ "submit_resubmit": "✓ 重新提交",
560
+ "submit_disabled_title": "请回答全部问题后再提交 — 共 {1} 项中尚有 {0} 项未完成",
561
+ "submit_ready_title": "将完整评分发送至数据集",
562
+ "submit_resubmit_title": "您已提交过;再次点击将覆盖",
563
+ "submit_enable_hint": "请完成全部评分后再启用",
564
+ "export_json": "↓ 导出 JSON",
565
+ "export_title": "将评分另存为本地备份",
566
+ "reset_case": "↺ 重置当前案例",
567
+ "reset_all": "✕ 全部重置",
568
+ "submitted_badge": "✓ 已提交",
569
+ "submitted_badge_title": "您已提交;继续编辑将清除此标记",
570
+ "pill_idle": "● 服务器就绪",
571
+ "pill_submitting": "↻ 正在提交…",
572
+ "pill_submitted": "✓ 已提交",
573
+ "pill_local_only": "💾 仅本地",
574
+ "pill_error": "✕ 提交出错",
575
+ "pill_checking": "● 检查中…",
576
+ "pill_default_title": "全部完成后点击「提交研究」",
577
+ "cases_n": "案例 ({0})",
578
+ "case_n_of_m": "第 {0} / {1} 个案例",
579
+ "prompt_label": "提示词 / 指令",
580
+ "no_prompt": "(未提供提示词)",
581
+ "play_all": "▶ 全部播放",
582
+ "pause": "⏸ 暂停",
583
+ "restart": "⏮ 重新开始",
584
+ "loop": "↻ 循环",
585
+ "mute": "🔇 静音",
586
+ "muted": "🔇 已静音",
587
+ "sound": "🔊 取消静音",
588
+ "speed": "速度:",
589
+ "sub_question_col": "子问题",
590
+ "video_label_anon": "视频 {0}",
591
+ "video_label_revealed": "视频 {0} · {1}",
592
+ "video_col_anon": "视频 {0}",
593
+ "video_col_revealed": "{0} · {1}",
594
+ "no_video_file": "该路径下没有视频文件",
595
+ "drop_mp4_hint": "请将 .mp4 文件放入该路径后刷新",
596
+ "footer_summary": "案例 {0} / {1} · 本案例已评 {2} / {3} 项",
597
+ "footer_complete_suffix": " · ✓ 已完成",
598
+ "prev": "← 上一个",
599
+ "next": "下一个 →",
600
+ "instructions_toggle": "评分说明(点击展开)— 共 4 个维度 / {0} 个子问题,每项 1–5 分",
601
+ "instructions_intro": "请并排观看所有视频,然后<strong>独立</strong>对每个视频的每个子问题打分。评分表按维度分组;视频以列方式呈现。",
602
+ "scale_legend": "李克特量表(1 = 最差, 5 = 最佳)",
603
+ "dimensions_header": "评估维度",
604
+ "dim_inst_short": "<strong>指令遵循</strong> — 可控性、编辑准确度、提示一致性。",
605
+ "dim_visual_short": "<strong>画面质量</strong> — 美学、清晰度、真实感。",
606
+ "dim_temporal_short": "<strong>时间一致性</strong> — 防闪烁,人物 / 物体 / 环境稳定性。",
607
+ "dim_motion_short": "<strong>运动真实感</strong> — 物理规律、运动连贯性、相机运动。",
608
+ "tips_header": "操作提示",
609
+ "tip_keys": "<kbd>Space</kbd> 同步播放 / 暂停所有视频,<kbd>R</kbd> 重新开始,<kbd>L</kbd> 切换循环。",
610
+ "tip_nav": "使用 <kbd>←</kbd> / <kbd>→</kbd> (或 <kbd>j</kbd> / <kbd>k</kbd>) 在案例间切换。",
611
+ "tip_autosave": "评分会自动保存到浏览器的 localStorage。完成后点击 <code>↓ 导出 JSON</code>。",
612
+ "tip_anon": "默认情况下视频已匿名 — 仅管理员可切换显示模型名称。",
613
+ "tip_missing": "若卡片显示「没有视频文件」,说明清单中的路径在磁盘上不存在 — 请将真实的 <code>.mp4</code> 放置在该路径后刷新。",
614
+ "scale_1": "很差",
615
+ "scale_2": "差",
616
+ "scale_3": "一般",
617
+ "scale_4": "好",
618
+ "scale_5": "极佳",
619
+ "reg_title": "注册以开始评分",
620
+ "reg_lead": "我们会记录每份评分的提交者,以便将结果对应到参与者并处理重复提交。无需密码 — 只需您的姓名和一个可唯一识别您的邮箱地址。",
621
+ "reg_name": "您的姓名",
622
+ "reg_name_ph": "例如:陈小明",
623
+ "reg_email": "邮箱",
624
+ "reg_email_ph": "例如:xiaoming@example.com",
625
+ "reg_note": "所属单位 / 备注(可选)",
626
+ "reg_note_ph": "例如:INSAIT、内部预测试 等",
627
+ "reg_continue": "继续 →",
628
+ "reg_side_note": "您的评分会在过程中自动保存到本地。提交是一次性最终操作,需在 100% 完成后执行。",
629
+ "reg_foot": "您之后可在工具栏修改姓名。提交后,姓名 + 邮箱 + 评分将写入 Hugging Face 上的 <code>dehezhang2/Frameworker_User_Study</code> 数据集。",
630
+ "reg_err_name": "请输入您的姓名。",
631
+ "reg_err_email": "请输入有效的邮箱地址。",
632
+ "submitted_title": "提交成功",
633
+ "submitted_thanks": "{0},感谢您的参与。我们已将 {2} 个视频 × {1} 项评分写入数据集。",
634
+ "submitted_close": "关闭",
635
+ "submitted_download": "↓ 同时下载备份 JSON",
636
+ "toast_registered_as": "已注册为 {0}",
637
+ "toast_pls_signin": "请先登录后再提交",
638
+ "toast_missing_first": "尚有 {0} 项未完成 — 例如:{1}",
639
+ "toast_no_server": "无法连接服务器 — 请使用 ↓ 导出 JSON 来保存",
640
+ "toast_submit_failed_http": "提交失败 (HTTP {0})",
641
+ "toast_submit_failed": "提交失败:{0}",
642
+ "toast_exported": "已导出 JSON",
643
+ "toast_cleared_case": "已清空 {0} 的评分",
644
+ "toast_reset_all": "已重置全部评分",
645
+ "toast_loaded_example": "已加载 cases.example.json — 请放入真实的 cases.json 以覆盖",
646
+ "toast_server_not_configured": "服务器未配置 — 请改用「导出 JSON」",
647
+ "toast_save_failed": "⚠ 保存失败:{0}",
648
+ "confirm_reset_case": "确定要清空 {0} 的全部评分吗?",
649
+ "confirm_reset_all": "确定要重置全部评分、注册信息和评分人 ID 吗?该操作不可撤销。",
650
+ "pill_server_ready_detail": "服务器就绪 — 提交将写入 {0}",
651
+ "pill_no_token_detail": "服务器可达但缺少 HF_TOKEN 密钥",
652
+ "pill_unhealthy": "服务器不健康",
653
+ "pill_health_http": "健康探测 HTTP {0}",
654
+ "pill_no_endpoint": "无法访问 /api/submit",
655
+ "pill_uploading": "正在上传至数据集…",
656
+ "pill_recorded_as": "已记录为 {0}({1} 项评分)",
657
+ "pill_changed_after_submit": "提交后又有修改 — 请再次提交以更新",
658
+ "empty_app_title": "视频用户研究",
659
+ "empty_app_intro_html": "本页面需要在 <code>./cases.json</code> 中提供案例清单。可参考 <code>./cases.example.json</code>。",
660
+ "empty_app_format_header": "cases.json 格式",
661
+ "empty_app_serve_header": "随后从该目录启动服务并打开页面:",
662
+ "empty_app_missing_tip_html": "提示:缺失的视频文件会显示斜条「无视频」占位,因此可以先搭好评分界面,等真实的 <code>.mp4</code> 文件就位后再使用。",
663
+ "empty_app_load_error": "无法加载 ./cases.json 或 ./cases.example.json — 请使用 python -m http.server,或将清单文件放入当前目录。",
664
+ "empty_app_empty_manifest": "清单为空 — 请在 cases.json 中至少添加一个案例。",
665
+ },
666
+ bg: {
667
+ "title": "Видео потребителско проучване — паралелно оценяване",
668
+ "subtitle": "{0} случая · 4 измерения · {1} под-въпроса на видео · Ликерт 1–5",
669
+ "lang_label": "Език",
670
+ "rater": "Оценител:",
671
+ "rater_placeholder": "вашето име",
672
+ "rater_edit_title": "щракнете, за да редактирате името",
673
+ "anonymized": "🔒 Анонимизирано",
674
+ "reveal_models": "👁 Покажи моделите",
675
+ "submit_pending": "Изпрати проучването (остават {0})",
676
+ "submit_ready": "Изпрати проучването ({0} оценки)",
677
+ "submit_resubmit": "✓ Повторно изпращане",
678
+ "submit_disabled_title": "оценете всеки въпрос, за да активирате — липсват {0} от {1}",
679
+ "submit_ready_title": "изпратете пълния набор от оценки към набора от данни",
680
+ "submit_resubmit_title": "вече сте изпратили; щракнете отново, за да презапишете",
681
+ "submit_enable_hint": "оценете всеки въпрос, за да активирате",
682
+ "export_json": "↓ Изтегли JSON",
683
+ "export_title": "запази локално копие на оценките",
684
+ "reset_case": "↺ Изчисти случая",
685
+ "reset_all": "✕ Изчисти всичко",
686
+ "submitted_badge": "✓ изпратено",
687
+ "submitted_badge_title": "вече сте изпратили; следващи промени премахват този етикет",
688
+ "pill_idle": "● сървърът е готов",
689
+ "pill_submitting": "↻ изпращане…",
690
+ "pill_submitted": "✓ изпратено",
691
+ "pill_local_only": "💾 само локално",
692
+ "pill_error": "✕ грешка при изпращане",
693
+ "pill_checking": "● проверка…",
694
+ "pill_default_title": "щракнете „Изпрати проучването“, когато сте 100% готови",
695
+ "cases_n": "Случаи ({0})",
696
+ "case_n_of_m": "Случай {0} от {1}",
697
+ "prompt_label": "Подкана / инструкция",
698
+ "no_prompt": "(няма подкана)",
699
+ "play_all": "▶ Пусни всички",
700
+ "pause": "⏸ Пауза",
701
+ "restart": "⏮ Започни отначало",
702
+ "loop": "↻ Цикъл",
703
+ "mute": "🔇 Изключи звук",
704
+ "muted": "🔇 Без звук",
705
+ "sound": "🔊 Със звук",
706
+ "speed": "Скорост:",
707
+ "sub_question_col": "Под-въпрос",
708
+ "video_label_anon": "Видео {0}",
709
+ "video_label_revealed": "Видео {0} · {1}",
710
+ "video_col_anon": "Видео {0}",
711
+ "video_col_revealed": "{0} · {1}",
712
+ "no_video_file": "няма видео файл на този път",
713
+ "drop_mp4_hint": "поставете .mp4 файла там и презаредете",
714
+ "footer_summary": "Случай {0} / {1} · {2} / {3} оценки за този случай",
715
+ "footer_complete_suffix": " · ✓ завършен",
716
+ "prev": "← Назад",
717
+ "next": "Напред →",
718
+ "instructions_toggle": "Как се оценява (щракни за разгъване) — 4 измерения, {0} под-въпроса, по 1–5",
719
+ "instructions_intro": "За всеки случай гледайте всички видеа едно до друго и оценявайте <strong>всяко видео самостоятелно</strong> по всеки под-въпрос. Таблицата групира под-въпросите по измерения; видеата са колоните.",
720
+ "scale_legend": "Ликертова скала (1 = най-лошо, 5 = най-добро)",
721
+ "dimensions_header": "Измерения",
722
+ "dim_inst_short": "<strong>Следване на инструкции</strong> — контролируемост, точност на редакцията, съответствие с подканата.",
723
+ "dim_visual_short": "<strong>Визуално качество</strong> — естетика, острота, реализъм.",
724
+ "dim_temporal_short": "<strong>Времева съгласуваност</strong> — анти-трептене, стабилност на хора / обекти / среда.",
725
+ "dim_motion_short": "<strong>Реалистичност на движението</strong> — физика, движение, движение на камерата.",
726
+ "tips_header": "Съвети",
727
+ "tip_keys": "С <kbd>Space</kbd> пускате / спирате всички видеа синхронно, <kbd>R</kbd> рестартира, <kbd>L</kbd> превключва цикъл.",
728
+ "tip_nav": "С <kbd>←</kbd> / <kbd>→</kbd> (или <kbd>j</kbd> / <kbd>k</kbd>) минавате между случаите.",
729
+ "tip_autosave": "Оценките се запазват автоматично в localStorage на браузъра. Щракнете <code>↓ Изтегли JSON</code>, когато приключите.",
730
+ "tip_anon": "По подразбиране видеата са анонимизирани — само администратор може да покаже имената на моделите.",
731
+ "tip_missing": "Ако плочка показва „няма видео файл“, пътят от манифеста не съществува — поставете истинско <code>.mp4</code> там и презаредете.",
732
+ "scale_1": "Много слабо",
733
+ "scale_2": "Слабо",
734
+ "scale_3": "Средно",
735
+ "scale_4": "Добро",
736
+ "scale_5": "Отлично",
737
+ "reg_title": "Регистрирайте се, за да започнете оценяване",
738
+ "reg_lead": "Записваме кой е изпратил всеки набор от оценки, за да можем да съпоставяме резултатите с участниците и да разрешаваме дубликати. Без парола — само вашето име и имейл, който уникално ви идентифицира.",
739
+ "reg_name": "Вашето име",
740
+ "reg_name_ph": "напр. Алекс Иванов",
741
+ "reg_email": "Имейл",
742
+ "reg_email_ph": "напр. alex@example.com",
743
+ "reg_note": "Принадлежност / бележки (по избор)",
744
+ "reg_note_ph": "напр. INSAIT, вътрешен пилот и т.н.",
745
+ "reg_continue": "Продължи →",
746
+ "reg_side_note": "Оценките ви се запазват локално в процеса. Изпращането е еднократно финално действие при 100% готовност.",
747
+ "reg_foot": "Името можете да промените по-късно в лентата с инструменти. След като изпратите проучването, името + имейлът + оценките се записват в набора от данни <code>dehezhang2/Frameworker_User_Study</code> в Hugging Face.",
748
+ "reg_err_name": "Моля, въведете името си.",
749
+ "reg_err_email": "Моля, въведете валиден имейл адрес.",
750
+ "submitted_title": "Изпращането е записано",
751
+ "submitted_thanks": "Благодарим, {0}. Записахме {1} оценки за {2} видеа в набора от данни.",
752
+ "submitted_close": "Затвори",
753
+ "submitted_download": "↓ Изтегли резервно JSON копие",
754
+ "toast_registered_as": "Регистриран(а) като {0}",
755
+ "toast_pls_signin": "Моля, влезте преди изпращане",
756
+ "toast_missing_first": "Все още липсват {0} оценки — първите: {1}",
757
+ "toast_no_server": "Сървърът не е достъпен — използвайте ↓ Изтегли JSON, за да запазите",
758
+ "toast_submit_failed_http": "Изпращането се провали (HTTP {0})",
759
+ "toast_submit_failed": "Изпращането се провали: {0}",
760
+ "toast_exported": "JSON е изтеглен",
761
+ "toast_cleared_case": "Оценките за {0} са изчистени",
762
+ "toast_reset_all": "Всички оценки са изчистени",
763
+ "toast_loaded_example": "Заредено cases.example.json — поставете истински cases.json, за да го заместите",
764
+ "toast_server_not_configured": "Сървърът не е конфигуриран — използвайте „Изтегли JSON“",
765
+ "toast_save_failed": "⚠ грешка при запазване: {0}",
766
+ "confirm_reset_case": "Да се изчистят ли всички оценки за {0}?",
767
+ "confirm_reset_all": "Да се изчистят всички оценки, регистрация и rater id? Действието е необратимо.",
768
+ "pill_server_ready_detail": "сървърът е готов — изпращанията отиват в {0}",
769
+ "pill_no_token_detail": "сървърът е достъпен, но липсва тайната HF_TOKEN",
770
+ "pill_unhealthy": "сървърът не е здрав",
771
+ "pill_health_http": "проверка на здравето HTTP {0}",
772
+ "pill_no_endpoint": "няма достъпен /api/submit",
773
+ "pill_uploading": "качване в набора от данни…",
774
+ "pill_recorded_as": "записано като {0} ({1} оценки)",
775
+ "pill_changed_after_submit": "оценките са променени след изпращане — изпратете отново",
776
+ "empty_app_title": "Видео потребителско проучване",
777
+ "empty_app_intro_html": "Тази страница очаква манифест в <code>./cases.json</code> с описание на случаите за оценяване. Работещ пример има в <code>./cases.example.json</code>.",
778
+ "empty_app_format_header": "Формат на cases.json",
779
+ "empty_app_serve_header": "След това стартирайте директорията и отворете страницата:",
780
+ "empty_app_missing_tip_html": "Съвет: липсващите видеа се пок��зват с раиран „без видео“ заместител, така че можете да подготвите интерфейса преди да съществуват реални <code>.mp4</code> файлове.",
781
+ "empty_app_load_error": "Не може да се зареди ./cases.json или ./cases.example.json — стартирайте python -m http.server или поставете манифест в тази директория.",
782
+ "empty_app_empty_manifest": "Манифестът е празен — добавете поне един случай в cases.json.",
783
+ },
784
+ };
785
+
786
+ // Per-dimension and per-sub-question translations. Keyed by dim.key / q.key.
787
+ const RUBRIC_I18N = {
788
+ zh: {
789
+ instruction_following: { name: "指令遵循", hint: "视频是否按提示完成?" },
790
+ visual_quality: { name: "画面质量", hint: "每一帧的视觉效果如何?" },
791
+ temporal_consistency: { name: "时间一致性", hint: "内容在帧间的稳定程度?" },
792
+ motion_realism: { name: "运动真实感", hint: "运动是否符合物理规律?" },
793
+ controllability: { name: "可控性",
794
+ desc: "视频是否响应控制信号(相机运动、条件输入、场景线索)?" },
795
+ editing_correctness: { name: "编辑准确度",
796
+ desc: "是否在不破坏无关内容的情况下应用了所请求的编辑?" },
797
+ prompt_adherence: { name: "提示一致性",
798
+ desc: "内容是否与提示的描述一致(主体、动作、场景)?" },
799
+ aesthetics: { name: "美学",
800
+ desc: "构图、色彩、光照及整体观感。" },
801
+ sharpness: { name: "清晰度",
802
+ desc: "清晰度与细节;无模糊或压缩伪影。" },
803
+ realism: { name: "真实感",
804
+ desc: "照片级真实感或风格忠实度(无诡异感或失真伪影)。" },
805
+ anti_flicker: { name: "防闪烁",
806
+ desc: "帧间无亮度、色彩或纹理闪烁。" },
807
+ person_stability: { name: "人物稳定性",
808
+ desc: "面部、身份及身体比例在帧间保持一致。" },
809
+ object_stability: { name: "物体稳定性",
810
+ desc: "道具、服饰及物体随时间保持形状和位置。" },
811
+ environment_stability: { name: "环境稳定性",
812
+ desc: "背景、光照及场景布局在帧间保持连贯。" },
813
+ physics: { name: "物理规律",
814
+ desc: "重力、碰撞、流体/布料动力学是否合理。" },
815
+ movement: { name: "运动连贯性",
816
+ desc: "身体与物体的运动流畅,无形变或瞬移。" },
817
+ camera: { name: "相机运动",
818
+ desc: "相机运动(平移、推拉、焦距变化)自然且有意图。" },
819
+ },
820
+ bg: {
821
+ instruction_following: { name: "Следване на инструкции",
822
+ hint: "Видеото изпълнява ли подканата?" },
823
+ visual_quality: { name: "Визуално качество",
824
+ hint: "Колко добре изглежда всеки кадър?" },
825
+ temporal_consistency: { name: "Времева съгласуваност",
826
+ hint: "Колко стабилно е съдържанието между кадрите?" },
827
+ motion_realism: { name: "Реалистичност на движението",
828
+ hint: "Движението изглежда ли правдоподобно?" },
829
+ controllability: { name: "Контролируемост",
830
+ desc: "Реагира ли видеото на контролни сигнали (движение на камерата, обуславяне, насоки за сцена)?" },
831
+ editing_correctness: { name: "Точност на редакцията",
832
+ desc: "Прилагат ли се поисканите промени без да нарушават останалото съдържание?" },
833
+ prompt_adherence: { name: "Съответствие с подканата",
834
+ desc: "Съответства ли съдържанието на описаното в подканата (обекти, действия, обстановка)?" },
835
+ aesthetics: { name: "Естетика",
836
+ desc: "Композиция, цвят, осветление, цялостен приятен вид." },
837
+ sharpness: { name: "Острота",
838
+ desc: "Яснота и детайли; липса на размазване или компресионни артефакти." },
839
+ realism: { name: "Реализъм",
840
+ desc: "Фотореалистичност или стилова достоверност (без странни / счупени артефакти)." },
841
+ anti_flicker: { name: "Анти-трептене",
842
+ desc: "Липса на трептене на яркост, цвят или текстура между кадрите." },
843
+ person_stability: { name: "Стабилност на хората",
844
+ desc: "Лица, идентичност�� и пропорции на тялото остават постоянни между кадрите." },
845
+ object_stability: { name: "Стабилност на обектите",
846
+ desc: "Реквизити, дрехи и обекти запазват форма и позиция във времето." },
847
+ environment_stability: { name: "Стабилност на средата",
848
+ desc: "Фон, осветление и подредба на сцената остават последователни между кадрите." },
849
+ physics: { name: "Физика",
850
+ desc: "Гравитация, сблъсъци, динамика на флуиди / тъкани се държат правдоподобно." },
851
+ movement: { name: "Движение",
852
+ desc: "Движенията на тела и обекти текат плавно, без деформации или телепортация." },
853
+ camera: { name: "Камера",
854
+ desc: "Движението на камерата (панорама, дъли, промяна на фокус) изглежда естествено и целенасочено." },
855
+ },
856
+ };
857
+
858
+ function t(key, ...args) {
859
+ let s = (STRINGS[LANG] && STRINGS[LANG][key]) ?? STRINGS.en[key] ?? key;
860
+ if (args.length) {
861
+ s = s.replace(/\{(\d+)\}/g, (_, i) => args[Number(i)] ?? "");
862
+ }
863
+ return s;
864
+ }
865
+
866
+ function dimName(dim) {
867
+ if (LANG === "en") return dim.name;
868
+ return RUBRIC_I18N[LANG]?.[dim.key]?.name ?? dim.name;
869
+ }
870
+ function dimHint(dim) {
871
+ if (LANG === "en") return dim.hint;
872
+ return RUBRIC_I18N[LANG]?.[dim.key]?.hint ?? dim.hint;
873
+ }
874
+ function qName(q) {
875
+ if (LANG === "en") return q.name;
876
+ return RUBRIC_I18N[LANG]?.[q.key]?.name ?? q.name;
877
+ }
878
+ function qDesc(q) {
879
+ if (LANG === "en") return q.desc;
880
+ return RUBRIC_I18N[LANG]?.[q.key]?.desc ?? q.desc;
881
+ }
882
+ function scaleLabel(score) {
883
+ return t(`scale_${score}`);
884
+ }
885
+
886
  /* =========================================================================
887
  * State
888
  * ========================================================================= */
 
920
  const blob = {
921
  rater: RATER,
922
  anonymize,
923
+ lang: LANG,
924
  shuffle: SHUFFLE,
925
  ratings: RATINGS,
926
  saved_at: new Date().toISOString(),
 
928
  try {
929
  localStorage.setItem(STORAGE_KEY, JSON.stringify(blob));
930
  } catch (e) {
931
+ showToast(t("toast_save_failed", e.message), true);
932
  }
933
  }
934
 
 
995
  RATER.submitted_at = null;
996
  saveState();
997
  setSyncStatus(SYNC_STATUS === "local-only" ? "local-only" : "idle",
998
+ t("pill_changed_after_submit"));
999
  }
1000
  }
1001
 
 
1052
 
1053
  async function submitWholeStudy() {
1054
  if (!RATER.email || !RATER.name) {
1055
+ showToast(t("toast_pls_signin"), true);
1056
  showLoginOverlay(true);
1057
  return;
1058
  }
 
1060
  if (comp.missing.length > 0) {
1061
  const first = comp.missing.slice(0, 3)
1062
  .map(m => `${m.case_id}/${m.slot}/${m.q}`).join(", ");
1063
+ showToast(t("toast_missing_first", comp.missing.length, first), true);
 
 
1064
  // Jump to the first incomplete case to make it easy to finish.
1065
  const firstCaseId = comp.missing[0].case_id;
1066
  const idx = CASES.findIndex(c => c.id === firstCaseId);
 
1068
  return;
1069
  }
1070
  if (SYNC_STATUS === "local-only") {
1071
+ showToast(t("toast_no_server"), true);
 
 
1072
  return;
1073
  }
1074
 
1075
+ setSyncStatus("submitting", t("pill_uploading"));
1076
  const payload = buildFullSubmissionPayload();
1077
  try {
1078
  const resp = await fetch(API_SUBMIT, {
 
1085
  RATER.submitted_at = new Date().toISOString();
1086
  saveState();
1087
  setSyncStatus("submitted",
1088
+ t("pill_recorded_as", body.stored_as || "submission", body.n_scores ?? "?"));
1089
  updateSubmitButton();
1090
  showSubmittedOverlay(body);
1091
  } else if (resp.status === 404 || resp.status === 503) {
1092
+ setSyncStatus("local-only", `HTTP ${resp.status}`);
1093
+ showToast(t("toast_server_not_configured"), true);
1094
  } else {
1095
  const text = await resp.text().catch(() => "");
1096
  setSyncStatus("error", `HTTP ${resp.status}: ${text.slice(0, 120)}`);
1097
+ showToast(t("toast_submit_failed_http", resp.status), true);
1098
  }
1099
  } catch (e) {
1100
  setSyncStatus("local-only", "POST /api/submit failed: " + e.message);
1101
+ showToast(t("toast_submit_failed", e.message), true);
1102
  }
1103
  }
1104
 
 
1107
  if (detail) SYNC_LAST_DETAIL = detail;
1108
  const pill = document.getElementById("syncPill");
1109
  if (!pill) return;
1110
+ const labelKey = {
1111
+ idle: "pill_idle",
1112
+ submitting: "pill_submitting",
1113
+ submitted: "pill_submitted",
1114
+ "local-only": "pill_local_only",
1115
+ error: "pill_error",
1116
+ }[state];
1117
+ pill.textContent = labelKey ? t(labelKey) : state;
1118
  pill.dataset.state = state;
1119
+ pill.title = SYNC_LAST_DETAIL || t("pill_default_title");
1120
  }
1121
 
1122
  async function probeSyncEndpoint() {
 
1126
  const j = await resp.json().catch(() => ({}));
1127
  const ok = j.ok && j.has_token;
1128
  setSyncStatus(ok ? "idle" : "local-only",
1129
+ ok ? t("pill_server_ready_detail", j.dataset || "dataset")
1130
+ : (j.has_token === false ? t("pill_no_token_detail") : t("pill_unhealthy")));
 
 
1131
  } else {
1132
+ setSyncStatus("local-only", t("pill_health_http", resp.status));
1133
  }
1134
  } catch (e) {
1135
+ setSyncStatus("local-only", t("pill_no_endpoint"));
1136
  }
1137
  }
1138
 
 
1212
  function renderHeader() {
1213
  return el("header", { class: "top" },
1214
  el("div", {},
1215
+ el("div", { class: "title" }, t("title")),
1216
  el("div", { class: "subtitle" },
1217
+ t("subtitle", CASES.length, TOTAL_QUESTIONS)),
1218
  ),
1219
  el("div", { class: "progress" },
1220
  el("div", { class: "progress-bar" },
 
1224
  );
1225
  }
1226
 
1227
+ function renderLangSelect() {
1228
+ const sel = el("select", {
1229
+ title: t("lang_label"),
1230
+ onchange: (e) => {
1231
+ LANG = e.target.value;
1232
+ document.documentElement.lang = LANG;
1233
+ saveState();
1234
+ renderShell();
1235
+ applyRegistrationOverlayI18n();
1236
+ },
1237
+ });
1238
+ for (const L of LANGUAGES) {
1239
+ const opt = el("option", { value: L.code }, L.label);
1240
+ if (L.code === LANG) opt.setAttribute("selected", "");
1241
+ sel.appendChild(opt);
1242
+ }
1243
+ return sel;
1244
+ }
1245
+
1246
  function renderToolbar() {
1247
  const tb = el("div", { class: "toolbar" });
1248
 
1249
  const nameInput = el("input", {
1250
  type: "text",
1251
+ placeholder: t("rater_placeholder"),
1252
  value: RATER.name || "",
1253
+ title: t("rater_edit_title"),
1254
  onchange: (e) => {
1255
  const newName = e.target.value.trim();
1256
  if (!newName) { e.target.value = RATER.name; return; }
1257
  RATER.name = newName;
1258
  saveState();
1259
+ // re-render so the admin-only toggle visibility refreshes on name change
1260
+ renderShell();
1261
  },
1262
  });
1263
 
1264
  tb.appendChild(el("div", { class: "rater-box" },
1265
+ el("span", {}, t("rater")),
1266
  nameInput,
1267
  el("span", {
1268
  style: "color:var(--muted-2);font-size:11px;font-family:ui-monospace,monospace"
 
1271
 
1272
  if (RATER.submitted_at) {
1273
  tb.appendChild(el("span", { class: "submitted-badge",
1274
+ title: t("submitted_badge_title") },
1275
+ t("submitted_badge")));
1276
  }
1277
 
1278
  tb.appendChild(el("div", { class: "sep" }));
1279
 
1280
+ // Admin-only reveal toggle. Non-admins always see anonymized view (and
1281
+ // anonymize is force-set to true on first paint below).
1282
+ if (isAdmin()) {
1283
+ tb.appendChild(el("button", {
1284
+ class: "btn ghost",
1285
+ onclick: toggleAnon,
1286
+ }, anonymize ? t("anonymized") : t("reveal_models")));
1287
+ tb.appendChild(el("div", { class: "sep" }));
1288
+ }
1289
 
1290
  tb.appendChild(el("span", {
1291
  id: "syncPill", class: "sync-pill",
1292
  "data-state": SYNC_STATUS,
1293
+ title: SYNC_LAST_DETAIL || t("pill_default_title"),
1294
+ }, t("pill_checking")));
1295
 
1296
  tb.appendChild(el("div", { class: "sep" }));
1297
 
 
1300
  class: "btn submit-primary",
1301
  onclick: submitWholeStudy,
1302
  disabled: "",
1303
+ title: t("submit_enable_hint"),
1304
+ }, t("submit_pending", 0)));
1305
 
1306
  tb.appendChild(el("button", {
1307
  class: "btn ghost",
1308
  onclick: exportJSON,
1309
+ title: t("export_title"),
1310
+ }, t("export_json")));
1311
 
1312
  tb.appendChild(el("button", {
1313
  class: "btn ghost",
1314
  onclick: resetCurrentCase,
1315
+ }, t("reset_case")));
1316
 
1317
  tb.appendChild(el("button", {
1318
  class: "btn ghost",
1319
  onclick: resetAll,
1320
+ }, t("reset_all")));
1321
+
1322
+ tb.appendChild(el("div", { class: "sep" }));
1323
+ tb.appendChild(el("div", { class: "rater-box" },
1324
+ el("span", {}, t("lang_label") + ":"),
1325
+ renderLangSelect(),
1326
+ ));
1327
 
1328
  return tb;
1329
  }
 
1335
  const remaining = comp.expected - comp.done;
1336
  if (remaining > 0) {
1337
  btn.disabled = true;
1338
+ btn.textContent = t("submit_pending", remaining);
1339
+ btn.title = t("submit_disabled_title", remaining, comp.expected);
1340
  } else if (SYNC_STATUS === "submitted") {
1341
  btn.disabled = false;
1342
+ btn.textContent = t("submit_resubmit");
1343
+ btn.title = t("submit_resubmit_title");
1344
  } else {
1345
  btn.disabled = false;
1346
+ btn.textContent = t("submit_ready", comp.expected);
1347
+ btn.title = t("submit_ready_title");
1348
  }
1349
  }
1350
 
1351
  function renderSidebar() {
1352
  const aside = el("aside", { class: "list" });
1353
+ aside.appendChild(el("div", { class: "list-header" }, t("cases_n", CASES.length)));
1354
  CASES.forEach((c, i) => {
1355
  const p = caseProgress(c);
1356
  let cls = "case-row";
 
1376
  return el("footer", { class: "bottom" },
1377
  el("div", { class: "summary", id: "footerSummary" }),
1378
  el("div", { class: "nav-btns" },
1379
+ el("button", { class: "btn", onclick: () => step(-1) }, t("prev")),
1380
+ el("button", { class: "btn", onclick: () => step(1) }, t("next")),
1381
  ),
1382
  );
1383
  }
 
1409
  function renderInstructions(forceOpen) {
1410
  const det = el("details", { class: "instructions" });
1411
  if (forceOpen) det.setAttribute("open", "");
1412
+ det.appendChild(el("summary", {}, t("instructions_toggle", TOTAL_QUESTIONS)));
 
1413
 
1414
  const body = el("div");
1415
  body.innerHTML = `
1416
+ <p>${t("instructions_intro")}</p>
 
1417
 
1418
+ <h4>${t("scale_legend")}</h4>
1419
  <div class="scale-row">
1420
+ <span class="scale-pill" style="background:var(--score-1)">1 · ${t("scale_1")}</span>
1421
+ <span class="scale-pill" style="background:var(--score-2)">2 · ${t("scale_2")}</span>
1422
+ <span class="scale-pill" style="background:var(--score-3)">3 · ${t("scale_3")}</span>
1423
+ <span class="scale-pill" style="background:var(--score-4)">4 · ${t("scale_4")}</span>
1424
+ <span class="scale-pill" style="background:var(--score-5)">5 · ${t("scale_5")}</span>
1425
  </div>
1426
 
1427
+ <h4>${t("dimensions_header")}</h4>
1428
  <ul>
1429
+ <li>${t("dim_inst_short")}</li>
1430
+ <li>${t("dim_visual_short")}</li>
1431
+ <li>${t("dim_temporal_short")}</li>
1432
+ <li>${t("dim_motion_short")}</li>
1433
  </ul>
1434
 
1435
+ <h4>${t("tips_header")}</h4>
1436
  <ul>
1437
+ <li>${t("tip_keys")}</li>
1438
+ <li>${t("tip_nav")}</li>
1439
+ <li>${t("tip_autosave")}</li>
1440
+ <li>${t("tip_anon")}</li>
1441
+ <li>${t("tip_missing")}</li>
1442
  </ul>
1443
  `;
1444
  det.appendChild(body);
 
1450
  const left = el("div", { style: "flex:0 0 auto;display:flex;flex-direction:column;gap:4px" },
1451
  el("span", { class: "case-id" }, c.id),
1452
  el("span", { class: "case-counter" },
1453
+ t("case_n_of_m", currentIdx + 1, CASES.length)),
1454
  );
1455
  wrap.appendChild(left);
1456
 
1457
  const promptBox = el("div", { class: "prompt-box" });
1458
+ promptBox.appendChild(el("div", { class: "label" }, t("prompt_label")));
1459
+ promptBox.appendChild(el("div", {}, c.prompt || t("no_prompt")));
1460
  wrap.appendChild(promptBox);
1461
 
1462
  if (c.reference_image) {
 
1477
  slots.forEach((origIdx, slotIdx) => {
1478
  const v = c.videos[origIdx];
1479
  const tile = el("div", { class: "video-tile" });
1480
+ const letter = String.fromCharCode(65 + slotIdx);
1481
  const labelText = anonymize
1482
+ ? t("video_label_anon", letter)
1483
+ : t("video_label_revealed", letter, v.model);
1484
  tile.appendChild(el("div", { class: "slot-label" },
1485
+ el("span", { class: "slot-num" }, letter),
1486
  el("span", {}, labelText),
1487
  ));
1488
 
 
1499
 
1500
  const empty = el("div", { class: "empty-state", style: "display:none" },
1501
  el("div", { class: "icon" }, "▶"),
1502
+ el("div", {}, t("no_video_file")),
1503
  el("div", { class: "path" }, v.path),
1504
  el("div", { style: "font-size:11px;color:var(--muted-2);margin-top:4px" },
1505
+ t("drop_mp4_hint")),
1506
  );
1507
  frame.appendChild(video);
1508
  frame.appendChild(empty);
 
1527
  const ctl = el("div", { class: "video-controls" });
1528
  ctl.appendChild(el("button", {
1529
  class: "ctl-btn", onclick: playAll,
1530
+ }, t("play_all")));
1531
  ctl.appendChild(el("button", {
1532
  class: "ctl-btn", onclick: pauseAll,
1533
+ }, t("pause")));
1534
  ctl.appendChild(el("button", {
1535
  class: "ctl-btn", onclick: restartAll,
1536
+ }, t("restart")));
1537
 
1538
  const loopBtn = el("button", {
1539
  class: "ctl-btn", id: "loopBtn",
1540
  onclick: () => toggleLoop(loopBtn),
1541
+ }, t("loop"));
1542
  ctl.appendChild(loopBtn);
1543
 
1544
  const muteBtn = el("button", {
1545
  class: "ctl-btn", id: "muteBtn",
1546
  onclick: () => toggleMute(muteBtn),
1547
+ }, t("mute"));
1548
  ctl.appendChild(muteBtn);
1549
 
1550
+ ctl.appendChild(el("span", { style: "margin-left:auto" }, t("speed")));
1551
  const speedSel = el("select", {
1552
  onchange: (e) => setSpeed(parseFloat(e.target.value)),
1553
  });
 
1567
  const table = el("table");
1568
  const thead = el("thead");
1569
  const headRow = el("tr");
1570
+ headRow.appendChild(el("th", { class: "q-col" }, t("sub_question_col")));
1571
  slots.forEach((origIdx, slotIdx) => {
1572
  const v = c.videos[origIdx];
1573
+ const letter = String.fromCharCode(65 + slotIdx);
1574
  const label = anonymize
1575
+ ? t("video_col_anon", letter)
1576
+ : t("video_col_revealed", letter, v.model);
1577
  headRow.appendChild(el("th", { class: "video-col" }, label));
1578
  });
1579
  thead.appendChild(headRow);
 
1583
  for (const dim of DIMENSIONS) {
1584
  const dimRow = el("tr", { class: "dim-row" });
1585
  const dimCell = el("td", { colspan: String(slots.length + 1) });
1586
+ dimCell.appendChild(el("span", {}, dimName(dim)));
1587
+ dimCell.appendChild(el("span", { class: "dim-hint" }, dimHint(dim)));
1588
  dimRow.appendChild(dimCell);
1589
  tbody.appendChild(dimRow);
1590
 
1591
  for (const q of dim.questions) {
1592
  const row = el("tr");
1593
  const qCell = el("td", { class: "q-cell" });
1594
+ qCell.appendChild(el("div", { class: "q-name" }, qName(q)));
1595
+ qCell.appendChild(el("div", { class: "q-desc" }, qDesc(q)));
1596
  row.appendChild(qCell);
1597
 
1598
  slots.forEach((origIdx, slotIdx) => {
 
1613
  for (let s = 1; s <= 5; s++) {
1614
  const btn = el("button", {
1615
  "data-score": String(s),
1616
+ title: `${s} — ${scaleLabel(s)}`,
1617
  onclick: () => {
1618
  setRating(caseId, slotIdx, qkey, s);
1619
  // re-render only this group
 
1691
  const p = caseProgress(c);
1692
  const el = document.getElementById("footerSummary");
1693
  if (!el) return;
1694
+ const summary = t("footer_summary",
1695
+ `<span class="num">${currentIdx + 1}</span>`,
1696
+ CASES.length,
1697
+ `<span class="num">${p.done}</span>`,
1698
+ p.expected);
1699
+ el.innerHTML = summary +
1700
+ (p.done === p.expected && p.expected > 0 ? t("footer_complete_suffix") : "");
1701
  }
1702
 
1703
  function updateCaseStatus(caseId) {
 
1718
  * Toolbar actions
1719
  * ========================================================================= */
1720
  function toggleAnon() {
1721
+ if (!isAdmin()) return; // gate: non-admins can't reveal models
1722
  anonymize = !anonymize;
1723
  // Re-shuffle (or un-shuffle) since the visual order can change
1724
  SHUFFLE = {};
 
1729
 
1730
  function resetCurrentCase() {
1731
  const c = CASES[currentIdx];
1732
+ if (!confirm(t("confirm_reset_case", c.id))) return;
1733
  delete RATINGS[c.id];
1734
  saveState();
1735
  renderDetail();
1736
  document.querySelector(`[data-case-id="${c.id}"]`)?.classList.remove("partial", "complete");
1737
  updateProgress();
1738
  updateCaseStatus(c.id);
1739
+ showToast(t("toast_cleared_case", c.id));
1740
  }
1741
 
1742
  function resetAll() {
1743
+ if (!confirm(t("confirm_reset_all"))) return;
1744
  RATINGS = {};
1745
  SHUFFLE = {};
1746
  RATER = { id: genRaterId(), name: "", email: "", note: "",
 
1748
  buildShuffle(CASES);
1749
  saveState();
1750
  showLoginOverlay(true);
1751
+ showToast(t("toast_reset_all"));
1752
  }
1753
 
1754
  /* =========================================================================
 
1784
  const note = document.getElementById("regNote").value.trim();
1785
  const err = document.getElementById("regErr");
1786
  err.textContent = "";
1787
+ if (!name) { err.textContent = t("reg_err_name"); return; }
1788
  if (!EMAIL_RE.test(email)) {
1789
+ err.textContent = t("reg_err_email");
1790
  return;
1791
  }
1792
  RATER.name = name;
 
1805
  hideLoginOverlay();
1806
  renderShell();
1807
  probeSyncEndpoint();
1808
+ showToast(t("toast_registered_as", name));
1809
+ }
1810
+
1811
+ // Sync the registration overlay's static markup to the current LANG so it
1812
+ // reads correctly when the language switcher is changed before the user
1813
+ // completes registration.
1814
+ function applyRegistrationOverlayI18n() {
1815
+ const map = {
1816
+ regHeader: "reg_title",
1817
+ regLead: "reg_lead",
1818
+ regNameLabel: "reg_name",
1819
+ regEmailLabel: "reg_email",
1820
+ regNoteLabel: "reg_note",
1821
+ regContinueText: "reg_continue",
1822
+ regSideNote: "reg_side_note",
1823
+ regFootText: "reg_foot",
1824
+ submittedHeading: "submitted_title",
1825
+ submittedCloseBtn: "submitted_close",
1826
+ submittedDownloadBtn: "submitted_download",
1827
+ regLangLabel: "lang_label",
1828
+ };
1829
+ for (const [domId, key] of Object.entries(map)) {
1830
+ const el = document.getElementById(domId);
1831
+ if (!el) continue;
1832
+ if (key.endsWith("_foot") || key.endsWith("_lead")) el.innerHTML = t(key);
1833
+ else el.textContent = t(key);
1834
+ }
1835
+ const name = document.getElementById("regName");
1836
+ const email = document.getElementById("regEmail");
1837
+ const note = document.getElementById("regNote");
1838
+ if (name) name.placeholder = t("reg_name_ph");
1839
+ if (email) email.placeholder = t("reg_email_ph");
1840
+ if (note) note.placeholder = t("reg_note_ph");
1841
+
1842
+ // language selector on the registration overlay
1843
+ const sel = document.getElementById("regLangSelect");
1844
+ if (sel) {
1845
+ sel.innerHTML = "";
1846
+ for (const L of LANGUAGES) {
1847
+ const opt = document.createElement("option");
1848
+ opt.value = L.code; opt.textContent = L.label;
1849
+ if (L.code === LANG) opt.selected = true;
1850
+ sel.appendChild(opt);
1851
+ }
1852
+ }
1853
  }
1854
 
1855
  /* =========================================================================
 
1861
  const detail = document.getElementById("submittedDetail");
1862
  const ref = document.getElementById("submittedRef");
1863
  if (detail) {
1864
+ detail.textContent = t("submitted_thanks",
1865
+ RATER.name, body.n_scores ?? "?", body.n_videos ?? "?");
 
1866
  }
1867
+ if (ref) ref.textContent = body.stored_as || "—";
1868
  ov.classList.remove("hidden");
1869
  }
1870
 
 
1903
  });
1904
  document.body.appendChild(a); a.click(); a.remove();
1905
  URL.revokeObjectURL(url);
1906
+ showToast(t("toast_exported"));
1907
  }
1908
 
1909
  /* =========================================================================
 
1912
  function renderEmptyApp(reason) {
1913
  document.getElementById("app").innerHTML = `
1914
  <div class="empty-app">
1915
+ <h2>${t("empty_app_title")}</h2>
1916
  <p style="color:var(--bad)">${escapeHtml(reason)}</p>
1917
+ <p>${t("empty_app_intro_html")}</p>
1918
+ <h3 style="color:var(--accent-strong);font-size:13px;text-transform:uppercase;letter-spacing:0.4px">${t("empty_app_format_header")}</h3>
 
1919
  <pre>[
1920
  {
1921
  "id": "case_001",
 
1927
  ]
1928
  }
1929
  ]</pre>
1930
+ <p>${t("empty_app_serve_header")}</p>
1931
  <pre>cd evals/user_study
1932
  python -m http.server 8765
1933
  # open http://localhost:8765/</pre>
1934
+ <p style="color:var(--muted-2)">${t("empty_app_missing_tip_html")}</p>
 
1935
  </div>`;
1936
  }
1937
 
 
1980
  });
1981
 
1982
  (async function init() {
1983
+ // Restore LANG first so the empty-app + registration overlay show the right
1984
+ // language even before the rest of the state is wired up.
1985
+ try {
1986
+ const prior0 = JSON.parse(localStorage.getItem(STORAGE_KEY) || "null");
1987
+ if (prior0 && STRINGS[prior0.lang]) LANG = prior0.lang;
1988
+ } catch (e) { /* ignore */ }
1989
+ // Or pick browser preferred language on first visit.
1990
+ if (LANG === "en") {
1991
+ const nav = (navigator.language || "en").toLowerCase();
1992
+ if (nav.startsWith("zh")) LANG = "zh";
1993
+ else if (nav.startsWith("bg")) LANG = "bg";
1994
+ }
1995
+ document.documentElement.lang = LANG;
1996
+ applyRegistrationOverlayI18n();
1997
+
1998
  const found = await fetchManifest();
1999
  if (!found) {
2000
+ renderEmptyApp(t("empty_app_load_error"));
 
2001
  return;
2002
  }
2003
  CASES = found.data || [];
2004
  if (!Array.isArray(CASES) || CASES.length === 0) {
2005
+ renderEmptyApp(t("empty_app_empty_manifest"));
2006
  return;
2007
  }
2008
 
 
2021
  RATER = blankRater();
2022
  }
2023
 
2024
+ // Non-admins always see anonymized view — they can't toggle.
2025
+ if (!isAdmin()) anonymize = true;
2026
+
2027
  buildShuffle(CASES);
2028
  saveState();
2029
 
 
2036
  }
2037
 
2038
  if (found.path.endsWith("example.json")) {
2039
+ showToast(t("toast_loaded_example"));
2040
  }
2041
  // Probe the /api/submit endpoint. Done after registration so the pill, which
2042
  // lives in the toolbar, exists in the DOM.