openvibers/openvibe.bench Commits

Home folds say how much they hold (#91)

OP OpenVibers committed 11 days ago · 4951e7ae87 · 2 files, +16 −2

Changes

ddiff --git a/public/css/bench.css b/public/css/bench.css
iindex 81d79be..0f8aa53 100644
---- a/public/css/bench.css
++++ b/public/css/bench.css
@@@ -580,6 +580,7 @@ html, body { margin: 0; background: var(--bg-primary, #0a0f1c); color: var(--tex
.fold-h > h2 { margin: 0; font-size: 1.05rem; line-height: 1.3; flex: 1 1 auto; }
.fold-h:focus-within { outline: 2px solid var(--room-accent, #3b82f6); outline-offset: 2px; }
.fold-mark { flex: none; }
++.fold-n { flex: none; font-size: .82rem; font-weight: 600; color: var(--text-muted, #7386a3); font-variant-numeric: tabular-nums; }
.fold-mark::after { content: "+"; font-size: 1.25rem; font-weight: 800; color: var(--room-strong, #60a5fa); }
.fold-toggle:checked ~ .fold-h .fold-mark::after { content: "\2212"; }
.fold-body { display: none; }
@@@ -596,7 +597,7 @@ html, body { margin: 0; background: var(--bg-primary, #0a0f1c); color: var(--tex
.fold-toggle { display: none; }
.fold-h { align-items: baseline; justify-content: space-between; gap: 12px; min-height: 0; padding: 0; margin-bottom: 12px; cursor: default; border: 0; border-radius: 0; background: none; }
.fold-h > h2 { margin: 0; font-size: 1.2rem; }
-- .fold-mark { display: none; }
++ .fold-mark, .fold-n { display: none; }
.fold-body { display: block; }
.fold-bare > .fold-h { display: none; }
.fold-bare { margin-top: 0; }
ddiff --git a/server/render/short.js b/server/render/short.js
iindex ec74c00..21f62f2 100644
---- a/server/render/short.js
++++ b/server/render/short.js
@@@ -24,11 +24,24 @@ const str = (v) => (v && typeof v === 'object' && typeof v.s === 'string') ? v.s
*
* foldBlock({ id, head, html, bare })
*/
++/**
++ * What a fold holds, counted, for its line ("7 questions", "latest 5", "3 items"): a folded part still says how much
++ * is behind it (the owner's rule, 2026-10-31: folds show their count). The 11-01 pass missed this checkbox fold.
++ */
++function foldMeta(body, cls = '') {
++ const s = typeof body === 'string' ? body : String((body && (body.s || body.html || body.value)) || body || '');
++ const n = (re) => (s.match(re) || []).length;
++ const shipped = /data-ov-shipped="list"[^>]*?data-limit="(\d+)"|data-limit="(\d+)"[^>]*?data-ov-shipped="list"/.exec(s);
++ const q = n(/<details[\s>]/g), li = n(/<li[\s>]/g), a = n(/<a\s/g);
++ const text = shipped ? `latest ${shipped[1] || shipped[2]}` : q > 1 ? `${q} questions` : li > 1 ? `${li} items` : a > 1 ? `${a} links` : '';
++ return text ? `<span${cls ? ` class="${cls}"` : ''}>${text}</span>` : '';
++}
++
function foldBlock({ id, head, html, bare = false }) {
const key = `fold-${esc(id)}`;
return `<div class="fold${bare ? ' fold-bare' : ''}" id="${key}">`
+ `<input class="fold-toggle" type="checkbox" id="${key}-open">`
-- + `<label class="fold-h" for="${key}-open">${str(head)}<span class="fold-mark" aria-hidden="true"></span></label>`
++ + `<label class="fold-h" for="${key}-open">${str(head)}${foldMeta(str(html), 'fold-n')}<span class="fold-mark" aria-hidden="true"></span></label>`
+ `<div class="fold-body">${str(html)}</div></div>`;
}