transbeam/static/js/download.js

15 lines
555 B
JavaScript
Raw Normal View History

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);
});