From 790b08e22c26d8caa4bbf116b738c5fb0c4194b1 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 22 Aug 2023 16:37:00 +0400 Subject: [PATCH] Changed formatting in main.js. Also innerText was replaced with textContent. --- web/assets/js/main.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/web/assets/js/main.js b/web/assets/js/main.js index 440df34..5764ff6 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -10,17 +10,15 @@ function updateRadioStatus() { }).catch(() => { $("radio-song").textContent = ""; $("radio-listeners").textContent = - $("radio-listener-peak").textContent = "0"; - }); -} + $("radio-listener-peak").textContent = "0"; }); } function updateLastPlayedSong() { fetch("/lastsong") .then(r => r.json()) .then(last_played => { if ($("last-songs").firstChild === null) - $("last-songs").appendChild(document.createElement("tbody")) - else if (last_played.time == $("last-songs").firstChild.lastChild.firstChild.innerText) + $("last-songs").appendChild(document.createElement("tbody")); + else if (last_played.time == $("last-songs").firstChild.lastChild.firstChild.textContent) return; if ($("last-songs").firstChild.children.length == 10) @@ -29,9 +27,7 @@ function updateLastPlayedSong() { let row = $("last-songs").insertRow(); 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.song)); - }); -} + row.insertCell().appendChild(document.createTextNode(last_played.song)); }); } $("radio-update").addEventListener("click", () => { updateLastPlayedSong(); @@ -57,16 +53,14 @@ audio.addEventListener("timeupdate", e => { const h = Math.floor(ct / 3600); $("radio-elapsed").textContent = `${h}h ${m}m ${s}s`; }); -$("player").firstChild.style.display = "flex"; -$("player").style.display = "flex"; +$("player").style.display = + $("player").firstChild.style.display = "flex"; $("radio-play").addEventListener("click", e => { if (audio.paused) { audio.src = audio_src; audio.play(); - } else { - audio.pause(); + } else audio.src = ""; - } e.target.style.maskImage = e.target.style.webkitMaskImage = audio.paused ? "url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; });