Improved all list importing, and added error-messages for faulty url/ids

This commit is contained in:
Kasper Rynning-Tønnesen
2016-08-27 15:44:34 +02:00
parent a0fd178eca
commit 93ed57e720
3 changed files with 35 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@@ -418,7 +418,10 @@ $(document).on("submit", "#listImport", function(e){
document.getElementById("import").disabled = true;
$("#import").addClass("hide");
$("#playlist_loader").removeClass("hide");
} else {
Materialize.toast("It seems you've entered a invalid url.", 4000);
}
document.getElementById("import").value = "";
});
$(document).on("submit", "#listImportSpotify", function(e){
@@ -431,13 +434,16 @@ $(document).on("submit", "#listImportSpotify", function(e){
var user = url[0];
var playlist_id = url[2];
Search.importSpotifyPlaylist('https://api.spotify.com/v1/users/' + user + '/playlists/' + playlist_id + '/tracks');
}
}
document.getElementById("import_spotify").value = "";
document.getElementById("import_spotify").disabled = true;
$("#import_spotify").addClass("hide");
$("#playlist_loader_spotify").removeClass("hide");
Search.importSpotifyPlaylist('https://api.spotify.com/v1/users/' + user + '/playlists/' + playlist_id + '/tracks');
} else {
Materialize.toast("It seems you've entered a invalid url.", 4000);
}
}
document.getElementById("import_spotify").value = "";
});
$(window).focus(function(){

View File

@@ -243,6 +243,12 @@ var Search = {
dataType:"jsonp",
success: function(response)
{
if(response.error){
document.getElementById("import").disabled = false;
$("#playlist_loader").addClass("hide");
$("#import").removeClass("hide");
Materialize.toast("It seems you've entered a invalid url.", 4000);
} else {
var ids="";
//Search.addVideos(response.items[0].contentDetails.videoId);
//response.items.shift();
@@ -254,6 +260,7 @@ var Search = {
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
document.getElementById("import").value = "";
}
}
});
},
@@ -264,7 +271,6 @@ var Search = {
'Authorization': 'Bearer ' + access_token_data.access_token
},
success: function(response) {
console.log(response);
$.each(response.items, function(i,data)
{
//ids+=data.contentDetails.videoId+",";
@@ -274,6 +280,12 @@ var Search = {
if(response.next){
Search.importSpotifyPlaylist(response.next);
}
},
error: function() {
document.getElementById("import_spotify").disabled = false;
$("#import_spotify").removeClass("hide");
$("#playlist_loader_spotify").addClass("hide");
Materialize.toast("It seems you've entered a invalid url.", 4000);
}
});
},