From f7322a78b4579f54b29338442486169d4012ea78 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 22 Jan 2022 19:04:33 +0400 Subject: [PATCH] Added song start time column. Added listener for update button. --- radio/static/assets/js/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/radio/static/assets/js/main.js b/radio/static/assets/js/main.js index cea8290..f9b23f0 100644 --- a/radio/static/assets/js/main.js +++ b/radio/static/assets/js/main.js @@ -21,7 +21,7 @@ function updateLastPlayedSong() { fetch('/lastsong') .then(r => r.json()) .then(last_played => { - let cur_artist = $('last-played').firstChild.lastChild.firstChild.innerText; + let cur_artist = $('last-played').firstChild.lastChild.children[1].innerText; let cur_title = $('last-played').firstChild.lastChild.lastChild.innerText; if (last_played.artist == cur_artist && last_played.title == cur_title) @@ -30,6 +30,8 @@ function updateLastPlayedSong() { $('last-played').firstChild.firstChild.remove(); let row = $('last-played').insertRow(); + let start_time = row.insertCell(); + start_time.appendChild(document.createTextNode(last_played.start_time_local)); let artist_cell = row.insertCell(); artist_cell.appendChild(document.createTextNode(last_played.artist)); let title_cell = row.insertCell(); @@ -37,5 +39,10 @@ function updateLastPlayedSong() { }); } +document.getElementById("btn-update").addEventListener("click", () => { + updateLastPlayedSong(); + updateRadioStatus(); +}) + setInterval(updateRadioStatus, 45000); setInterval(updateLastPlayedSong, 45000); \ No newline at end of file