Refresh queue regularly
This commit is contained in:
parent
ad5da60b5a
commit
6af47b8c30
3 changed files with 23 additions and 9 deletions
16
static/queue/main.ts
Normal file
16
static/queue/main.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
const COUNT = document.getElementById("count")!;
|
||||
const QUEUE = document.getElementById("queue")!;
|
||||
const REFRESH_SECONDS = 10;
|
||||
|
||||
function update() {
|
||||
fetch("table")
|
||||
.then(response => response.text())
|
||||
.then(text => {
|
||||
QUEUE.innerHTML = text;
|
||||
let count = QUEUE.querySelectorAll("tbody tr").length;
|
||||
COUNT.textContent = String(count);
|
||||
document.title = document.title.replace(/^queue \(\d+\)/, `queue (${count})`);
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(update, REFRESH_SECONDS * 1000);
|
||||
Loading…
Add table
Add a link
Reference in a new issue