mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Adding playlists works even better now
This commit is contained in:
2
static/dist/embed.min.js
vendored
2
static/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
3034
static/dist/main.min.js
vendored
3034
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -31,6 +31,33 @@ var List = {
|
||||
}
|
||||
},
|
||||
|
||||
insertAtBeginning: function(song_info, transition) {
|
||||
var add = List.generateSong(song_info, transition, false, true, false);
|
||||
$("#wrapper").append(add);
|
||||
},
|
||||
|
||||
insertAtIndex: function(song_info, transition) {
|
||||
var i = List.getIndexOfSong(song_info.id);
|
||||
|
||||
if(!song_info.now_playing){
|
||||
|
||||
var add = List.generateSong(song_info, transition, false, true, false);
|
||||
if(i == 0) {
|
||||
$("#wrapper").prepend(add);
|
||||
} else {
|
||||
$("#wrapper > div:nth-child(" + (i) + ")").after(add);
|
||||
}
|
||||
}
|
||||
var added = $("#wrapper").children()[i];
|
||||
|
||||
if(transition)
|
||||
{
|
||||
setTimeout(function(){
|
||||
$(added).css("height", 66);
|
||||
},5);
|
||||
}
|
||||
},
|
||||
|
||||
populate_list: function(msg)
|
||||
{
|
||||
if(list_html == undefined) list_html = $("#list-song-html").html();
|
||||
@@ -63,18 +90,20 @@ var List = {
|
||||
$("#settings").css("visibility", "visible");
|
||||
$("#settings").css("opacity", "1");
|
||||
$("#wrapper").css("opacity", "1");
|
||||
|
||||
},
|
||||
|
||||
added_song: function(added){
|
||||
now_playing = full_playlist.pop();
|
||||
full_playlist.push(added);
|
||||
List.sortList();
|
||||
full_playlist.push(now_playing);
|
||||
$("#suggested-"+added.id).remove();
|
||||
if(List.empty){
|
||||
$("#empty-channel-message").remove();
|
||||
List.empty = false;
|
||||
}
|
||||
$("#empty-channel-message").remove();
|
||||
List.insertAtIndex(added, true);
|
||||
|
||||
},
|
||||
|
||||
deleted_song: function(deleted){
|
||||
@@ -130,7 +159,10 @@ var List = {
|
||||
full_playlist.push(full_playlist.shift());
|
||||
if(!List.empty)
|
||||
$("#wrapper").children()[0].remove();
|
||||
|
||||
if($("#wrapper").children().length == 0) {
|
||||
List.empty = true;
|
||||
$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>");
|
||||
}
|
||||
List.insertAtIndex(full_playlist[length-1], false);
|
||||
document.getElementById('wrapper').scrollTop += 1;
|
||||
document.getElementById('wrapper').scrollTop += -1;
|
||||
@@ -202,24 +234,6 @@ var List = {
|
||||
}
|
||||
},
|
||||
|
||||
insertAtIndex: function(song_info, transition) {
|
||||
i = List.getIndexOfSong(song_info.id);
|
||||
|
||||
if(i === 0)
|
||||
$("#wrapper").prepend(List.generateSong(song_info, transition, false, true, false));
|
||||
else
|
||||
$("#wrapper > div:nth-child(" + (i) + ")").after(List.generateSong(song_info, transition, false, true, false));
|
||||
|
||||
var added = $("#wrapper").children()[i];
|
||||
|
||||
if(transition)
|
||||
{
|
||||
setTimeout(function(){
|
||||
$(added).css("height", 66);
|
||||
},5);
|
||||
}
|
||||
},
|
||||
|
||||
generateSong: function(song_info, transition, lazy, list, user)
|
||||
{
|
||||
var video_id = song_info.id;
|
||||
|
||||
@@ -40,11 +40,10 @@ var Player = {
|
||||
if(mobile_beginning && window.mobilecheck() && seekTo == 0)
|
||||
seekTo = 1;
|
||||
|
||||
if(full_playlist[0].id == video_id){
|
||||
List.song_change(full_playlist[0].added);
|
||||
}
|
||||
|
||||
try{
|
||||
if(full_playlist[0].id == video_id){
|
||||
List.song_change(full_playlist[0].added);
|
||||
}
|
||||
Suggestions.fetchYoutubeSuggests(video_id);
|
||||
}catch(e){}
|
||||
Player.getTitle(song_title, viewers);
|
||||
|
||||
@@ -146,19 +146,20 @@ var Search = {
|
||||
success: function(response)
|
||||
{
|
||||
var ids="";
|
||||
Search.addVideos(response.items[0].contentDetails.videoId);
|
||||
//Search.addVideos(response.items[0].contentDetails.videoId);
|
||||
//response.items.shift();
|
||||
$.each(response.items, function(i,data)
|
||||
{
|
||||
ids+=data.contentDetails.videoId+",";
|
||||
});
|
||||
Search.addVideos(ids);
|
||||
Search.addVideos(ids, true);
|
||||
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
||||
document.getElementById("import").value = "";
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addVideos: function(ids){
|
||||
addVideos: function(ids, playlist){
|
||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
||||
request_url += ids;
|
||||
|
||||
@@ -172,7 +173,7 @@ var Search = {
|
||||
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
||||
if(!longsongs || duration<720){
|
||||
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
||||
Search.submit(song.id, enc_title, duration);
|
||||
Search.submit(song.id, enc_title, duration, playlist);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -180,8 +181,9 @@ var Search = {
|
||||
});
|
||||
},
|
||||
|
||||
submit: function(id,title,duration){
|
||||
socket.emit("add", [id, decodeURIComponent(title), adminpass, duration]);
|
||||
submit: function(id,title,duration, playlist){
|
||||
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist});
|
||||
//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||
},
|
||||
|
||||
durationToSeconds: function(duration) {
|
||||
|
||||
Reference in New Issue
Block a user