mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Started intelligent-list feature
This commit is contained in:
@@ -2036,7 +2036,7 @@ nav ul li:hover, nav ul li.active {
|
||||
transition: all .1s ease;
|
||||
}
|
||||
|
||||
.vote-container{
|
||||
.vote-container, .deleted-vote-container{
|
||||
height: 100%;
|
||||
width: 90%;
|
||||
}
|
||||
@@ -2766,6 +2766,11 @@ nav ul li:hover, nav ul li.active {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.disabled-vote{
|
||||
cursor: not-allowed !important;
|
||||
background: rgba(255,255,255,.2);
|
||||
}
|
||||
|
||||
.hide
|
||||
{
|
||||
display:none !important;
|
||||
|
||||
@@ -3,6 +3,7 @@ var timed_remove_check;
|
||||
var gotten_np = false;
|
||||
var song_title = "";
|
||||
var paused = false;
|
||||
var intelligentList = true;
|
||||
var client = false;
|
||||
var _VERSION;
|
||||
try {
|
||||
@@ -19,6 +20,7 @@ if(window.location.hostname == "localhost" || window.location.hostname == "clien
|
||||
}
|
||||
var SC_player;
|
||||
var durationTimeout;
|
||||
var intelligentQueue = [];
|
||||
var sc_need_initialization = true;
|
||||
var sc_initialized = false;
|
||||
var startTime = 0;
|
||||
|
||||
@@ -611,6 +611,35 @@ function loadChromecastVideo() {
|
||||
});
|
||||
}
|
||||
|
||||
window.clearIntelligentQueue = clearIntelligentQueue;
|
||||
|
||||
function clearIntelligentQueue() {
|
||||
for(var i = 0; i < intelligentQueue.length; i++) {
|
||||
console.log(intelligentQueue[i]);
|
||||
var currentElement = intelligentQueue[i];
|
||||
console.log(currentElement);
|
||||
if(currentElement.type == "vote") {
|
||||
Helper.removeElement("#"+currentElement.element.id);
|
||||
List.insertAtIndex(currentElement.element, false);
|
||||
} else if(currentElement.type == "delete") {
|
||||
List.deleted_song(currentElement.element.id, false, true);
|
||||
} else if(currentElement.type == "add") {
|
||||
List.insertAtIndex(currentElement.element, true);
|
||||
Helper.css(document.querySelector("#wrapper").children[List.page + List.can_fit], "display", "none");
|
||||
if(document.querySelector("#wrapper").children.length > List.page + List.can_fit){
|
||||
Helper.css(".next_page_hide", "display", "none");
|
||||
Helper.removeClass(".next_page", "hide");
|
||||
Helper.css(".last_page_hide", "display", "none");
|
||||
Helper.css(".next_page", "display", "inline-flex");
|
||||
Helper.css(".last_page", "display", "inline-flex");
|
||||
} else {
|
||||
Helper.css(".next_page_hide", "display", "inline-flex");
|
||||
Helper.css(".next_page", "display", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateChromecastMetadata() {
|
||||
if(!chromecastAvailable) return;
|
||||
var image = {url:'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', heigth: 180, width: 320};
|
||||
|
||||
@@ -121,6 +121,7 @@ var List = {
|
||||
insertAtIndex: function(song_info, transition, change) {
|
||||
if(document.querySelector("#wrapper") == null) return;
|
||||
var i = List.getIndexOfSong(song_info.id);
|
||||
console.log(i, song_info);
|
||||
var display = "none";
|
||||
if(!song_info.now_playing){
|
||||
if(i >= List.page && i < List.page + (List.can_fit)) display = "inline-flex"
|
||||
@@ -397,6 +398,12 @@ var List = {
|
||||
if(document.querySelectorAll("#empty-channel-message").length > 0) {
|
||||
document.querySelector("#empty-channel-message").remove();
|
||||
}
|
||||
if(intelligentList) {
|
||||
intelligentQueue.push({
|
||||
type: "add",
|
||||
element: added,
|
||||
});
|
||||
} else {
|
||||
List.insertAtIndex(added, true);
|
||||
Helper.css(document.querySelector("#wrapper").children[List.page + List.can_fit], "display", "none");
|
||||
if(document.querySelector("#wrapper").children.length > List.page + List.can_fit){
|
||||
@@ -410,11 +417,28 @@ var List = {
|
||||
Helper.css(".next_page", "display", "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
deleted_song: function(deleted, removed) {
|
||||
deleted_song: function(deleted, removed, intelligentSecond) {
|
||||
try{
|
||||
console.log(deleted);
|
||||
var index = List.getIndexOfSong(deleted);
|
||||
console.log("place 2");
|
||||
if(intelligentList && !intelligentSecond) {
|
||||
intelligentQueue.push({
|
||||
type: "delete",
|
||||
element: full_playlist[index],
|
||||
});
|
||||
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
||||
var this_element = document.getElementById(deleted);
|
||||
Helper.addClass(this_element, "disabled-vote");
|
||||
this_element.querySelector(".vote-span").innerText = "Deleted";
|
||||
Helper.addClass(this_element.querySelector(".vote-container"), "deleted-vote-container");
|
||||
Helper.removeClass(this_element.querySelector(".vote-container"), "clickable");
|
||||
Helper.removeClass(this_element.querySelector(".vote-container"), "vote-container");
|
||||
return;
|
||||
} else {
|
||||
//if(!removed) to_delete.style.height = 0;
|
||||
var nextToChange;
|
||||
if(index < List.page && document.querySelector("#wrapper").children.length - (List.page + 2) >= 0){
|
||||
@@ -464,12 +488,16 @@ var List = {
|
||||
Helper.css(nextToChange, "height", List.element_height + "px");
|
||||
}
|
||||
}
|
||||
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
||||
var index = List.getIndexOfSong(deleted);
|
||||
if(index != -1) full_playlist.splice(index, 1);
|
||||
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail});
|
||||
//}
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
||||
console.log(err);
|
||||
var index = List.getIndexOfSong(deleted);
|
||||
if(index != -1) full_playlist.splice(index, 1);
|
||||
if(!List.empty){
|
||||
try {
|
||||
document.getElementById(deleted).remove();
|
||||
@@ -508,9 +536,20 @@ var List = {
|
||||
full_playlist[index_of_song].votes += 1;
|
||||
full_playlist[index_of_song].added = time;
|
||||
|
||||
|
||||
if(intelligentList) {
|
||||
console.log(full_playlist[index_of_song].votes, full_playlist[index_of_song]);
|
||||
document.getElementById(voted).querySelector(".list-votes").innerText = full_playlist[index_of_song].votes;
|
||||
intelligentQueue.push({
|
||||
type: "vote",
|
||||
element: song_voted_on
|
||||
});
|
||||
List.sortList();
|
||||
} else {
|
||||
List.sortList();
|
||||
Helper.removeElement("#"+voted);
|
||||
List.insertAtIndex(song_voted_on, false);
|
||||
}
|
||||
},
|
||||
|
||||
song_change_prev: function(time) {
|
||||
@@ -537,7 +576,7 @@ var List = {
|
||||
song_change: function(time, remove) {
|
||||
try{
|
||||
var length = full_playlist.length - 1;
|
||||
document.querySelector("#wrapper").children[0].remove();
|
||||
|
||||
if(full_playlist.length <= 1) {
|
||||
List.empty = true;
|
||||
Helper.setHtml("#wrapper", "<span id='empty-channel-message'>The playlist is empty.</span>");
|
||||
@@ -547,6 +586,19 @@ var List = {
|
||||
full_playlist[0].votes = 0;
|
||||
full_playlist[0].guids = [];
|
||||
full_playlist[0].added = time;
|
||||
var i = intelligentQueue.length
|
||||
var deleted_elements = 0;
|
||||
while (i--) {
|
||||
var current = intelligentQueue[i];
|
||||
if (current.type == "delete") {
|
||||
intelligentQueue.splice(i, 1);
|
||||
Helper.removeElement("#" + current.element.id);
|
||||
deleted_elements += 1;
|
||||
}
|
||||
}
|
||||
try {
|
||||
document.getElementById(full_playlist[0].id).remove();
|
||||
} catch(e) {};
|
||||
if(!remove){
|
||||
full_playlist[length].now_playing = false;
|
||||
} else {
|
||||
@@ -561,10 +613,14 @@ var List = {
|
||||
if(!remove){
|
||||
List.insertAtIndex(full_playlist[document.querySelector("#wrapper").children.length], false, true);
|
||||
}
|
||||
/*var wrapperChildren = [].slice.call(document.querySelector("#wrapper").children);
|
||||
if(wrapperChildren.length > List.can_fit) {
|
||||
//Helper.css(wrapperChildren[List.can_fit], "display", "inline-flex");
|
||||
}*/
|
||||
var wrapperChildren = [].slice.call(document.querySelector("#wrapper").children);
|
||||
if(wrapperChildren.length >= List.can_fit && intelligentList) {
|
||||
console.log(wrapperChildren[List.can_fit]);
|
||||
for(var i = 0; i < deleted_elements + 1; i++) {
|
||||
//Helper.css(wrapperChildren[List.can_fit - 2], "display", "inline-flex");
|
||||
Helper.css(wrapperChildren[List.can_fit - 1 - i], "display", "inline-flex");
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
@@ -1276,7 +1332,6 @@ var List = {
|
||||
for(var i = 0; i < full_playlist.length; i++) {
|
||||
if(full_playlist[i].id == id) return i;
|
||||
}
|
||||
|
||||
} catch(e) {}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,6 +17,8 @@ var scUsingWidget = false;
|
||||
var SC_player;
|
||||
var previewing = false;
|
||||
var sc_initialized = false;
|
||||
var intelligentQueue = [];
|
||||
var intelligentList = true;
|
||||
var soundcloud_enabled = true;
|
||||
var local_new_channel = false;
|
||||
var sc_need_initialization = true;
|
||||
|
||||
Reference in New Issue
Block a user