update download contents as more files become available

This commit is contained in:
xenofem 2022-05-24 16:49:48 -04:00
parent 007289ffe5
commit be4decde12
4 changed files with 80 additions and 16 deletions

14
static/js/download.js Normal file
View file

@ -0,0 +1,14 @@
document.addEventListener("DOMContentLoaded", () => {
const table = document.getElementById("download_contents").getElementsByTagName("tbody")[0];
if (table.children.length === 0) { return; }
setInterval(() => {
fetch(`info?code=${CODE}`)
.then((res) => res.json())
.then((info) => {
for (const [index, offset] of info.offsets.entries()) {
table.children[index].className = (offset > info.available) ? "unavailable" : "";
}
});
}, 5000);
});