<div id="outerSongList">
<h1><u>Song List</u></h1>
- <input id="songFilterInput"></input>
- <input id="songFilterArtist"></input>
- <button id="" onclick="getSongList()">Update Songs</button>
+ <div id="songFilterInputs">
+ <input placeholder="Name of a song..." id="songFilterName"></input>
+ <input placeholder="Name of an artist..." id="songFilterArtist"></input>
+ <input id="songFilterInDB" type="checkbox">In DB</input>
+ <input id="songFilterImageExist" type="checkbox">Image Exists</input>
+ <button id="" onclick="getSongList()">Update Songs</button>
+ </div>
<div id="innerSongList">
</div>
+let songList = []
+
+/**
+ * SONG FILE LIST SECTION
+ */
+
let songFileList = []
/**
* Get the list of all named song files (raw filenames) using the API
}
getSongFileList()
-
-let songList = []
let innerSongList = document.getElementById("innerSongList")
/**
/**
* Check if the songs exists, withtout trying to download the full file
+ * @param {*} url - The URL that should be checked for in the song file list
*/
function SongURLExists(url) {
console.log(url)
return songFileList.indexOf(url) != -1
}
+/**
+ * Make the song list and append them to the elements, given the list of songs
+ * @param {*} listOfSongs - The list of songs, obviously should be a list of songs
+ * @param {*} appendElement - The element to which the list should be appended
+ **/
+function makeSongList(listOfSongs, appendElement) {
+ for (let i = 0; i < listOfSongs.length; i++) {
+ let song = listOfSongs[i]
+
+ let fileAvailable = SongURLExists(song.PreviewURL)
+
+ appendElement.appendChild(NewSongElement(
+ fileAvailable, song.DisplayTrackName, song.DisplayArtistNames, song.ArtworkURL60, song.Key
+ ))
+ }
+}
+
/**
* Get all the songs
**/
**/
let songFilterInput = document.getElementById("songFilterInput")
+/**
+ * FILTERING SECTION
+ **/
+let songFilterName = document.getElementById("songFilterName")
+let songFilterArtist = document.getElementById("songFilterArtist")
+let songFilterInDB = document.getElementById("songFilterInDB")
+let songFilterImageExist = document.getElementById("songFilterImageExist")
+/**
+ * Get the current state of filters, with fields NameFilter, ArtistFilter, DBFilter, ImageFilter
+ * @returns filterstates with fields mentioned above
+ **/
+function getFilterStates() {
+ let filterStates
+ filterStates.NameFilter = songFilterName.value.toLowerCase()
+ filterStates.ArtistFilter = songFilterArtist.value.toLowerCase()
+ filterStates.DBFilter = songFilterInDB.checked
+ filterStates.ImageExist = songFilterImageExist.checked
+
+ return filterStates
+}
+
+/**
+ * SETUP / RUN AT START SECTION
+ **/
getSongList()
// ==============================================================