squash bug, clean up
This commit is contained in:
parent
11cbe2b1c4
commit
64564c8c41
20
js/music.js
20
js/music.js
@ -1,4 +1,4 @@
|
|||||||
const alblabel = document.getElementById("albLabel");
|
const albumlabel = document.getElementById("albumLabel");
|
||||||
const albumart = document.getElementById("album-art");
|
const albumart = document.getElementById("album-art");
|
||||||
const song = document.getElementById("song");
|
const song = document.getElementById("song");
|
||||||
const artist = document.getElementById("artist");
|
const artist = document.getElementById("artist");
|
||||||
@ -11,21 +11,27 @@ async function getLatestSong() {
|
|||||||
if (lsResponse.ok) {
|
if (lsResponse.ok) {
|
||||||
const latestSongJSON = await lsResponse.json();
|
const latestSongJSON = await lsResponse.json();
|
||||||
if (!latestSongJSON.track["@attr"]) {
|
if (!latestSongJSON.track["@attr"]) {
|
||||||
alblabel.textContent = "Last Listen:";
|
albumlabel.textContent = "Last Listen:";
|
||||||
} else if (latestSongJSON.track["@attr"].nowplaying) {
|
} else {
|
||||||
alblabel.textContent = "Now Playing:";
|
// noinspection JSUnresolvedReference
|
||||||
|
if (latestSongJSON.track["@attr"].nowplaying) {
|
||||||
|
albumlabel.textContent = "Now Playing:";
|
||||||
} else {
|
} else {
|
||||||
console.log("[WARN] Invalid value in now playing status, or something else messed up");
|
console.log("[WARN] Invalid value in now playing status, or something else messed up");
|
||||||
alblabel.textContent = "Last Listen:";
|
albumlabel.textContent = "Last Listen:";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// noinspection JSUnresolvedReference
|
||||||
albumart.src = latestSongJSON.track.image[1]["#text"];
|
albumart.src = latestSongJSON.track.image[1]["#text"];
|
||||||
song.textContent = latestSongJSON.track.name;
|
song.textContent = latestSongJSON.track.name;
|
||||||
artist.textContent = latestSongJSON.track.artist["#text"];
|
artist.textContent = latestSongJSON.track.artist["#text"];
|
||||||
album.textContent = latestSongJSON.track.album["#text"];
|
album.textContent = latestSongJSON.track.album["#text"];
|
||||||
} else throw new Error(`Error, response status: ${lsResponse.status}`);
|
} else console.log(`Error: ${lsResponse.status}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Error: ${error.message}`);
|
console.log(`Error: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getLatestSong();
|
(async function() {
|
||||||
|
await getLatestSong();
|
||||||
|
})();
|
Loading…
x
Reference in New Issue
Block a user