+/**
+ * ADD / REMOVE FROM ROOMS
+ **/
+let currentRoom = ""
+
+
+function removeSongFromRoom(event) {
+
+}
+
+function addSongToRoom(event) {
+
+}
+
/**
* SONG LIST
**/
* LIST ELEMENTS
**/
-function makeListElementWithSong(song) {
+function makeInListElementWithSong(song) {
let el = document.createElement("div")
el.id = song.Key // should be unique on page
let text = document.createElement("p")
text.innerText = song.DisplayTrackName + " by " + song.DisplayArtistNames
+
+ let removeButton = document.createElement("button")
+ removeButton.addEventListener("click", (e) => { removeSongFromRoom(e) })
+ removeButton.innerText = "Remove"
+
+ el.appendChild(text)
+ el.appendChild(removeButton)
+
+ return el
+}
+
+
+function makeOutListElementWithSong(song) {
+ let el = document.createElement("div")
+ el.id = song.Key // should be unique on page
+
+ let text = document.createElement("p")
+ text.innerText = song.DisplayTrackName + " by " + song.DisplayArtistNames
+
+ let addButton = document.createElement("button")
+ addButton.addEventListener("click", (e) => { addSongToRoom(e) })
+ addButton.innerText = "Add"
+
el.appendChild(text)
+ el.appendChild(addButton)
return el
}
return
}
let ids = await response.json()
+ currentRoom = room
// now that we have the songs and their ID's we can arrange the lists correctly
let inList = songList.filter((v, _i, _a) => { return ids.includes(v.Key.replace("song:", "")) })
inRoomList.innerHTML = ""
for (let i = 0; i < inList.length; i++) {
let song = inList[i]
- inRoomList.appendChild(makeListElementWithSong(song))
+ inRoomList.appendChild(makeInListElementWithSong(song))
}
let outList = songList.filter((v, _i, _a) => { return !ids.includes(v.Key.replace("song:", "")) })
outRoomList.innerHTML = ""
for (let i = 0; i < outList.length; i++) {
let song = outList[i]
- outRoomList.appendChild(makeListElementWithSong(song))
+ outRoomList.appendChild(makeOutListElementWithSong(song))
}
})