Update '12/liveplayer.js'

master
murtaugh 5 years ago
parent d41bb76e96
commit 7dc71e7263

@ -1,5 +1,6 @@
function liveplayer (elt) {
var last_timestamp;
var last_timestamp,
DELAY_TIME_SECS = 8;
async function poll () {
var rows = await (await fetch("/cgi-bin/radioimplicancies.cgi")).json();
@ -10,17 +11,19 @@ function liveplayer (elt) {
if (d.time && d.time != last_timestamp) {
last_timestamp = d.time;
console.log("CURRENT METADATA", d);
var old_nowplaying = elt.querySelector(".now_playing");
if (old_nowplaying) {
old_nowplaying.classList.remove("now_playing");
}
var nowplaying = elt.querySelector("#"+d.title);
if (nowplaying) {
console.log("liveplayer: nowplaying", nowplaying);
nowplaying.classList.add("now_playing");
} else {
console.log("liveplayer: warning no div matching title " + d.title);
}
window.setTimeout(function () {
var old_nowplaying = elt.querySelector(".now_playing");
if (old_nowplaying) {
old_nowplaying.classList.remove("now_playing");
}
var nowplaying = elt.querySelector("#"+d.title);
if (nowplaying) {
console.log("liveplayer: nowplaying", nowplaying);
nowplaying.classList.add("now_playing");
} else {
console.log("liveplayer: warning no div matching title " + d.title);
}
}, DELAY_TIME_SECS*1000);
}
}
}

Loading…
Cancel
Save