Update '12/liveplayer.js'
parent
70f628955c
commit
4b8a66b60f
@ -1,21 +1,29 @@
|
||||
(function () {
|
||||
var last_timestamp;
|
||||
function liveplayer (elt) {
|
||||
var last_timestamp;
|
||||
|
||||
async function poll () {
|
||||
var rows = await (await fetch("/cgi-bin/radioimplicancies.cgi")).json();
|
||||
console.log("rows", rows);
|
||||
if (rows) {
|
||||
// get the last (most recent) item
|
||||
var d = rows[rows.length-1];
|
||||
if (d.time && d.time != last_timestamp) {
|
||||
console.log("CURRENT METADATA", d);
|
||||
last_timestamp = d.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.setInterval(poll, 5000);
|
||||
async function poll () {
|
||||
var rows = await (await fetch("/cgi-bin/radioimplicancies.cgi")).json();
|
||||
// console.log("rows", rows);
|
||||
if (rows) {
|
||||
// get the last (most recent) item
|
||||
var d = rows[rows.length-1];
|
||||
if (d.time && d.time != last_timestamp) {
|
||||
last_timestamp = d.time;
|
||||
console.log("CURRENT METADATA", d);
|
||||
var old_nowplaying = elt.querySelector(".nowplaying");
|
||||
if (old_nowplaying) {
|
||||
old_nowplaying.classList.remove("nowplaying");
|
||||
}
|
||||
var nowplaying = elt.querySelector(d.title);
|
||||
if (nowplaying) {
|
||||
nowplaying.classList.add("nowplaying");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.setInterval(poll, 5000);
|
||||
}
|
||||
|
||||
})();
|
||||
liveplayer(document);
|
Loading…
Reference in New Issue