Fixed a js script for radio page.
This commit is contained in:
parent
b7044af0e6
commit
f02d333ae3
@ -3,14 +3,14 @@ function $(id) { return document.getElementById(id); }
|
|||||||
function updateRadioStatus() {
|
function updateRadioStatus() {
|
||||||
fetch("/stats")
|
fetch("/stats")
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(radio => {
|
.then(r => {
|
||||||
$("radio-status").innerHTML =
|
$("radio-status").innerHTML =
|
||||||
`On-air since <time datetime="${radio.server_start_iso8601}">${radio.server_start_date}</time>`;
|
`On-air since <time datetime="${r.server_start_iso8601}">${r.server_start_date}</time>`;
|
||||||
$("radio-song").textContent = radio.song;
|
$("radio-song").textContent = r.song;
|
||||||
$("radio-listeners").textContent = radio.listeners;
|
$("radio-listeners").textContent = r.listeners;
|
||||||
$("radio-listener-peak").textContent = radio.listener_peak;
|
$("radio-listener-peak").textContent = r.listener_peak;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
$("radio-status").textContent = "Now is offline";
|
$("radio-status").textContent = "Radio is offline.";
|
||||||
$("radio-song").textContent =
|
$("radio-song").textContent =
|
||||||
$("radio-listeners").textContent =
|
$("radio-listeners").textContent =
|
||||||
$("radio-listener-peak").textContent = "n/a";
|
$("radio-listener-peak").textContent = "n/a";
|
||||||
@ -37,7 +37,5 @@ function updateLastPlayedSong() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAll() { updateRadioStatus(); updateLastPlayedSong(); }
|
|
||||||
|
|
||||||
setInterval(updateRadioStatus, 45000);
|
setInterval(updateRadioStatus, 45000);
|
||||||
setInterval(updateLastPlayedSong, 45000);
|
setInterval(updateLastPlayedSong, 45000);
|
Loading…
Reference in New Issue
Block a user