Update '12/liveplayer.js'

master
murtaugh 5 years ago
parent 70f628955c
commit 4b8a66b60f

@ -1,21 +1,29 @@
(function () { function liveplayer (elt) {
var last_timestamp; var last_timestamp;
async function poll () { async function poll () {
var rows = await (await fetch("/cgi-bin/radioimplicancies.cgi")).json(); var rows = await (await fetch("/cgi-bin/radioimplicancies.cgi")).json();
console.log("rows", rows); // console.log("rows", rows);
if (rows) { if (rows) {
// get the last (most recent) item // get the last (most recent) item
var d = rows[rows.length-1]; var d = rows[rows.length-1];
if (d.time && d.time != last_timestamp) { if (d.time && d.time != last_timestamp) {
console.log("CURRENT METADATA", d); last_timestamp = d.time;
last_timestamp = d.time; console.log("CURRENT METADATA", d);
} var old_nowplaying = elt.querySelector(".nowplaying");
} if (old_nowplaying) {
} old_nowplaying.classList.remove("nowplaying");
}
window.setInterval(poll, 5000); var nowplaying = elt.querySelector(d.title);
if (nowplaying) {
nowplaying.classList.add("nowplaying");
}
}
}
}
window.setInterval(poll, 5000);
}
})(); liveplayer(document);
Loading…
Cancel
Save