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