mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Improved all list importing, and added error-messages for faulty url/ids
This commit is contained in:
6
static/dist/main.min.js
vendored
6
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -418,7 +418,10 @@ $(document).on("submit", "#listImport", function(e){
|
|||||||
document.getElementById("import").disabled = true;
|
document.getElementById("import").disabled = true;
|
||||||
$("#import").addClass("hide");
|
$("#import").addClass("hide");
|
||||||
$("#playlist_loader").removeClass("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){
|
$(document).on("submit", "#listImportSpotify", function(e){
|
||||||
@@ -431,13 +434,16 @@ $(document).on("submit", "#listImportSpotify", function(e){
|
|||||||
var user = url[0];
|
var user = url[0];
|
||||||
var playlist_id = url[2];
|
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;
|
document.getElementById("import_spotify").disabled = true;
|
||||||
$("#import_spotify").addClass("hide");
|
$("#import_spotify").addClass("hide");
|
||||||
$("#playlist_loader_spotify").removeClass("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(){
|
$(window).focus(function(){
|
||||||
|
|||||||
@@ -243,6 +243,12 @@ var Search = {
|
|||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response)
|
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="";
|
var ids="";
|
||||||
//Search.addVideos(response.items[0].contentDetails.videoId);
|
//Search.addVideos(response.items[0].contentDetails.videoId);
|
||||||
//response.items.shift();
|
//response.items.shift();
|
||||||
@@ -254,6 +260,7 @@ var Search = {
|
|||||||
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
||||||
document.getElementById("import").value = "";
|
document.getElementById("import").value = "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -264,7 +271,6 @@ var Search = {
|
|||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
console.log(response);
|
|
||||||
$.each(response.items, function(i,data)
|
$.each(response.items, function(i,data)
|
||||||
{
|
{
|
||||||
//ids+=data.contentDetails.videoId+",";
|
//ids+=data.contentDetails.videoId+",";
|
||||||
@@ -274,6 +280,12 @@ var Search = {
|
|||||||
if(response.next){
|
if(response.next){
|
||||||
Search.importSpotifyPlaylist(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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user