diff --git a/assets/day-bg.png b/assets/day-bg.png new file mode 100644 index 0000000..6ba9001 Binary files /dev/null and b/assets/day-bg.png differ diff --git a/assets/evening-bg.png b/assets/evening-bg.png new file mode 100644 index 0000000..863d2b2 Binary files /dev/null and b/assets/evening-bg.png differ diff --git a/assets/night-bg.png b/assets/night-bg.png new file mode 100644 index 0000000..c7f5442 Binary files /dev/null and b/assets/night-bg.png differ diff --git a/index.html b/index.html index 04e7111..7ca4891 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,25 @@ - + -listening to: - - + + + + + + + + + +
+ + +
+ + listening to: + + + +
+
+ +
+ \ No newline at end of file diff --git a/main.js b/main.js index 525163a..bc2e589 100644 --- a/main.js +++ b/main.js @@ -1,13 +1,13 @@ async function getData() { - const url = "http://localhost:3000/userrecent?userName=sussyenby&limit=1"; + const url = "http://localhost:3000/userrecent?userName=sussyenby&limit=1"; // request most recent track try { const response = await fetch(url); if (!response.ok) { - throw new Error(`Response status: ${response.status}`); + throw new Error(`Response status: ${response.status}`); // return response } - + const json = await response.json(); - try{ if (json.recenttracks.track[0]["@attr"].nowplaying) { + try{ if (json.recenttracks.track[0]["@attr"].nowplaying) { // check if most recent track is currently playing console.log(json.recenttracks.track[0].name) console.log(json.recenttracks.track[0].url) console.log(json.recenttracks.track[0].image[0]["#text"]) @@ -22,4 +22,23 @@ async function getData() { } } +async function setBg() { + const d = new Date(); + let hour = d.getHours(); + document.getElementById("track").innerHTML = hour + if (hour < 18 ) { + time = "day" + } else if (hour < 20) { + time = "evening" + } else { + time = "night" + } + console.log(`assets/${time}-bg`) + document.getElementById("left-border").setAttribute("src", `assets/${time}-bg.png`) + document.getElementById("right-border").setAttribute("src", `assets/${time}-bg.png`) + +} +setBg() getData() + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29