1
0

Changed formatting in main.js. Also innerText was replaced with textContent.

This commit is contained in:
Alexander Andreev 2023-08-22 16:37:00 +04:00
parent 28c2cf21a0
commit 790b08e22c
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -10,17 +10,15 @@ function updateRadioStatus() {
}).catch(() => { }).catch(() => {
$("radio-song").textContent = ""; $("radio-song").textContent = "";
$("radio-listeners").textContent = $("radio-listeners").textContent =
$("radio-listener-peak").textContent = "0"; $("radio-listener-peak").textContent = "0"; }); }
});
}
function updateLastPlayedSong() { function updateLastPlayedSong() {
fetch("/lastsong") fetch("/lastsong")
.then(r => r.json()) .then(r => r.json())
.then(last_played => { .then(last_played => {
if ($("last-songs").firstChild === null) if ($("last-songs").firstChild === null)
$("last-songs").appendChild(document.createElement("tbody")) $("last-songs").appendChild(document.createElement("tbody"));
else if (last_played.time == $("last-songs").firstChild.lastChild.firstChild.innerText) else if (last_played.time == $("last-songs").firstChild.lastChild.firstChild.textContent)
return; return;
if ($("last-songs").firstChild.children.length == 10) if ($("last-songs").firstChild.children.length == 10)
@ -29,9 +27,7 @@ function updateLastPlayedSong() {
let row = $("last-songs").insertRow(); let row = $("last-songs").insertRow();
row.insertCell().appendChild(document.createTextNode(last_played.time)); row.insertCell().appendChild(document.createTextNode(last_played.time));
row.insertCell().appendChild(document.createTextNode(last_played.listeners == 0 ? "" : last_played.listeners)); row.insertCell().appendChild(document.createTextNode(last_played.listeners == 0 ? "" : last_played.listeners));
row.insertCell().appendChild(document.createTextNode(last_played.song)); row.insertCell().appendChild(document.createTextNode(last_played.song)); }); }
});
}
$("radio-update").addEventListener("click", () => { $("radio-update").addEventListener("click", () => {
updateLastPlayedSong(); updateLastPlayedSong();
@ -57,16 +53,14 @@ audio.addEventListener("timeupdate", e => {
const h = Math.floor(ct / 3600); const h = Math.floor(ct / 3600);
$("radio-elapsed").textContent = `${h}h ${m}m ${s}s`; }); $("radio-elapsed").textContent = `${h}h ${m}m ${s}s`; });
$("player").firstChild.style.display = "flex"; $("player").style.display =
$("player").style.display = "flex"; $("player").firstChild.style.display = "flex";
$("radio-play").addEventListener("click", e => { $("radio-play").addEventListener("click", e => {
if (audio.paused) { if (audio.paused) {
audio.src = audio_src; audio.src = audio_src;
audio.play(); audio.play();
} else { } else
audio.pause();
audio.src = ""; audio.src = "";
}
e.target.style.maskImage = e.target.style.webkitMaskImage = audio.paused ? e.target.style.maskImage = e.target.style.webkitMaskImage = audio.paused ?
"url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; }); "url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; });