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