From 066208def461f2172a9088a536826a5a85bb3791 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Fri, 1 Apr 2022 18:42:13 +0400 Subject: [PATCH] Reduced main.js a little. --- internal/handlers/web/assets/js/main.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/internal/handlers/web/assets/js/main.js b/internal/handlers/web/assets/js/main.js index 52b2805..199ccb5 100644 --- a/internal/handlers/web/assets/js/main.js +++ b/internal/handlers/web/assets/js/main.js @@ -13,7 +13,7 @@ function updateRadioStatus() { $("radio-status").textContent = "Radio is offline."; $("radio-song").textContent = $("radio-listeners").textContent = - $("radio-listener-peak").textContent = "n/a"; + $("radio-listener-peak").textContent = ""; }); } @@ -21,20 +21,15 @@ function updateLastPlayedSong() { fetch('/lastsong') .then(r => r.json()) .then(last_played => { - let cur_time = $('last-played').firstChild.lastChild.firstChild.innerText; - - if (last_played.time == cur_time) + if (last_played.time == $('last-played').firstChild.lastChild.firstChild.innerText) return; $('last-played').firstChild.firstChild.remove(); let row = $('last-played').insertRow(); - let start_time = row.insertCell(); - start_time.appendChild(document.createTextNode(last_played.time)); - let listeners_cell = row.insertCell(); - listeners_cell.appendChild(document.createTextNode(last_played.listeners == 0 ? "" : last_played.listeners)); - let song_cell = row.insertCell(); - song_cell.appendChild(document.createTextNode(last_played.song)); + 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)); }); }