39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
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", "encoder"]) {
|
|
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 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
|