From f0e1e26cc3ff1bd1f9500fcbcade14d2fe1c8710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Tue, 23 Oct 2018 13:10:11 +0200 Subject: [PATCH] Added not found and logging --- server/public/assets/js/list.js | 42 +++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/server/public/assets/js/list.js b/server/public/assets/js/list.js index a1cba5f6..af67317b 100755 --- a/server/public/assets/js/list.js +++ b/server/public/assets/js/list.js @@ -610,13 +610,7 @@ var List = { console.log(thisSong, i); if(i >= full_playlist.length) { console.log(result, List.found, List.not_found); - SC_player.post('/playlists', { - playlist: { - title: chan.toLowerCase() + " - Zoff", - tracks: List.found, - } - }).then(function(result) { - console.log(result, List.found, List.not_found); + if(List.found.length == 0) { for(var x = 0; x < List.not_found.length; x++) { var data = List.not_found[x]; var not_added_song = document.createElement("div"); @@ -628,12 +622,34 @@ var List = { Helper.addClass(".current_number", "hide"); Helper.addClass("#playlist_loader_export", "hide"); Helper.addClass(".exported-list-container", "hide"); - document.querySelector(".exported-list").insertAdjacentHTML("beforeend", "" + result.title + ""); List.found = []; List.not_found = []; - }).catch(function(error) { - console.log(error); - }); + } else { + SC_player.post('/playlists', { + playlist: { + title: chan.toLowerCase() + " - Zoff", + tracks: List.found, + } + }).then(function(result) { + console.log(result, List.found, List.not_found); + for(var x = 0; x < List.not_found.length; x++) { + var data = List.not_found[x]; + var not_added_song = document.createElement("div"); + not_added_song.innerHTML = not_export_html; + not_added_song.querySelector(".extra-add-text").setAttribute("value", data); + not_added_song.querySelector(".extra-add-text").setAttribute("title", data); + document.querySelector(".not-exported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML); + } + Helper.addClass(".current_number", "hide"); + Helper.addClass("#playlist_loader_export", "hide"); + Helper.addClass(".exported-list-container", "hide"); + document.querySelector(".exported-list").insertAdjacentHTML("beforeend", "" + result.title + ""); + List.found = []; + List.not_found = []; + }).catch(function(error) { + console.log(error); + }); + } } else if(thisSong == undefined) { if(full_playlist.length > 0) { List.exportToSoundCloud(full_playlist[0], 0); @@ -664,8 +680,10 @@ var List = { if(title.indexOf(song.user.username) == -1) { title = song.user.username + " - " + title; } + title = title.toLowerCase(); var id=song.id; - if(similarity(title, thisSong.track) > 0.60) { + console.log(title, thisSong.title, similarity(title, thisSong.title)); + if(similarity(title, thisSong.title) > 0.60) { List.found.push({id: parseInt(song.id)}); isFound = true; break;