Apply ruff lint and rename cryptic identifiers to readable names
This commit is contained in:
+102
-102
@@ -1,112 +1,112 @@
|
||||
// Web UI logic: polls /status every 3 s, renders the meetings table, and wires search, Q&A, upload, crop and bulk actions to the local server.
|
||||
// Escape text for innerHTML (&, <, >, ").
|
||||
const E=s=>String(s??"").replace(/[&<>"]/g,c=>({"&":"&","<":"<",">":">",'"':"""}[c]));
|
||||
const E=value=>String(value??"").replace(/[&<>"]/g,char=>({"&":"&","<":"<",">":">",'"':"""}[char]));
|
||||
// Seconds -> mm:ss (minutes can exceed 59; no hour form here).
|
||||
const fmt=s=>{s=Math.round(s);return String(Math.floor(s/60)).padStart(2,"0")+":"+String(s%60).padStart(2,"0")};
|
||||
const fmt=seconds=>{seconds=Math.round(seconds);return String(Math.floor(seconds/60)).padStart(2,"0")+":"+String(seconds%60).padStart(2,"0")};
|
||||
// Enter in the search box runs the search.
|
||||
q.onkeydown=e=>{if(e.key=="Enter")srch()};
|
||||
q.onkeydown=event=>{if(event.key==="Enter")srch()};
|
||||
// Enter in the Q&A box asks the question.
|
||||
qa.onkeydown=e=>{if(e.key=="Enter")ask()};
|
||||
qa.onkeydown=event=>{if(event.key==="Enter")ask()};
|
||||
// Close button appended after results: clears the input and the result box.
|
||||
const CLOSE=(i,o)=>`<div><button onclick="${i}.value='';${o}.innerHTML=''">✕ chiudi</button></div>`;
|
||||
const CLOSE=(target,output)=>`<div><button onclick="${target}.value='';${output}.innerHTML=''">✕ chiudi</button></div>`;
|
||||
// Q&A: /ask_stream sends NDJSON events ({sources} first, then {t} text pieces); the answer is redrawn as it grows. The model may take minutes to load on first use.
|
||||
async function ask(){if(!qa.value)return;ar.innerHTML="<small>…avvio modelli / risposta (può richiedere qualche minuto)</small>";
|
||||
const r=await fetch("/ask_stream?q="+encodeURIComponent(qa.value));if(!r.ok){ar.textContent=await r.text();return}
|
||||
const response=await fetch("/ask_stream?q="+encodeURIComponent(qa.value));if(!response.ok){ar.textContent=await response.text();return}
|
||||
let src=[],txt="",buf="",fin=false;
|
||||
// Turn citation markers [n] into links to the matching report section; keep the marker if the source is missing. Sources list and close button appear when the stream ends.
|
||||
// Minimal markdown -> HTML (on escaped text): headings, bullet/numbered lists, **bold**, *italic*, `code`; blank-line separated paragraphs.
|
||||
const MD=t=>{let h="",ul=false;const il=s=>s.replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*(.+?)\*\*/g,"<b>$1</b>").replace(/(^|\W)\*([^*\s][^*]*?)\*/g,"$1<i>$2</i>");
|
||||
for(const l of E(t).split("\n")){const m=l.match(/^\s*(?:[-*]|\d+\.) (.*)/);if(m){if(!ul){h+="<ul>";ul=true}h+="<li>"+il(m[1])+"</li>";continue}
|
||||
if(ul){h+="</ul>";ul=false}const g=l.match(/^#{1,6} (.*)/);if(g)h+="<h4>"+il(g[1])+"</h4>";else if(l.trim())h+="<p>"+il(l)+"</p>"}
|
||||
return h+(ul?"</ul>":"")};
|
||||
const lk=n=>{const s=src[n-1];return s?`<a href="/report?name=${encodeURIComponent(s.name)}#${encodeURIComponent(s.anchor)}" target=_blank title="${E(s.meeting)} — ${E(s.topic)}">${n}</a>`:n};
|
||||
const MD=text=>{let html="",ul=false;const inlineMd=str=>str.replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*(.+?)\*\*/g,"<b>$1</b>").replace(/(^|\W)\*([^*\s][^*]*?)\*/g,"$1<i>$2</i>");
|
||||
for(const line of E(text).split("\n")){const item=line.match(/^\s*(?:[-*]|\d+\.) (.*)/);if(item){if(!ul){html+="<ul>";ul=true}html+="<li>"+inlineMd(item[1])+"</li>";continue}
|
||||
if(ul){html+="</ul>";ul=false}const heading=line.match(/^#{1,6} (.*)/);if(heading)html+="<h4>"+inlineMd(heading[1])+"</h4>";else if(line.trim())html+="<p>"+inlineMd(line)+"</p>"}
|
||||
return html+(ul?"</ul>":"")};
|
||||
const lk=num=>{const source=src[num-1];return source?`<a href="/report?name=${encodeURIComponent(source.name)}#${encodeURIComponent(source.anchor)}" target=_blank title="${E(source.meeting)} — ${E(source.topic)}">${num}</a>`:num};
|
||||
// [n], [1][2] and [1, 2] all become links; each number opens report.html at that source's section.
|
||||
const draw=()=>{ar.innerHTML=`<div class=md>`+MD(txt).replace(/\[(\d+(?:\s*[,;]\s*\d+)*)\]/g,(m,l)=>"["+l.replace(/\d+/g,lk)+"]")+"</div>"+
|
||||
(fin?(src.length?`<details><summary><small>Fonti (${src.length})</small></summary>`+src.map(s=>`<div><small>[${lk(s.n)}] ${E(s.date)} ${E(s.meeting)} — ${E(s.topic)} <a href="#" title="riproduci il video da qui" onclick="play('${s.name}',0,'${E(s.meeting+" "+s.date).replace(/'/g,"")}',${+s.t||0});return false">▶ ${fmt(s.t)}</a> (${s.kind}): ${E(s.text)}</small></div>`).join("")+"</details>":"")+CLOSE("qa","ar"):"")};
|
||||
const rd=r.body.getReader(),dc=new TextDecoder();
|
||||
const draw=()=>{ar.innerHTML=`<div class=md>`+MD(txt).replace(/\[(\d+(?:\s*[,;]\s*\d+)*)\]/g,(match,group)=>"["+group.replace(/\d+/g,lk)+"]")+"</div>"+
|
||||
(fin?(src.length?`<details><summary><small>Fonti (${src.length})</small></summary>`+src.map(source=>`<div><small>[${lk(source.n)}] ${E(source.date)} ${E(source.meeting)} — ${E(source.topic)} <a href="#" title="riproduci il video da qui" onclick="play('${source.name}',0,'${E(source.meeting+" "+source.date).replace(/'/g,"")}',${+source.t||0});return false">▶ ${fmt(source.t)}</a> (${source.kind}): ${E(source.text)}</small></div>`).join("")+"</details>":"")+CLOSE("qa","ar"):"")};
|
||||
const rd=response.body.getReader(),dc=new TextDecoder();
|
||||
for(;;){const {value,done}=await rd.read();if(done)break;buf+=dc.decode(value,{stream:true});const ls=buf.split("\n");buf=ls.pop();
|
||||
for(const l of ls){const e=JSON.parse(l);if(e.sources)src=e.sources;else if(e.err)txt+="\n[errore: "+e.err+"]";else txt+=e.t}draw()}
|
||||
for(const line of ls){const event=JSON.parse(line);if(event.sources)src=event.sources;else if(event.err)txt+="\n[errore: "+event.err+"]";else txt+=event.t}draw()}
|
||||
fin=true;draw()}
|
||||
// Search over speech and screen text (/search).
|
||||
async function srch(){if(!q.value){sr.innerHTML="";return}const j=await (await fetch("/search?q="+encodeURIComponent(q.value))).json();
|
||||
async function srch(){if(!q.value){sr.innerHTML="";return}const results=await (await fetch("/search?q="+encodeURIComponent(q.value))).json();
|
||||
// Speech hits: [meeting, seconds, speaker, text]. Screen hits: [meeting, seconds, speaker, text, shot file] and link to the screenshot.
|
||||
sr.innerHTML=j.speech.map(r=>`<div>${E(r[0])} ${fmt(r[1])} ${E(r[2]||"")}: ${E(r[3])}</div>`).join("")+j.screen.map(r=>`<div>🖥 <a href="/shot?name=${r[0]}&file=shots/${r[4]}" target=_blank>${E(r[0])} ${fmt(r[1])}</a> ${E(r[2]||"")}: ${E(r[3])}</div>`).join("")+CLOSE("q","sr")}
|
||||
sr.innerHTML=results.speech.map(hit=>`<div>${E(hit[0])} ${fmt(hit[1])} ${E(hit[2]||"")}: ${E(hit[3])}</div>`).join("")+results.screen.map(hit=>`<div>🖥 <a href="/shot?name=${hit[0]}&file=shots/${hit[4]}" target=_blank>${E(hit[0])} ${fmt(hit[1])}</a> ${E(hit[2]||"")}: ${E(hit[3])}</div>`).join("")+CLOSE("q","sr")}
|
||||
// Start a pipeline run from the chosen step (/run); 409 means it is already running.
|
||||
async function run(n){const f=document.getElementById("f-"+n).value;const r=await fetch(`/run?name=${n}&from=${f}`,{method:"POST"});if(r.status==409)alert("già in esecuzione");tick()}
|
||||
async function run(name){const step=document.getElementById("f-"+name).value;const response=await fetch(`/run?name=${name}&from=${step}`,{method:"POST"});if(response.status===409)alert("già in esecuzione");tick()}
|
||||
// Names of the checked recording rows (.mg checkboxes).
|
||||
const sel_=()=>[...document.querySelectorAll(".mg:checked")].map(x=>x.value);
|
||||
// Show the bulk bar only when something is checked, and show the selected count.
|
||||
function upd(){const n=sel_().length;bulk.hidden=!n;bn.textContent=`${n} selezionat${n==1?"a":"e"}`}
|
||||
function upd(){const count=sel_().length;bulk.hidden=!count;bn.textContent=`${count} selezionat${count===1?"a":"e"}`}
|
||||
// Check or uncheck all recording rows.
|
||||
function selAll(v){document.querySelectorAll(".mg").forEach(x=>x.checked=!!v);upd()}
|
||||
function selAll(on){document.querySelectorAll(".mg").forEach(box=>box.checked=!!on);upd()}
|
||||
// Run one POST per selected recording and collect failures into a single alert.
|
||||
async function bulk_(path,names,label){let bad=[];for(const n of names){const r=await fetch(`${path}${path.includes("?")?"&":"?"}name=${n}`,{method:"POST"});if(!r.ok)bad.push(`${n}: ${await r.text()}`)}
|
||||
async function bulk_(path,names,label){let bad=[];for(const name of names){const response=await fetch(`${path}${path.includes("?")?"&":"?"}name=${name}`,{method:"POST"});if(!response.ok)bad.push(`${name}: ${await response.text()}`)}
|
||||
if(bad.length)alert(`${label}: ${names.length-bad.length}/${names.length} ok\n`+bad.join("\n"));tick()}
|
||||
// Re-run the selected recordings from the step chosen in #bf.
|
||||
function bulkRun(){bulk_("/run?from="+bf.value,sel_(),"rielaborazione")}
|
||||
// Bulk delete of video files only; report, transcript and screenshots are kept.
|
||||
function bulkDrop(){const n=sel_();if(confirm(`Eliminare i file video di ${n.length} riunioni?
|
||||
Report, trascrizione, audio e schermate restano, ma non potranno più essere rielaborate. Non si può annullare.`))bulk_("/drop_video",n,"elimina video")}
|
||||
function bulkDrop(){const names=sel_();if(confirm(`Eliminare i file video di ${names.length} riunioni?
|
||||
Report, trascrizione, audio e schermate restano, ma non potranno più essere rielaborate. Non si può annullare.`))bulk_("/drop_video",names,"elimina video")}
|
||||
// Bulk delete of whole recordings; asks for confirmation first.
|
||||
function bulkDel(){const n=sel_();if(confirm(`Eliminare definitivamente ${n.length} riunioni?
|
||||
Vengono cancellati registrazione, trascrizione, schermate e report. Non si può annullare.`))bulk_("/delete",n,"elimina")}
|
||||
function bulkDel(){const names=sel_();if(confirm(`Eliminare definitivamente ${names.length} riunioni?
|
||||
Vengono cancellati registrazione, trascrizione, schermate e report. Non si può annullare.`))bulk_("/delete",names,"elimina")}
|
||||
// Merge two or more checked recordings (same meeting restarted) into one.
|
||||
async function mergeSel(){const n=sel_();if(n.length<2)return alert("spunta almeno 2 registrazioni");const r=await fetch("/merge?names="+n.join(","),{method:"POST"});if(!r.ok)alert(await r.text());tick()}
|
||||
async function mergeSel(){const names=sel_();if(names.length<2)return alert("spunta almeno 2 registrazioni");const response=await fetch("/merge?names="+names.join(","),{method:"POST"});if(!response.ok)alert(await response.text());tick()}
|
||||
// Names whose speakers panel is open; kept across re-renders.
|
||||
const open_=new Set();
|
||||
// Toggle the speakers panel for one recording and re-render.
|
||||
async function spk(n){editing=false;open_.has(n)?open_.delete(n):open_.add(n);tick()}
|
||||
async function spk(name){editing=false;open_.has(name)?open_.delete(name):open_.add(name);tick()}
|
||||
// Speakers panel: diarization label -> person mapping, with a datalist of candidate names.
|
||||
async function panel(n){const j=await (await fetch("/speakers?name="+n)).json();
|
||||
return `<tr class=sp><td colspan=7><datalist id="cand-${n}">${j.candidates.map(c=>`<option value="${E(c)}">`).join("")}</datalist>`+
|
||||
j.rows.map(r=>`<div><b>${E(r.label)}</b> ${fmt(r.talk_s)} <input data-n="${n}" data-l="${E(r.label)}" list="cand-${n}" value="${E(r.person)}"> ${r.source}${r.source=="auto"&&r.overlap_s!=null?" "+Math.round(r.overlap_s)+"s":""}<br><small>${r.samples.map(E).join(" | ")}</small></div>`).join("")+
|
||||
`<div class=sa><button class=pri onclick="saveSpk('${n}')">✓ Salva nomi</button><button onclick="spk('${n}')">✕ Chiudi</button></div>`}
|
||||
async function panel(name){const data=await (await fetch("/speakers?name="+name)).json();
|
||||
return `<tr class=sp><td colspan=7><datalist id="cand-${name}">${data.candidates.map(candidate=>`<option value="${E(candidate)}">`).join("")}</datalist>`+
|
||||
data.rows.map(row=>`<div><b>${E(row.label)}</b> ${fmt(row.talk_s)} <input data-n="${name}" data-l="${E(row.label)}" list="cand-${name}" value="${E(row.person)}"> ${row.source}${row.source==="auto"&&row.overlap_s!=null?" "+Math.round(row.overlap_s)+"s":""}<br><small>${row.samples.map(E).join(" | ")}</small></div>`).join("")+
|
||||
`<div class=sa><button class=pri onclick="saveSpk('${name}')">✓ Salva nomi</button><button onclick="spk('${name}')">✕ Chiudi</button></div>`}
|
||||
// Read the label -> person inputs and save them (/speaker_map).
|
||||
async function saveSpk(n){const m={};document.querySelectorAll(`input[data-n="${n}"]`).forEach(i=>m[i.dataset.l]=i.value);
|
||||
const r=await fetch("/speaker_map?name="+n,{method:"POST",body:JSON.stringify(m)});editing=false;const t=await r.text();open_.delete(n);tick();alert(t)}
|
||||
async function saveSpk(name){const labels={};document.querySelectorAll(`input[data-n="${name}"]`).forEach(input=>labels[input.dataset.l]=input.value);
|
||||
const response=await fetch("/speaker_map?name="+name,{method:"POST",body:JSON.stringify(labels)});editing=false;const text=await response.text();open_.delete(name);tick();alert(text)}
|
||||
// Recompute the automatic title from the report.
|
||||
async function retitle(n){const r=await fetch(`/run?name=${n}&from=title`,{method:"POST"});if(!r.ok)alert(await r.text());tick()}
|
||||
async function retitle(name){const response=await fetch(`/run?name=${name}&from=title`,{method:"POST"});if(!response.ok)alert(await response.text());tick()}
|
||||
const sel={};
|
||||
// Delete one recording after confirmation.
|
||||
async function del_(n,label){if(!confirm(`Eliminare definitivamente "${label}"?
|
||||
async function del_(name,label){if(!confirm(`Eliminare definitivamente "${label}"?
|
||||
Vengono cancellati registrazione, trascrizione, schermate e report. Non si può annullare.`))return;
|
||||
const r=await fetch("/delete?name="+n,{method:"POST"});if(!r.ok)alert(await r.text());tick()}
|
||||
const response=await fetch("/delete?name="+name,{method:"POST"});if(!response.ok)alert(await response.text());tick()}
|
||||
// Delete only the video file of one recording (report and transcript stay).
|
||||
async function dropVid(n,mb){if(!confirm(`Eliminare il file video (${mb} MB)?
|
||||
async function dropVid(name,mb){if(!confirm(`Eliminare il file video (${mb} MB)?
|
||||
Report, trascrizione, audio e schermate restano, ma la riunione non potrà più essere rielaborata. Non si può annullare.`))return;
|
||||
const r=await fetch("/drop_video?name="+n,{method:"POST"});if(!r.ok)alert(await r.text());tick()}
|
||||
const response=await fetch("/drop_video?name="+name,{method:"POST"});if(!response.ok)alert(await response.text());tick()}
|
||||
// Prompt for a new title; empty means automatic. The date suffix is stripped from the default text.
|
||||
async function setTitle(n,cur){const t=prompt("Titolo della riunione (vuoto = automatico)",cur.replace(/ — \d{4}-\d\d-\d\d.*$/,""));if(t===null)return;
|
||||
const r=await fetch("/title?name="+n,{method:"POST",body:t});if(!r.ok)alert(await r.text());tick()}
|
||||
async function setTitle(name,cur){const title=prompt("Titolo della riunione (vuoto = automatico)",cur.replace(/ — \d{4}-\d\d-\d\d.*$/,""));if(title===null)return;
|
||||
const response=await fetch("/title?name="+name,{method:"POST",body:title});if(!response.ok)alert(await response.text());tick()}
|
||||
// "mm:ss" or "h:mm:ss" -> seconds.
|
||||
const sec=s=>s.trim().split(":").reduce((a,x)=>a*60+(+x),0);
|
||||
const sec=str=>str.trim().split(":").reduce((acc,part)=>acc*60+(+part),0);
|
||||
// Open the preview dialog for recording n; the video is streamed from /video. Optional at = seconds to start playing from (used by the Q&A sources).
|
||||
function play(n,d,t,at){cv.src="/video?name="+n;ctitle.textContent=t;cs.value="00:00";ce.value=d?fmt(d):"";cmsg.textContent="";cv.onloadedmetadata=()=>{if(!ce.value&&isFinite(cv.duration))ce.value=fmt(cv.duration);if(at>0){cv.currentTime=at;cv.play().catch(()=>{})}};cdlg.showModal()}
|
||||
function play(name,duration,title,start){cv.src="/video?name="+name;ctitle.textContent=title;cs.value="00:00";ce.value=duration?fmt(duration):"";cmsg.textContent="";cv.onloadedmetadata=()=>{if(!ce.value&&isFinite(cv.duration))ce.value=fmt(cv.duration);if(start>0){cv.currentTime=start;cv.play().catch(()=>{})}};cdlg.showModal()}
|
||||
// Stop and unload the video so the file handle is released.
|
||||
function cclose(){cv.pause();cv.removeAttribute("src");cv.load();cdlg.close()}
|
||||
// Esc closes the dialog through the same cleanup.
|
||||
cdlg.addEventListener("cancel",cclose);
|
||||
// Play from the start time; pause at the end time when one is set.
|
||||
function cplay(){cv.currentTime=sec(cs.value);cv.play();const e=sec(ce.value);cv.ontimeupdate=()=>{if(e>0&&cv.currentTime>=e){cv.pause();cv.ontimeupdate=null}}}
|
||||
function cplay(){cv.currentTime=sec(cs.value);cv.play();const endTime=sec(ce.value);cv.ontimeupdate=()=>{if(endTime>0&&cv.currentTime>=endTime){cv.pause();cv.ontimeupdate=null}}}
|
||||
// Crop: inplace replaces the original (after confirm); otherwise a new meeting is created from the clip.
|
||||
async function cgo(inplace){const a=sec(cs.value),b=sec(ce.value),n=new URL(cv.src).searchParams.get("name");
|
||||
async function cgo(inplace){const start=sec(cs.value),end=sec(ce.value),name=new URL(cv.src).searchParams.get("name");
|
||||
// Validate the interval: start >= 0 and end after start.
|
||||
if(!(a>=0&&b>a)){cmsg.textContent="intervallo non valido";return}
|
||||
if(!(start>=0&&end>start)){cmsg.textContent="intervallo non valido";return}
|
||||
// Replacing the original is irreversible, so confirm first.
|
||||
if(inplace&&!confirm("Sostituire il video di questa riunione con il ritaglio? L'originale va perso e la riunione viene rielaborata da zero."))return;
|
||||
if(inplace){cv.pause();cv.removeAttribute("src");cv.load()} // release the file: Windows can't replace a source the browser has open
|
||||
// Disable both crop buttons while the re-encode runs.
|
||||
cgo_.disabled=cgi_.disabled=true;cmsg.textContent="ritaglio in corso… (ricodifica, può richiedere minuti)";cpr.value=0;cpr.hidden=false;
|
||||
// Poll crop progress every 700 ms while the blocking /crop request is pending.
|
||||
const iv=setInterval(async()=>{try{const p=(await(await fetch("/crop_progress?name="+n,{method:"POST"})).json()).pct;if(p!=null){cpr.value=p;cmsg.textContent=`ritaglio in corso… ${Math.round(p)}%`}}catch(e){}},700);
|
||||
const iv=setInterval(async()=>{try{const percent=(await(await fetch("/crop_progress?name="+name,{method:"POST"})).json()).pct;if(percent!=null){cpr.value=percent;cmsg.textContent=`ritaglio in corso… ${Math.round(percent)}%`}}catch{/* poll failed: next tick retries */}},700);
|
||||
// Blocking request: the server re-encodes the clip, which can take minutes.
|
||||
const r=await fetch(`/crop?name=${n}&start=${a}&end=${b}${inplace?"&inplace=1":""}`,{method:"POST"});clearInterval(iv);cgo_.disabled=cgi_.disabled=false;cpr.hidden=true;
|
||||
const response=await fetch(`/crop?name=${name}&start=${start}&end=${end}${inplace?"&inplace=1":""}`,{method:"POST"});clearInterval(iv);cgo_.disabled=cgi_.disabled=false;cpr.hidden=true;
|
||||
// Show the result and refresh the table.
|
||||
if(!r.ok){cmsg.textContent="errore: "+await r.text();return}cmsg.textContent=inplace?"✓ riunione ritagliata, rielaborazione avviata":"✓ creata nuova riunione, elaborazione avviata";tick()}
|
||||
if(!response.ok){cmsg.textContent="errore: "+await response.text();return}cmsg.textContent=inplace?"✓ riunione ritagliata, rielaborazione avviata":"✓ creata nuova riunione, elaborazione avviata";tick()}
|
||||
// Cancel a running or queued pipeline (after confirm).
|
||||
async function stopRun(n){if(!confirm(`Fermare ${n}?`))return;await fetch("/cancel?name="+n,{method:"POST"});tick()}
|
||||
async function stopRun(name){if(!confirm(`Fermare ${name}?`))return;await fetch("/cancel?name="+name,{method:"POST"});tick()}
|
||||
// Save the screenshot-model and report-model choice on the server.
|
||||
async function setLlm(){const r=await fetch(`/llm?shots=${llm.value}&report=${llmr.value}`,{method:"POST"});if(!r.ok)alert(await r.text());tick()}
|
||||
async function setLlm(){const response=await fetch(`/llm?shots=${llm.value}&report=${llmr.value}`,{method:"POST"});if(!response.ok)alert(await response.text());tick()}
|
||||
// Save the "skip screenshots" switch on the server.
|
||||
async function setSkip(){await fetch("/skip_shots?v="+(skp.checked?1:0),{method:"POST"});tick()}
|
||||
// Italian labels for pipeline steps.
|
||||
@@ -114,107 +114,107 @@ const LBL={audio:"Audio",transcribing:"Trascrizione",diarizing:"Chi parla",ident
|
||||
// What each step does, shown under the progress bar.
|
||||
const HOW={audio:"pulizia e normalizzazione dell'audio",transcribing:"Whisper trascrive il parlato",diarizing:"riconoscimento di chi parla",identifying:"abbinamento voci-nomi",shots:"il modello di visione legge ogni schermata condivisa",docs:"ricerca su Confluence e Jira",report:"il modello scrive argomenti, decisioni e azioni",memory:"indicizzazione per la ricerca tra riunioni"};
|
||||
// Seconds -> "N s", "N min" or "H h MM min".
|
||||
const dur=s=>{if(s==null||!isFinite(s))return"–";s=Math.max(0,Math.round(s));if(s<60)return s+" s";const m=Math.round(s/60);return m<60?m+" min":Math.floor(m/60)+" h "+String(m%60).padStart(2,"0")+" min"};
|
||||
const dur=seconds=>{if(seconds==null||!isFinite(seconds))return"–";seconds=Math.max(0,Math.round(seconds));if(seconds<60)return seconds+" s";const minutes=Math.round(seconds/60);return minutes<60?minutes+" min":Math.floor(minutes/60)+" h "+String(minutes%60).padStart(2,"0")+" min"};
|
||||
// Seconds from now -> local HH:MM.
|
||||
const clock=s=>new Date(Date.now()+s*1000).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});
|
||||
const clock=seconds=>new Date(Date.now()+seconds*1000).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});
|
||||
// Per recording: last [timestamp, tokens decoded], used to compute tokens/s between ticks.
|
||||
const LT={};
|
||||
// LLM activity line: prompt reading vs token writing; idle time sets the severity colour.
|
||||
function live(n,p){const l=p.llm;let txt="",act=false;
|
||||
function live(name,prog){const l=prog.llm;let txt="",act=false;
|
||||
// Model is busy: compare token counts with the previous tick.
|
||||
if(l&&l.is_processing){act=true;const k=n,prev=LT[k],now=Date.now(),d=l.n_decoded||0;
|
||||
if(info&&info.is_processing){act=true;const key=name,prev=LT[key],now=Date.now(),decoded=info.n_decoded||0;
|
||||
// Tokens/s from the delta since the previous tick.
|
||||
if(d>0){const tps=prev&&d>prev[1]?(d-prev[1])/((now-prev[0])/1000):null;txt=`Il modello sta scrivendo: <b>${d}</b> token${tps?` · <b>${tps.toFixed(1)}</b> token/s`:""}`}
|
||||
else txt=`Il modello sta leggendo il contesto: <b>${l.n_prompt_tokens_processed||0}</b> di ${l.n_prompt_tokens} token`;
|
||||
if(decoded>0){const tps=prev&&decoded>prev[1]?(decoded-prev[1])/((now-prev[0])/1000):null;txt=`Il modello sta scrivendo: <b>${decoded}</b> token${tps?` · <b>${tps.toFixed(1)}</b> token/s`:""}`}
|
||||
else txt=`Il modello sta leggendo il contesto: <b>${info.n_prompt_tokens_processed||0}</b> di ${info.n_prompt_tokens} token`;
|
||||
// Store this sample for the next tick.
|
||||
LT[k]=[now,d]}
|
||||
LT[key]=[now,decoded]}
|
||||
// Severity by idle time: under 90 s ok, under 300 s warn, otherwise bad.
|
||||
const idle=p.idle,cls=act||idle<90?"":idle<300?"warn":"bad";
|
||||
const idle=prog.idle,cls=act||idle<90?"":idle<300?"warn":"bad";
|
||||
// Status text for the idle time.
|
||||
const tail=act?`ultimo passo completato ${dur(idle)} fa`:idle<90?`attivo · aggiornato ${dur(idle)} fa`:idle<300?`nessun avanzamento da <b>${dur(idle)}</b>: può essere normale (avvio modello, passo lungo)`:`nessuna attività da <b>${dur(idle)}</b>: possibile blocco, controlla il log Prefect o premi stop`;
|
||||
return `<div class="live ${cls}"><span class=dot></span><span>${txt?txt+" — ":""}${tail}</span></div>`}
|
||||
// Progress panel for a recording: boot, queued, or running pipeline.
|
||||
function progPanel(r){const p=r.prog;
|
||||
function progPanel(row){const prog=row.prog;
|
||||
// Pipeline starting: the Python environment can take minutes on the first run.
|
||||
if(!p&&r.running)return `<tr><td colspan=7><div class=pg><div class=pgh><span><span class=big>…</span> <b>Avvio della pipeline</b> <span class=n>— preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)</span></span></div><div class="bar ind"><i></i></div><div class="live"><span class=dot></span><span>${E(r.boot||"in avvio…")}</span></div></div>`;
|
||||
if(!prog&&row.running)return `<tr><td colspan=7><div class=pg><div class=pgh><span><span class=big>…</span> <b>Avvio della pipeline</b> <span class=n>— preparazione dell'ambiente Python (la prima volta scarica le dipendenze: qualche minuto)</span></span></div><div class="bar ind"><i></i></div><div class="live"><span class=dot></span><span>${E(row.boot||"in avvio…")}</span></div></div>`;
|
||||
// Queued behind another run, or nothing to show.
|
||||
if(!p)return r.status=="queued"?`<tr><td colspan=7><div class=pg><div class=pgh><b>In coda</b><span class=eta>parte appena finisce l'elaborazione in corso</span></div><div class="bar ind"><i></i></div></div>`:"";
|
||||
if(!prog)return row.status==="queued"?`<tr><td colspan=7><div class=pg><div class=pgh><b>In coda</b><span class=eta>parte appena finisce l'elaborazione in corso</span></div><div class="bar ind"><i></i></div></div>`:"";
|
||||
// Overall percent (null if unknown) and the running step.
|
||||
const pct=p.pct!=null?Math.round(p.pct*100):null,cur=p.plan.find(x=>x.state=="run");
|
||||
const pct=prog.pct!=null?Math.round(prog.pct*100):null,cur=prog.plan.find(stage=>stage.state==="run");
|
||||
// Step chips: skipped / done with duration / running with fraction / pending with estimate.
|
||||
const chips=p.plan.map(x=>x.state=="skip"?`<span class="st skip" title="non rieseguito">${LBL[x.s]}</span>`:x.state=="done"?`<span class="st ok">✓ ${LBL[x.s]} · ${dur(x.secs)}</span>`:x.state=="run"?`<span class="st run">● ${LBL[x.s]} · ${Math.round(x.frac*100)}%</span>`:`<span class=st>${LBL[x.s]} · ~${dur(x.est)}</span>`).join("");
|
||||
const chips=prog.plan.map(stage=>stage.state==="skip"?`<span class="st skip" title="non rieseguito">${LBL[stage.s]}</span>`:stage.state==="done"?`<span class="st ok">✓ ${LBL[stage.s]} · ${dur(stage.secs)}</span>`:stage.state==="run"?`<span class="st run">● ${LBL[stage.s]} · ${Math.round(stage.frac*100)}%</span>`:`<span class=st>${LBL[stage.s]} · ~${dur(stage.est)}</span>`).join("");
|
||||
// Done-of-total counter and step label.
|
||||
const cnt=p.total?`${p.done} di ${p.total}`:"",step=LBL[p.step]||p.step;
|
||||
const cnt=prog.total?`${prog.done} di ${prog.total}`:"",step=LBL[prog.step]||prog.step;
|
||||
// Panel markup: header, progress bars, step chips and live status.
|
||||
return `<tr><td colspan=7><div class=pg>
|
||||
<div class=pgh><span><span class=big>${pct!=null?pct+"%":"…"}</span> <b>${step}</b> <span class=n>— ${E(p.note||HOW[p.step]||"")}</span></span>
|
||||
<span class=eta>${p.eta!=null?`fine prevista <b>~${clock(p.eta)}</b> · mancano <b>${dur(p.eta)}</b> · `:""}trascorso ${dur(p.elapsed)}</span></div>
|
||||
<div class=pgh><span><span class=big>${pct!=null?pct+"%":"…"}</span> <b>${step}</b> <span class=n>— ${E(prog.note||HOW[prog.step]||"")}</span></span>
|
||||
<span class=eta>${prog.eta!=null?`fine prevista <b>~${clock(prog.eta)}</b> · mancano <b>${dur(prog.eta)}</b> · `:""}trascorso ${dur(prog.elapsed)}</span></div>
|
||||
<div class="bar${pct==null?" ind":""}"><i style="width:${pct||0}%"></i></div>
|
||||
<div class=steps>${chips}</div>
|
||||
<div class="bar thin"><i style="width:${Math.round(p.frac*100)}%"></i></div>
|
||||
<div class=sub><span>${step}: ${cnt?cnt+" · ":""}${Math.round(p.frac*100)}%</span><span>${cur?`questo passo: ancora ~${dur(cur.left)} (in corso da ${dur(cur.secs)})`:""}</span></div>
|
||||
${live(r.name,p)}</div>`}
|
||||
<div class="bar thin"><i style="width:${Math.round(prog.frac*100)}%"></i></div>
|
||||
<div class=sub><span>${step}: ${cnt?cnt+" · ":""}${Math.round(prog.frac*100)}%</span><span>${cur?`questo passo: ancora ~${dur(cur.left)} (in corso da ${dur(cur.secs)})`:""}</span></div>
|
||||
${live(row.name,prog)}</div>`}
|
||||
function pick(){up.click()}
|
||||
// Upload with XHR so we get upload progress events. Target: POST /upload?filename=.
|
||||
function send(f){const x=new XMLHttpRequest(),t0=Date.now();ub.hidden=false;ubar.style.width="0%";utitle.textContent="Caricamento di "+f.name;ubig.textContent="0%";
|
||||
function send(file){const xhr=new XMLHttpRequest(),t0=Date.now();ub.hidden=false;ubar.style.width="0%";utitle.textContent="Caricamento di "+file.name;ubig.textContent="0%";
|
||||
// Update bar, percent, MB/s and ETA from upload progress.
|
||||
x.upload.onprogress=e=>{if(!e.lengthComputable)return;const p=e.loaded/e.total,s=(Date.now()-t0)/1000,v=e.loaded/Math.max(s,.1);
|
||||
ubar.style.width=(p*100).toFixed(1)+"%";ubig.textContent=Math.floor(p*100)+"%";
|
||||
utxt.textContent=`${(e.loaded/1e6).toFixed(0)} di ${(e.total/1e6).toFixed(0)} MB · ${(v/1e6).toFixed(1)} MB/s · mancano ${dur((e.total-e.loaded)/v)}`};
|
||||
xhr.upload.onprogress=event=>{if(!event.lengthComputable)return;const fraction=event.loaded/event.total,elapsed=(Date.now()-t0)/1000,speed=event.loaded/Math.max(elapsed,.1);
|
||||
ubar.style.width=(fraction*100).toFixed(1)+"%";ubig.textContent=Math.floor(fraction*100)+"%";
|
||||
utxt.textContent=`${(event.loaded/1e6).toFixed(0)} di ${(event.total/1e6).toFixed(0)} MB · ${(speed/1e6).toFixed(1)} MB/s · mancano ${dur((event.total-event.loaded)/speed)}`};
|
||||
// Upload finished on the client; the server now validates the file and starts processing.
|
||||
x.upload.onload=()=>{utxt.textContent="File ricevuto: controllo del formato e avvio dell'elaborazione…"};
|
||||
xhr.upload.onload=()=>{utxt.textContent="File ricevuto: controllo del formato e avvio dell'elaborazione…"};
|
||||
// Success: show the recording duration; hide the card after 6 s.
|
||||
x.onload=()=>{if(x.status==200){const j=JSON.parse(x.responseText);ubig.textContent="✓";utxt.textContent=`Avviata l'elaborazione (${dur(j.duration_s)} di registrazione): segui l'avanzamento qui sotto`;setTimeout(()=>ub.hidden=true,6000)}
|
||||
else{ubig.textContent="!";utxt.textContent="Errore: "+x.responseText}tick()};
|
||||
xhr.onload=()=>{if(xhr.status===200){const data=JSON.parse(xhr.responseText);ubig.textContent="✓";utxt.textContent=`Avviata l'elaborazione (${dur(data.duration_s)} di registrazione): segui l'avanzamento qui sotto`;setTimeout(()=>ub.hidden=true,6000)}
|
||||
else{ubig.textContent="!";utxt.textContent="Errore: "+xhr.responseText}tick()};
|
||||
// Network error.
|
||||
x.onerror=()=>{ubig.textContent="!";utxt.textContent="Errore di rete durante il caricamento"};
|
||||
xhr.onerror=()=>{ubig.textContent="!";utxt.textContent="Errore di rete durante il caricamento"};
|
||||
// Cancel: abort the request and hide the card.
|
||||
ucancel.onclick=()=>{x.abort();ub.hidden=true};
|
||||
ucancel.onclick=()=>{xhr.abort();ub.hidden=true};
|
||||
// File is sent as the raw request body.
|
||||
x.open("POST","/upload?filename="+encodeURIComponent(f.name));x.send(f)}
|
||||
xhr.open("POST","/upload?filename="+encodeURIComponent(file.name));xhr.send(file)}
|
||||
// File picker upload; reset the input so the same file can be picked again.
|
||||
up.onchange=()=>{if(up.files[0])send(up.files[0]);up.value=""};
|
||||
// Dragging over the page: highlight the drop zone.
|
||||
addEventListener("dragover",e=>{e.preventDefault();document.body.classList.add("drag")});
|
||||
addEventListener("dragover",event=>{event.preventDefault();document.body.classList.add("drag")});
|
||||
// Leaving the window (no relatedTarget) clears the highlight.
|
||||
addEventListener("dragleave",e=>{if(!e.relatedTarget)document.body.classList.remove("drag")});
|
||||
addEventListener("dragleave",event=>{if(!event.relatedTarget)document.body.classList.remove("drag")});
|
||||
// Drop anywhere on the page: upload the first file.
|
||||
addEventListener("drop",e=>{e.preventDefault();document.body.classList.remove("drag");const f=e.dataTransfer.files[0];if(f)send(f)});
|
||||
addEventListener("drop",event=>{event.preventDefault();document.body.classList.remove("drag");const file=event.dataTransfer.files[0];if(file)send(file)});
|
||||
// Meetings per page and current page index (0-based); goPg changes page and re-renders.
|
||||
const PS=100;let pg_=0;
|
||||
function goPg(d){pg_+=d;tick()}
|
||||
function goPg(delta){pg_+=delta;tick()}
|
||||
// Refresh the whole UI from /status: header, LLM pickers, table.
|
||||
async function tick(){try{const j=await (await fetch("/status")).json();ab.disabled=j.ask_blocked;ab.title=j.ask_blocked?"pipeline in corso":"";
|
||||
async function tick(){try{const data=await (await fetch("/status")).json();ab.disabled=data.ask_blocked;ab.title=data.ask_blocked?"pipeline in corso":"";
|
||||
// Browser tab title shows the progress of the first running pipeline.
|
||||
const runp=j.recs.map(r=>r.prog).filter(p=>p&&p.pct!=null);document.title=runp.length?`${Math.round(runp[0].pct*100)}% · ${LBL[runp[0].step]} · Riunioni`:"Riunioni";
|
||||
const runp=data.recs.map(row=>row.prog).filter(prog=>prog&&prog.pct!=null);document.title=runp.length?`${Math.round(runp[0].pct*100)}% · ${LBL[runp[0].step]} · Riunioni`:"Riunioni";
|
||||
// Refill the LLM pickers from the server list; skip the focused one so the user's choice is not overwritten.
|
||||
for(const [s,i,p] of [[llm,0,"shots: "],[llmr,1,"report: "],[llma,1,""]])if(document.activeElement!==s){s.innerHTML=j.llms[i].map(([k,l])=>`<option value=${k}>${p}${E(l)}`).join("");s.value=j.llm[i];s.disabled=j.busy}
|
||||
for(const [select,index,prefix] of [[llm,0,"shots: "],[llmr,1,"report: "],[llma,1,""]])if(document.activeElement!==select){select.innerHTML=data.llms[index].map(([key,label])=>`<option value=${key}>${prefix}${E(label)}`).join("");select.value=data.llm[index];select.disabled=data.busy}
|
||||
// Skip-screenshots switch; disabled while busy.
|
||||
skp.checked=j.skip_shots;skp.disabled=j.busy;
|
||||
skp.checked=data.skip_shots;skp.disabled=data.busy;
|
||||
// omp login status: red and showing the error when logged out.
|
||||
const o=j.omp;omps.innerHTML=!o.exe?`<span style="color:var(--redf)">omp non installato</span>`:[["github-copilot","Copilot"],["anthropic","Anthropic"]].map(([k,l])=>`<span title="${E(o[k]||"login valido")}"${o[k]?' style="color:var(--redf)"':""}>${o[k]?"✗":"✓"} ${l}</span>`).join(" · ");
|
||||
const ompStatus=data.omp;omps.innerHTML=!ompStatus.exe?`<span style="color:var(--redf)">omp non installato</span>`:[["github-copilot","Copilot"],["anthropic","Anthropic"]].map(([key,label])=>`<span title="${E(ompStatus[key]||"login valido")}"${ompStatus[key]?' style="color:var(--redf)"':""}>${ompStatus[key]?"✗":"✓"} ${label}</span>`).join(" · ");
|
||||
// Queue size in the header.
|
||||
qs.textContent=j.queue?`rielaborazione: ${j.queue} da completare`:"";
|
||||
qs.textContent=data.queue?`rielaborazione: ${data.queue} da completare`:"";
|
||||
// Remember step-select values so they survive the re-render.
|
||||
document.querySelectorAll("select[id^=f-]").forEach(s=>sel[s.id]=s.value);
|
||||
document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=select.value);
|
||||
// Table header.
|
||||
let h="<thead><tr><th>recording<th>status<th>duration<th>speakers<th>MB<th>links<th>actions</tr></thead>";
|
||||
let html="<thead><tr><th>recording<th>status<th>duration<th>speakers<th>MB<th>links<th>actions</tr></thead>";
|
||||
// Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager.
|
||||
const np=Math.max(1,Math.ceil(j.recs.length/PS));if(pg_>=np)pg_=np-1;
|
||||
pgr.innerHTML=np>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${np} (${j.recs.length} riunioni)</span><button ${pg_<np-1?"":"disabled"} onclick="goPg(1)">›</button>`:"";
|
||||
const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1;
|
||||
pgr.innerHTML=pages>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${pages} (${j.recs.length} riunioni)</span><button ${pg_<pages-1?"":"disabled"} onclick="goPg(1)">›</button>`:"";
|
||||
// One tbody per recording on the current page; "running" when the status is done but the process is still alive.
|
||||
for(const r of j.recs.slice(pg_*PS,(pg_+1)*PS)){const st=r.running&&r.status=="done"?"running":r.status;
|
||||
for(const row of data.recs.slice(pg_*PS,(pg_+1)*PS)){
|
||||
// Display title, falling back to the upload name.
|
||||
const nm=r.title||r.upload;
|
||||
const nm=row.title||row.upload;
|
||||
// Main row: checkbox, title and rename buttons; status badge with error text and time since last data.
|
||||
h+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${r.name}">${nm?`<b>${E(nm)}</b><br><small>${r.name}</small>`:r.name} <button class=del title="modifica titolo" onclick="setTitle('${r.name}','${E(r.title||r.upload||"").replace(/'/g,"")}')">✎</button>${r.mb&&r.files.includes("report.html")?`<button class=del title="ricalcola titolo" onclick="retitle('${r.name}')">↻</button>`:""}<td><span class="b ${r.status}" title="${E(r.error)}">${r.status}</span>${r.receiving_age_s!=null&&r.status=="recording"?` <small>${r.receiving_age_s}s ago</small>`:""}${r.error?`<br><small>${E(r.error)}</small>`:""}<td>${r.duration_s?fmt(r.duration_s):""}<td>${r.speakers??""}<td>${r.mb}
|
||||
<td>${r.files.includes("report.html")?`<a href="/report?name=${r.name}" target=_blank>report</a><a href="/pdf?name=${r.name}" target=_blank>pdf</a>`:""}${r.flow_run_id?`<a href="http://127.0.0.1:4200/runs/flow-run/${r.flow_run_id}" target=_blank>prefect</a>`:""}
|
||||
<td>${r.mb?`<select id="f-${r.name}">${["audio","transcribe","diarize","speakers","shots","docs","report","memory","render"].map(s=>`<option>${s}`).join("")}</select><button onclick="run('${r.name}')">run</button>`:""}<button onclick="spk('${r.name}')">speakers</button>${r.mb?`<button title="anteprima e ritaglio" onclick="play('${r.name}',${r.duration_s||0},'${E(nm||r.name).replace(/'/g,"")}')">▶ video</button>`:""}${r.mb&&r.status=="done"&&!r.running?`<button title="elimina solo il file video: report, trascrizione e schermate restano, ma non si può più rielaborare" onclick="dropVid('${r.name}',${r.mb})">🎞 elimina video</button>`:""}${r.running||r.status=="queued"?`<button onclick="stopRun('${r.name}')">stop</button>`:`<button class=del title="elimina la riunione" onclick="del_('${r.name}','${E(nm||r.name).replace(/'/g,"")}')">🗑</button>`}`;
|
||||
h+=progPanel(r);
|
||||
if(open_.has(r.name))h+=await panel(r.name);h+="</tbody>"}
|
||||
h+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${row.name}">${nm?`<b>${E(nm)}</b><br><small>${row.name}</small>`:row.name} <button class=del title="modifica titolo" onclick="setTitle('${row.name}','${E(row.title||row.upload||"").replace(/'/g,"")}')">✎</button>${row.mb&&row.files.includes("report.html")?`<button class=del title="ricalcola titolo" onclick="retitle('${row.name}')">↻</button>`:""}<td><span class="b ${row.status}" title="${E(row.error)}">${row.status}</span>${row.receiving_age_s!=null&&row.status==="recording"?` <small>${row.receiving_age_s}s ago</small>`:""}${row.error?`<br><small>${E(row.error)}</small>`:""}<td>${row.duration_s?fmt(row.duration_s):""}<td>${row.speakers??""}<td>${row.mb}
|
||||
<td>${row.files.includes("report.html")?`<a href="/report?name=${row.name}" target=_blank>report</a><a href="/pdf?name=${row.name}" target=_blank>pdf</a>`:""}${row.flow_run_id?`<a href="http://127.0.0.1:4200/runs/flow-run/${row.flow_run_id}" target=_blank>prefect</a>`:""}
|
||||
<td>${row.mb?`<select id="f-${row.name}">${["audio","transcribe","diarize","speakers","shots","docs","report","memory","render"].map(step=>`<option>${step}`).join("")}</select><button onclick="run('${row.name}')">run</button>`:""}<button onclick="spk('${row.name}')">speakers</button>${row.mb?`<button title="anteprima e ritaglio" onclick="play('${row.name}',${row.duration_s||0},'${E(nm||row.name).replace(/'/g,"")}')">▶ video</button>`:""}${row.mb&&row.status==="done"&&!row.running?`<button title="elimina solo il file video: report, trascrizione e schermate restano, ma non si può più rielaborare" onclick="dropVid('${row.name}',${row.mb})">🎞 elimina video</button>`:""}${row.running||row.status==="queued"?`<button onclick="stopRun('${row.name}')">stop</button>`:`<button class=del title="elimina la riunione" onclick="del_('${row.name}','${E(nm||row.name).replace(/'/g,"")}')">🗑</button>`}`;
|
||||
html+=progPanel(row);
|
||||
if(open_.has(row.name))html+=await panel(row.name);html+="</tbody>"}
|
||||
// Re-render only when not editing a speaker field and no table input has focus, so user input is kept.
|
||||
const ae=document.activeElement;if(!editing&&!(ae&&t.contains(ae)&&/^(INPUT|SELECT)$/.test(ae.tagName))){const ck=[...document.querySelectorAll(".mg:checked")].map(x=>x.value);t.innerHTML=h;for(const k in sel){const e=document.getElementById(k);if(e)e.value=sel[k]}document.querySelectorAll(".mg").forEach(x=>x.checked=ck.includes(x.value));upd()}}catch(e){}}
|
||||
const ae=document.activeElement;if(!editing&&!(ae&&t.contains(ae)&&/^(INPUT|SELECT)$/.test(ae.tagName))){const ck=[...document.querySelectorAll(".mg:checked")].map(box=>box.value);t.innerHTML=html;for(const id in sel){const element=document.getElementById(id);if(element)element.value=sel[id]}document.querySelectorAll(".mg").forEach(box=>box.checked=ck.includes(box.value));upd()}}catch{/* poll failed: next tick retries */}}
|
||||
// Set while typing in a speaker name input.
|
||||
let editing=false;t.addEventListener("input",e=>{if(e.target.dataset.n)editing=true});t.addEventListener("change",e=>{if(e.target.classList.contains("mg"))upd()});
|
||||
let editing=false;t.addEventListener("input",event=>{if(event.target.dataset.n)editing=true});t.addEventListener("change",event=>{if(event.target.classList.contains("mg"))upd()});
|
||||
// Initial load, then poll every 3 s.
|
||||
tick();setInterval(tick,3000);
|
||||
|
||||
Reference in New Issue
Block a user