From 64564c8c413483417bc99dde2334e73dd31f72ea Mon Sep 17 00:00:00 2001 From: lou Date: Fri, 11 Oct 2024 18:46:00 -0400 Subject: [PATCH] squash bug, clean up --- js/music.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/music.js b/js/music.js index c998da5..c2262e5 100644 --- a/js/music.js +++ b/js/music.js @@ -1,4 +1,4 @@ -const alblabel = document.getElementById("albLabel"); +const albumlabel = document.getElementById("albumLabel"); const albumart = document.getElementById("album-art"); const song = document.getElementById("song"); const artist = document.getElementById("artist"); @@ -11,21 +11,27 @@ async function getLatestSong() { if (lsResponse.ok) { const latestSongJSON = await lsResponse.json(); if (!latestSongJSON.track["@attr"]) { - alblabel.textContent = "Last Listen:"; - } else if (latestSongJSON.track["@attr"].nowplaying) { - alblabel.textContent = "Now Playing:"; + albumlabel.textContent = "Last Listen:"; } else { - console.log("[WARN] Invalid value in now playing status, or something else messed up"); - alblabel.textContent = "Last Listen:"; + // noinspection JSUnresolvedReference + if (latestSongJSON.track["@attr"].nowplaying) { + albumlabel.textContent = "Now Playing:"; + } else { + console.log("[WARN] Invalid value in now playing status, or something else messed up"); + albumlabel.textContent = "Last Listen:"; + } } + // noinspection JSUnresolvedReference albumart.src = latestSongJSON.track.image[1]["#text"]; song.textContent = latestSongJSON.track.name; artist.textContent = latestSongJSON.track.artist["#text"]; album.textContent = latestSongJSON.track.album["#text"]; - } else throw new Error(`Error, response status: ${lsResponse.status}`); + } else console.log(`Error: ${lsResponse.status}`); } catch (error) { console.log(`Error: ${error.message}`); } } -getLatestSong(); \ No newline at end of file +(async function() { + await getLatestSong(); +})(); \ No newline at end of file