Update '12/liveplayer.js'

master
murtaugh 5 years ago
parent d41bb76e96
commit 7dc71e7263

@ -1,5 +1,6 @@
function liveplayer (elt) { function liveplayer (elt) {
var last_timestamp; var last_timestamp,
DELAY_TIME_SECS = 8;
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();
@ -10,17 +11,19 @@ function liveplayer (elt) {
if (d.time && d.time != last_timestamp) { if (d.time && d.time != last_timestamp) {
last_timestamp = d.time; last_timestamp = d.time;
console.log("CURRENT METADATA", d); console.log("CURRENT METADATA", d);
var old_nowplaying = elt.querySelector(".now_playing"); window.setTimeout(function () {
if (old_nowplaying) { var old_nowplaying = elt.querySelector(".now_playing");
old_nowplaying.classList.remove("now_playing"); if (old_nowplaying) {
} old_nowplaying.classList.remove("now_playing");
var nowplaying = elt.querySelector("#"+d.title); }
if (nowplaying) { var nowplaying = elt.querySelector("#"+d.title);
console.log("liveplayer: nowplaying", nowplaying); if (nowplaying) {
nowplaying.classList.add("now_playing"); console.log("liveplayer: nowplaying", nowplaying);
} else { nowplaying.classList.add("now_playing");
console.log("liveplayer: warning no div matching title " + d.title); } else {
} console.log("liveplayer: warning no div matching title " + d.title);
}
}, DELAY_TIME_SECS*1000);
} }
} }
} }

Loading…
Cancel
Save