const MILLISECOND = 1 const SECOND = 1000 async function update() { let resp = await fetch("status.json", {cache: "no-store"}) let s = await resp.json() for (let activity of ["reader"]) { let val = s.status[activity] let e = document.querySelector(`.status .${activity}`) let txt = e.querySelector(".text") let progress = e.querySelector("progress") txt.textContent = val if (val == "idle") { progress.value = 0 } else { // Removing the value makes it pulse progress.removeAttribute("value") } } let qtmpl = document.querySelector("template.encoder-item").content let qelem = document.querySelector(".encoder") while (qelem.firstChild) qelem.firstChild.remove() for (let qitem of s.queue) { let e = qtmpl.cloneNode(true) e.querySelector(".encoder-title").textContent = qitem.title e.querySelector("progress").value = qitem.complete qelem.append(e) } let fileItem = document.querySelector("template.panel-file-item").content for (let section of ["video", "audio"]) { let e = document.querySelector(`.${section} .items`) while (e.firstChild) e.firstChild.remove() for (let fn of s.finished[section]) { let item = fileItem.cloneNode(true) item.querySelector(".filename").textContent = fn e.append(item) } } } setInterval(update, 2 * SECOND) update() // vi: ts=2 sw=2 et ai