Spaces:
Running
Running
Download static/index.html from Lexsi/Hackathon_judging: direct link, hf CLI and curl.
- Browser
- Download file 24.9 kB
-
https://huggingface.co/spaces/Lexsi/Hackathon_judging/resolve/main/static/index.html
- Command line
-
hf download hf://spaces/Lexsi/Hackathon_judging/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Lexsi/Hackathon_judging/resolve/main/static/index.html
24.9 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <meta name="robots" content="noindex, nofollow"> | |
| <title>Judging | Lexsi - AI Safety and Alignment Hackathon</title> | |
| <link rel="icon" type="image/png" href="__FAVICON__"> | |
| <style>__FONTS__</style> | |
| <style> | |
| /* colours copied from the hackathon site's theme.js */ | |
| :root{ | |
| --accent:#FF4B0A;--accent-text:#FFFFFF;--background:#000000;--text:#FFFFFF;--text-body:#FFFFFFD1; | |
| --text-muted:#FFFFFF9E;--text-faint:#FFFFFF73;--border:#262626;--surface:#111111;--card-glow:#FF4B0A66; | |
| --green:#16A34A;--green-hover:#15803D;--hf:#FFD21E; | |
| --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace} | |
| *{box-sizing:border-box;margin:0;padding:0} | |
| [hidden]{display:none} | |
| html{color-scheme:dark} | |
| body{background:var(--background);color:var(--text);font-family:"Space Grotesk",sans-serif;font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased} | |
| a{color:inherit;text-decoration:none} | |
| button{font-family:inherit;cursor:pointer;border:0;background:none;color:inherit} | |
| input,textarea{font-family:inherit;color:var(--text)} | |
| .u{text-decoration:underline;text-underline-offset:3px} | |
| .header{position:sticky;top:0;z-index:50;height:60px;background:var(--background);border-bottom:1px solid var(--border)} | |
| .header-inner{height:100%;display:flex;align-items:center;gap:20px;padding:0 2rem} | |
| .logo img{height:30px;display:block} | |
| .crumb{font-weight:500;color:var(--text-muted);font-size:16px;padding-left:20px;border-left:1px solid var(--border);white-space:nowrap} | |
| .crumb b{color:var(--accent);font-weight:600} | |
| .me{margin-left:auto;display:flex;align-items:center;gap:14px;font-size:14px;color:var(--text-muted);white-space:nowrap} | |
| .me .id{font-family:var(--mono);font-size:12px;border:1px solid var(--border);background:var(--surface);border-radius:4px;padding:2px 8px;color:var(--text)} | |
| .btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 18px;border-radius:8px;font-weight:600;font-size:15px;border:1px solid #FFFFFF4D} | |
| .btn-ghost{border-color:var(--border);color:var(--text-body);height:34px;padding:0 14px;font-size:14px} | |
| .btn-ghost:hover{color:var(--text);border-color:#FFFFFF4D} | |
| .btn-green{background:var(--green);color:#fff}.btn-green:hover{background:var(--green-hover)} | |
| .btn-outline{border-color:var(--border);color:var(--text)}.btn-outline:hover{border-color:#FFFFFF4D} | |
| .btn-hf{background:var(--hf);color:#000;border-color:var(--hf);height:48px;padding:0 24px;font-size:16px} | |
| .btn:disabled{opacity:.5;cursor:not-allowed} | |
| .card{background:var(--background);border:2px solid var(--accent);border-radius:12px;padding:24px} | |
| /* gate */ | |
| .gate{min-height:calc(100vh - 60px);display:flex;align-items:center;justify-content:center;padding:32px 16px;width:100%} | |
| .gate .card{max-width:440px;width:100%;text-align:center;padding:40px 32px} | |
| .gate h1{font-size:26px;font-weight:700;margin-bottom:10px} | |
| .gate p{color:var(--text-body);font-size:15px;margin-bottom:24px} | |
| .gate small{display:block;color:var(--text-faint);font-size:13px;margin-top:18px} | |
| /* layout */ | |
| .layout{display:grid;grid-template-columns:300px minmax(0,1fr);gap:32px;max-width:1240px;margin:0 auto;padding:32px 2rem 120px} | |
| .side{position:sticky;top:92px;align-self:start;max-height:calc(100vh - 124px);display:flex;flex-direction:column} | |
| .side .card{padding:0;display:flex;flex-direction:column;min-height:0} | |
| .side-head{padding:18px 20px 14px;border-bottom:1px solid var(--border)} | |
| .side-head h2{font-size:18px;font-weight:700} | |
| .side-head p{font-size:13px;color:var(--text-muted);margin-top:2px} | |
| .progress{height:6px;background:var(--surface);border-radius:3px;margin-top:12px;overflow:hidden} | |
| .progress i{display:block;height:100%;background:var(--accent);width:0;transition:width .3s} | |
| .subs{list-style:none;overflow-y:auto;padding:8px} | |
| .subs li button{width:100%;text-align:left;display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:8px;border:1px solid transparent} | |
| .subs li button:hover{background:var(--surface)} | |
| .subs li button.on{background:var(--surface);border-color:var(--accent)} | |
| .subs .num{font-family:var(--mono);font-size:13px;font-weight:600;color:var(--text-muted);min-width:34px} | |
| .subs .nm{flex:1;min-width:0;font-weight:500;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} | |
| .pill{font-family:var(--mono);font-size:11px;font-weight:600;border-radius:4px;padding:2px 7px;white-space:nowrap;border:1px solid var(--border);color:var(--text-muted)} | |
| .pill.draft{color:#FFD21E;border-color:#FFD21E66} | |
| .pill.submitted{color:#4ADE80;border-color:#4ADE8066} | |
| .pill.ended_checklist{color:var(--accent);border-color:#FF4B0A66} | |
| /* status lights: slot 1 = you, slots 2-3 = two other judges on this submission */ | |
| .t1{--tc:#FF3B30}.t2{--tc:#FF8A00}.t3{--tc:#FFD21E} | |
| .trk{flex-shrink:0;background:var(--tc,var(--accent));color:#000;font-family:var(--mono);font-size:10.5px;font-weight:700;line-height:1;padding:4px 5px;border-radius:4px} | |
| .subs li button{gap:10px} | |
| .subs li.grp button.gh{font-size:12px;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em;padding:12px 12px 6px;gap:8px;border:0;border-radius:6px} | |
| .subs li.grp button.gh:hover{background:none;color:var(--text)} | |
| .subs li.grp:first-child button.gh{padding-top:6px} | |
| .gh .chev{display:inline-block;width:10px;transition:transform .15s} | |
| .gh.shut .chev{transform:rotate(-90deg)} | |
| .gh .gn{margin-left:auto;font-family:var(--mono);font-weight:500;letter-spacing:0} | |
| .subs li.hid{display:none} | |
| .tprog{margin-top:14px;padding-top:12px;border-top:1px solid var(--border);display:flex;flex-direction:column;gap:7px} | |
| .tprog .tr{display:grid;grid-template-columns:22px 1fr 54px;align-items:center;gap:10px;font-family:var(--mono);font-size:11px} | |
| .tprog .tr b{color:var(--text-body);font-weight:600} | |
| .tprog .tbar{height:6px;background:#FFFFFF1F;border-radius:3px;overflow:hidden} | |
| .tprog .tr span{color:var(--text-muted);text-align:right} | |
| .tprog .tbar i{display:block;height:100%;background:var(--tc,var(--accent));min-width:0;transition:width .3s} | |
| .lights{display:flex;gap:4px;flex-shrink:0} | |
| .lights i{width:8px;height:8px;border-radius:2px;display:block} | |
| .lights i.off{background:#EF4444;box-shadow:0 0 5px 1px #EF444480} | |
| .lights i.draft{background:#FACC15;box-shadow:0 0 5px 1px #FACC1580} | |
| .lights i.done{background:#22C55E;box-shadow:0 0 5px 1px #22C55E80} | |
| .lights i.none{border:1px solid #FFFFFF2E} | |
| .lights i:first-child{outline:1px solid #FFFFFF59;outline-offset:1px} | |
| /* main */ | |
| .main{display:flex;flex-direction:column;gap:28px;min-width:0} | |
| .sub-title{display:flex;align-items:baseline;gap:14px;flex-wrap:wrap} | |
| .sub-title h1{font-size:30px;font-weight:700;line-height:1.2} | |
| .sub-title .tag{font-family:var(--mono);font-size:13px;border:1px solid #5C5C5C;background:#1A1A1A;border-radius:4px;padding:2px 8px} | |
| .meta{display:grid;grid-template-columns:1fr 1fr;gap:0 40px;margin-top:20px} | |
| .meta dl{display:flex;flex-direction:column} | |
| .meta .row{display:grid;grid-template-columns:minmax(150px,auto) 1fr;gap:12px;padding:10px 0;border-bottom:1px solid var(--border);font-size:15px} | |
| .meta .row:last-child{border-bottom:0} | |
| .meta dd{min-width:0;overflow-wrap:anywhere} | |
| .more-h{font-size:18px;font-weight:700} | |
| .meta2{display:grid;grid-template-columns:1fr 1fr;gap:0 40px;margin-top:8px} | |
| .meta2 .row{display:grid;grid-template-columns:110px minmax(0,1fr);gap:12px;padding:10px 0;border-bottom:1px solid var(--border);font-size:15px} | |
| .meta2 .row.wide{grid-column:1/-1;border-bottom:0} | |
| .meta2 dt{color:var(--text-muted)} | |
| .meta2 dd{color:var(--text);font-weight:500;min-width:0;overflow-wrap:anywhere} | |
| .meta2 dd a{color:var(--accent)} | |
| .meta dt{color:var(--text-muted)} | |
| .meta dd{color:var(--text);font-weight:500;word-break:break-word} | |
| .meta dd a{color:var(--accent)} | |
| .sec h3{display:flex;align-items:center;gap:12px;color:var(--accent);font-size:20.5px;font-weight:600;margin-bottom:6px} | |
| .sec h3 .n{background:var(--accent);color:var(--accent-text);border-radius:6px;font-family:var(--mono);font-size:13px;font-weight:600;padding:3px 10px} | |
| .sec .sub{color:var(--text-muted);font-size:14px;margin-bottom:8px} | |
| .q{padding:18px 0;border-top:1px solid var(--border)} | |
| .q:first-of-type{border-top:0} | |
| .q-label{font-size:15.5px;color:var(--text);font-weight:500;margin-bottom:4px} | |
| .q-label .req{color:var(--accent);margin-left:4px} | |
| .q-hint{font-size:13px;color:var(--text-faint);margin-bottom:10px} | |
| .q-label + .opts,.q-label + .num-wrap,.q-label + textarea{margin-top:10px} | |
| .opts{display:flex;flex-wrap:wrap;gap:8px} | |
| .opts.stack{flex-direction:column} | |
| .opt{display:inline-flex;align-items:center;gap:10px;min-height:38px;padding:7px 16px;border:1px solid var(--border);border-radius:8px;font-size:14.5px;font-weight:500;color:var(--text-body);background:var(--background);text-align:left} | |
| .opt:hover{border-color:#FFFFFF4D;color:var(--text)} | |
| .opt .dot{width:16px;height:16px;border-radius:50%;border:1.5px solid #FFFFFF73;flex-shrink:0;display:grid;place-items:center} | |
| .opt.on{border-color:var(--accent);background:#FF4B0A1A;color:var(--text)} | |
| .opt.on .dot{border-color:var(--accent)} | |
| .opt.on .dot::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--accent)} | |
| .num-wrap{display:flex;align-items:center;gap:16px} | |
| .num-wrap input[type=number]{width:84px;height:40px;background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:0 12px;font-size:16px;font-weight:600;font-family:var(--mono)} | |
| .num-wrap .of{font-family:var(--mono);color:var(--text-muted);font-size:14px} | |
| .num-wrap input[type=range]{flex:1;max-width:360px;accent-color:var(--accent)} | |
| textarea{width:100%;min-height:96px;background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:12px 14px;font-size:15px;line-height:1.5;resize:vertical} | |
| input:focus,textarea:focus{outline:none;border-color:var(--accent)} | |
| .q.missing .q-label{color:#FF8A5C} | |
| .q.missing .opts .opt,.q.missing input[type=number],.q.missing textarea{border-color:#FF4B0A99} | |
| .ended{margin-top:14px;border:1px solid var(--accent);background:#FF4B0A14;border-radius:8px;padding:14px 16px;font-size:14.5px;color:var(--text-body)} | |
| .ended b{color:var(--accent)} | |
| .bar{position:fixed;left:0;right:0;bottom:0;z-index:40;background:#000000E6;backdrop-filter:blur(8px);border-top:1px solid var(--border)} | |
| .bar-inner{max-width:1240px;margin:0 auto;padding:14px 2rem;display:flex;align-items:center;gap:12px} | |
| .bar .msg{flex:1;font-size:14px;color:var(--text-muted)} | |
| .bar .msg.err{color:#FF8A5C}.bar .msg.ok{color:#4ADE80} | |
| .empty{color:var(--text-muted);font-size:15px} | |
| @media (max-width:900px){ | |
| .layout{grid-template-columns:1fr;padding:20px 16px 120px;gap:20px} | |
| .side{position:static;max-height:none} | |
| .subs{max-height:240px} | |
| .meta{grid-template-columns:1fr} | |
| .meta2{grid-template-columns:1fr} | |
| .header-inner{padding:0 16px;gap:12px} | |
| .logo img{height:22px} | |
| .crumb{padding-left:12px;font-size:14px} | |
| .me .who{display:none} | |
| .bar-inner{padding:12px 16px;flex-wrap:wrap} | |
| .bar .msg{flex-basis:100%} | |
| .card{padding:18px} | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <header class="header"><div class="header-inner"> | |
| <a class="logo" href="https://hackathon.lexsi.ai" target="_blank" rel="noopener"><img src="__LOGO__" alt="Lexsi.ai"></a> | |
| <span class="crumb"><b>Judging</b> · AI Safety and Alignment Hackathon</span> | |
| <div class="me" id="me" hidden><span class="who" id="who"></span><span class="id" id="jid" title="Your anonymous judge id"></span></div> | |
| </div></header> | |
| <div id="gate" class="gate" hidden><div class="card" id="gate-card"></div></div> | |
| <div id="app" class="layout" hidden> | |
| <aside class="side"><div class="card"> | |
| <div class="side-head"><h2>Submissions</h2><p id="count"></p><div class="progress"><i id="prog"></i></div><div class="tprog" id="tprog"></div></div> | |
| <ul class="subs" id="subs"></ul> | |
| </div></aside> | |
| <main class="main" id="main"></main> | |
| </div> | |
| <div class="bar" id="bar" hidden><div class="bar-inner"> | |
| <span class="msg" id="msg"></span> | |
| <button class="btn btn-outline" id="save">Save draft</button> | |
| <button class="btn btn-green" id="submit">Submit review</button> | |
| </div></div> | |
| <script> | |
| const $ = s => document.querySelector(s); | |
| const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); | |
| const FORM_INLINE = __FORM__; | |
| const SIGN = new URLSearchParams(location.search).get('__sign'); | |
| const FRAMED = window.top !== window.self; | |
| const withSign = p => SIGN ? p + (p.includes('?') ? '&' : '?') + '__sign=' + encodeURIComponent(SIGN) : p; | |
| let FORM, ME, SUBS = [], cur = null, A = {}, dirty = false, locked = false; | |
| const cond = (c, a) => !c ? true : c.all ? c.all.every(x => cond(x, a)) : c.any ? c.any.some(x => cond(x, a)) : c.in.includes(a[c.f]); | |
| // Track is assigned by the internal team in submissions.json, not by the judge. | |
| const withTrack = a => ({...a, track: (SUBS.find(x => x.id === cur) || {}).track}); | |
| function visibleSections(a) { | |
| a = withTrack(a); | |
| const out = []; | |
| for (const s of FORM.sections) { | |
| if (!cond(s.show_if, a)) continue; | |
| out.push(s); | |
| if (s.ends_if && cond(s.ends_if, a)) return [out, true]; | |
| } | |
| return [out, false]; | |
| } | |
| function missing(a) { | |
| const [secs] = visibleSections(a), m = []; | |
| a = withTrack(a); | |
| for (const s of secs) for (const f of s.fields) { | |
| if (f.optional || !cond(f.show_if, a)) continue; | |
| const v = a[f.id]; | |
| if (f.type === 'choice' && !f.options.includes(v)) m.push(f.id); | |
| else if (f.type === 'number' && !(v !== '' && v != null && +v >= f.min && +v <= f.max)) m.push(f.id); | |
| else if (f.type === 'text' && !String(v ?? '').trim()) m.push(f.id); | |
| } | |
| return m; | |
| } | |
| async function api(path, opts) { | |
| const r = await fetch(withSign(path), {credentials: 'same-origin', ...opts}); | |
| let body = null; try { body = await r.json(); } catch (e) {} | |
| return {ok: r.ok, status: r.status, body}; | |
| } | |
| function gate(html) { $('#gate').hidden = false; $('#app').hidden = true; $('#bar').hidden = true; $('#gate-card').innerHTML = html; } | |
| async function boot() { | |
| FORM = FORM_INLINE; | |
| const r = await api('/api/me'); | |
| if (!r.ok || !r.body) return gate(`<h1>Couldn't load</h1><p>Reload this page on Hugging Face. If it keeps happening, message the Lexsi team.</p>`); | |
| ME = r.body; | |
| locked = ME.locked; | |
| if (!ME.user) { | |
| return gate(`<h1>Judges only</h1><p>Open this page on Hugging Face while signed in with your judge account.</p> | |
| <a class="btn btn-hf" href="https://huggingface.co/spaces/Lexsi/Hackathon_judging" target="_top">🤗 Open on Hugging Face</a>`); | |
| } | |
| $('#me').hidden = false; $('#who').textContent = '@' + ME.user; | |
| const RL = {common: 'Common', t1: 'Track 1', t2: 'Track 2', t3: 'Track 3'}; | |
| $('#who').title = 'Judging lists: ' + ((ME.roles || []).map(r => RL[r]).join(', ') || 'none'); | |
| if (!ME.allowed) return gate(`<h1>Not on the judges list</h1><p>You're signed in as <b>@${esc(ME.user)}</b>, but this account isn't an invited judge. If you think that's a mistake, message the Lexsi team.</p>`); | |
| $('#jid').textContent = ME.judge; | |
| $('#app').hidden = false; $('#bar').hidden = false; | |
| await loadSubs(); | |
| const want = location.hash.slice(1); | |
| open(SUBS.find(s => s.id === want) ? want : SUBS[0]?.id); | |
| } | |
| async function loadSubs() { | |
| const TO = {t1: 1, t2: 2, t3: 3}; | |
| SUBS = ((await api('/api/submissions')).body || []).sort((a, b) => (TO[a.track] || 9) - (TO[b.track] || 9) || (a.order ?? 0) - (b.order ?? 0) || String(a.number).localeCompare(String(b.number))); | |
| const done = SUBS.filter(s => s.status === 'submitted' || s.status === 'ended_checklist').length; | |
| $('#count').textContent = `${done} of ${SUBS.length} reviewed`; | |
| $('#prog').style.width = SUBS.length ? (100 * done / SUBS.length) + '%' : 0; | |
| const word = {off: 'not started', draft: 'draft saved', done: 'submitted'}; | |
| const lamp = (v, i) => `<i class="${v || 'none'}" title="${i ? 'Another judge' : 'You'}: ${v ? word[v] : 'no judge'}"></i>`; | |
| const isDone = s => s.status === 'submitted' || s.status === 'ended_checklist'; | |
| const n = t => SUBS.filter(x => x.track === t).length, nd = t => SUBS.filter(x => x.track === t && isDone(x)).length; | |
| const tracks = [...new Set(SUBS.map(s => s.track))]; | |
| $('#tprog').innerHTML = tracks.map(t => `<div class="tr ${esc(t || '')}"><b>${esc((t || '?').toUpperCase())}</b><div class="tbar" title="${nd(t)} of ${n(t)} reviewed"><i style="width:${n(t) ? 100 * nd(t) / n(t) : 0}%"></i></div><span>${nd(t)} / ${n(t)}</span></div>`).join(''); | |
| $('#tprog').hidden = !tracks.length; | |
| $('#subs').innerHTML = SUBS.map((s, i) => (i === 0 || SUBS[i - 1].track !== s.track | |
| ? `<li class="grp"><button class="gh ${SHUT.has(s.track) ? 'shut' : ''}" data-g="${esc(s.track)}" aria-expanded="${!SHUT.has(s.track)}"><span class="chev">▾</span>${esc(FORM.labels[s.track] ? 'Track ' + s.track.slice(1) : 'No track')}<span class="gn">${n(s.track)}</span></button></li>` : '') + `<li data-t="${esc(s.track)}" class="${SHUT.has(s.track) ? 'hid' : ''}"><button data-id="${esc(s.id)}" class="${s.id === cur ? 'on' : ''}"> | |
| <span class="trk ${esc(s.track || '')}" title="${esc(FORM.labels[s.track] || '')}">${esc((s.track || '?').toUpperCase())}</span><span class="num">#${esc(s.number)}</span><span class="nm">${esc(s.team_name)}</span> | |
| <span class="lights">${(s.lights || []).map(lamp).join('')}</span></button></li>`).join(''); | |
| $('#subs').querySelectorAll('button[data-id]').forEach(b => b.onclick = () => open(b.dataset.id)); | |
| $('#subs').querySelectorAll('button.gh').forEach(b => b.onclick = () => toggleGroup(b.dataset.g)); | |
| } | |
| // collapsed track groups, remembered per browser | |
| let SHUT = new Set(); | |
| try { SHUT = new Set(JSON.parse(localStorage.getItem('judging:shut') || '[]')); } catch (e) {} | |
| function toggleGroup(t, open) { | |
| const shut = open === undefined ? !SHUT.has(t) : !open; | |
| shut ? SHUT.add(t) : SHUT.delete(t); | |
| try { localStorage.setItem('judging:shut', JSON.stringify([...SHUT])); } catch (e) {} | |
| $('#subs').querySelectorAll(`li[data-t="${t}"]`).forEach(li => li.classList.toggle('hid', shut)); | |
| const g = $(`#subs button.gh[data-g="${t}"]`); if (g) { g.classList.toggle('shut', shut); g.setAttribute('aria-expanded', !shut); } | |
| } | |
| async function open(id) { | |
| if (!id) { $('#main').innerHTML = '<div class="card"><p class="empty">No submissions to review yet.</p></div>'; return; } | |
| if (dirty && id !== cur && !confirm('You have unsaved changes. Leave without saving?')) return; | |
| cur = id; dirty = false; location.hash = id; | |
| const st = (SUBS.find(x => x.id === id) || {}).track; if (SHUT.has(st)) toggleGroup(st, true); | |
| $('#subs').querySelectorAll('button').forEach(b => b.classList.toggle('on', b.dataset.id === id)); | |
| const r = (await api('/api/review/' + encodeURIComponent(id))).body; | |
| A = r.answers || {}; | |
| try { const d = JSON.parse(localStorage.getItem(key()) || 'null'); if (d && d.t > Date.parse(r.updated || 0)) { A = d.a; dirty = true; } } catch (e) {} | |
| render(); | |
| msg(r.updated ? `Last saved ${new Date(r.updated).toLocaleString()}` : (locked ? 'Reviews are locked.' : 'Not saved yet.')); | |
| window.scrollTo(0, 0); | |
| } | |
| const key = () => `judging:${ME.judge}:${cur}`; | |
| const link = v => /^https?:\/\//.test(v || '') ? `<a class="u" href="${esc(v)}" target="_blank" rel="noopener">${esc(v.replace(/^https?:\/\/(www\.)?/, ''))}</a>` : esc(v || '–'); | |
| function render(showMissing) { | |
| const s = SUBS.find(x => x.id === cur), m = s.members || []; | |
| const [secs, ended] = visibleSections(A), miss = showMissing ? new Set(missing(A)) : new Set(); | |
| const row = (k, v, c) => `<div class="row ${c || ''}"><dt>${k}</dt><dd>${v}</dd></div>`; | |
| const mail = v => v ? `<a class="u" href="mailto:${esc(v)}">${esc(v)}</a>` : '–'; | |
| let h = `<section class="card"> | |
| <div class="sub-title"><h1>${esc(s.team_name || 'XXX')}</h1><span class="tag">Submission #${esc(s.number)}</span></div> | |
| <div class="meta"> | |
| <dl>${row('Team Member 1', esc(m[0] || '–'))}${row('Team Member 2', esc(m[1] || '–'))}${row('Team Member 3', esc(m[2] || '–'))}${row('Track', esc(FORM.labels[s.track] || 'Not assigned yet'))}</dl> | |
| <dl>${row('HF Dataset collection', link(s.datasets))}${row('HF Models collection', link(s.models))}${row('HF article write-up', link(s.article))}${row('Submission Number', esc(s.number))}</dl> | |
| </div></section> | |
| <section class="card"><h3 class="more-h">More from the submission form</h3> | |
| <dl class="meta2"> | |
| ${row('Project', esc(s.project || s.team_name || '–'))}${row('Email', mail(s.email))} | |
| ${row('GitHub repo', link(s.github))}${row('Discord', esc(s.discord || '–'))} | |
| ${row('Tracks chosen', esc(s.tracks_chosen || '–'), 'wide')} | |
| </dl></section>`; | |
| secs.forEach((sec, i) => { | |
| h += `<section class="card sec"><h3><span class="n">${sec.num}</span>${esc(sec.title)}</h3>`; | |
| for (const f of sec.fields) { | |
| if (!cond(f.show_if, A)) continue; | |
| h += `<div class="q ${miss.has(f.id) ? 'missing' : ''}" data-q="${f.id}"><div class="q-label">${esc(f.label)}${f.optional ? '' : '<span class="req">*</span>'}</div>`; | |
| if (f.hint) h += `<div class="q-hint">${esc(f.hint)}</div>`; | |
| if (f.type === 'choice') { | |
| h += `<div class="opts ${f.layout === 'stack' ? 'stack' : ''}">` + f.options.map(o => | |
| `<button type="button" class="opt ${A[f.id] === o ? 'on' : ''}" data-f="${f.id}" data-v="${o}" ${locked ? 'disabled' : ''}><span class="dot"></span>${esc(FORM.labels[o] || o)}</button>`).join('') + '</div>'; | |
| } else if (f.type === 'number') { | |
| const v = A[f.id] ?? ''; | |
| h += `<div class="num-wrap"><input type="number" inputmode="numeric" min="${f.min}" max="${f.max}" step="1" value="${esc(v)}" data-f="${f.id}" ${locked ? 'disabled' : ''}> | |
| <span class="of">/ ${f.max}</span><input type="range" min="${f.min}" max="${f.max}" step="1" value="${v === '' ? f.min : esc(v)}" data-r="${f.id}" ${locked ? 'disabled' : ''}></div>`; | |
| } else { | |
| h += `<textarea rows="${f.rows || 3}" data-f="${f.id}" ${locked ? 'disabled' : ''}>${esc(A[f.id] || '')}</textarea>`; | |
| } | |
| h += '</div>'; | |
| } | |
| if (ended && i === secs.length - 1) h += `<div class="ended"><b>Grading ends here.</b> ${esc(sec.ends_note || '')} You can still submit this review.</div>`; | |
| h += '</section>'; | |
| }); | |
| $('#main').innerHTML = h; | |
| $('#main').querySelectorAll('.opt').forEach(b => b.onclick = () => { A[b.dataset.f] = b.dataset.v; changed(true); }); | |
| $('#main').querySelectorAll('input[type=number]').forEach(i => i.oninput = () => { | |
| A[i.dataset.f] = i.value === '' ? '' : Math.max(+i.min, Math.min(+i.max, Math.round(+i.value))); | |
| if (i.value !== '' && +i.value !== A[i.dataset.f]) i.value = A[i.dataset.f]; | |
| const r = $(`input[data-r="${i.dataset.f}"]`); if (r && i.value !== '') r.value = A[i.dataset.f]; | |
| changed(false); | |
| }); | |
| $('#main').querySelectorAll('input[type=range]').forEach(r => r.oninput = () => { | |
| A[r.dataset.r] = +r.value; $(`input[data-f="${r.dataset.r}"]`).value = r.value; changed(false); | |
| }); | |
| $('#main').querySelectorAll('textarea').forEach(t => t.oninput = () => { A[t.dataset.f] = t.value; changed(false); }); | |
| $('#save').disabled = $('#submit').disabled = locked; | |
| } | |
| function changed(rerender) { | |
| dirty = true; | |
| try { localStorage.setItem(key(), JSON.stringify({t: Date.now(), a: A})); } catch (e) {} | |
| msg('Unsaved changes.'); | |
| if (rerender) { const y = window.scrollY; render(); window.scrollTo(0, y); } | |
| } | |
| function msg(t, cls) { const m = $('#msg'); m.textContent = t; m.className = 'msg ' + (cls || ''); } | |
| async function save(final) { | |
| if (final) { | |
| const m = missing(A); | |
| if (m.length) { | |
| render(true); | |
| const el = document.querySelector(`[data-q="${m[0]}"]`); if (el) el.scrollIntoView({behavior: 'smooth', block: 'center'}); | |
| return msg(`${m.length} required question${m.length > 1 ? 's' : ''} left.`, 'err'); | |
| } | |
| } | |
| $('#save').disabled = $('#submit').disabled = true; msg('Saving…'); | |
| const r = await api('/api/review/' + encodeURIComponent(cur), {method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({answers: A, final})}); | |
| $('#save').disabled = $('#submit').disabled = false; | |
| if (!r.ok) return msg(r.body?.error || r.body?.detail || (r.body?.missing ? 'Some required questions are missing.' : 'Could not save. Please try again.'), 'err'); | |
| dirty = false; try { localStorage.removeItem(key()); } catch (e) {} | |
| msg(final ? (r.body.status === 'ended_checklist' ? 'Submitted (ended at the checklist).' : 'Review submitted. You can still edit it until the deadline.') : 'Draft saved.', 'ok'); | |
| await loadSubs(); | |
| } | |
| $('#save').onclick = () => save(false); | |
| $('#submit').onclick = () => save(true); | |
| window.addEventListener('beforeunload', e => { if (dirty) { e.preventDefault(); e.returnValue = ''; } }); | |
| boot(); | |
| </script> | |
| </body> | |
| </html> | |