Updated embedded player to work with the new offline functions

This commit is contained in:
Kasper Rynning-Tønnesen
2017-01-25 19:17:24 +01:00
parent 02b946448f
commit 01d4a38353
7 changed files with 55 additions and 18 deletions

View File

@@ -983,6 +983,7 @@ hide mdi-action-visibility mdi-action-visibility-off
#wrapper { #wrapper {
padding-right:0vh !important; padding-right:0vh !important;
width:100% !important; width:100% !important;
overflow:hidden;
} }
} }
@@ -1914,6 +1915,7 @@ nav ul li:hover, nav ul li.active {
overflow: auto; overflow: auto;
/*padding-right: 5vh;*/ /*padding-right: 5vh;*/
opacity: 1; opacity: 1;
overflow:hidden;
} }
#playlist{ #playlist{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -154,7 +154,7 @@ var Admin = {
} }
if($(".card-action").length !== 0 && if($(".card-action").length !== 0 &&
!Helper.contains($(".card-action").attr("class").split(" "), "hide")){ !Helper.contains($(".card-action").attr("class").split(" "), "hide") && !offline){
$(".card-action").addClass("hide"); $(".card-action").addClass("hide");
} }

View File

@@ -11,6 +11,7 @@ var adminpass = "";
var mobile_beginning = false; var mobile_beginning = false;
var durationBegun = false; var durationBegun = false;
var chromecastAvailable = false; var chromecastAvailable = false;
var offline = false;
var seekTo; var seekTo;
var socket; var socket;

View File

@@ -301,11 +301,33 @@ var List = {
try{ try{
to_delete.style.height = 0; to_delete.style.height = 0;
if(index < List.page && $("#wrapper").children().length - (List.page + 2) >= 0){
$($("#wrapper").children()[List.page]).css("height", 0);
$($("#wrapper").children()[List.page]).css("display", "block");
$($("#wrapper").children()[List.page]).css("height", List.element_height);
} else if($("#wrapper").children().length > List.page + (List.can_fit)){
$($("#wrapper").children()[List.page + (List.can_fit)]).css("height", 0);
$($("#wrapper").children()[List.page + (List.can_fit)]).css("display", "block");
$($("#wrapper").children()[List.page + (List.can_fit)]).css("height", List.element_height);
}
if(List.page >= $("#wrapper").children().length - 1){
List.dynamicContentPage(-1);
$(".next_page_hide").css("display", "inline-block");
$(".next_page").css("display", "none");
$(".last_page_hide").css("display", "inline-block");
$(".last_page").css("display", "none");
} else if(List.page + List.can_fit + 1 >= $("#wrapper").children().length - 1){
$(".next_page_hide").css("display", "inline-block");
$(".next_page").css("display", "none");
$(".last_page_hide").css("display", "inline-block");
$(".last_page").css("display", "none");
}
setTimeout(function() setTimeout(function()
{ {
$("#"+deleted).remove(); $("#"+deleted).remove();
full_playlist.splice(List.getIndexOfSong(deleted), 1); full_playlist.splice(List.getIndexOfSong(deleted), 1);
if(index < List.page && $("#wrapper").children().length - (List.page + 1) >= 0){ /*if(index < List.page && $("#wrapper").children().length - (List.page + 1) >= 0){
$($("#wrapper").children()[List.page - 1]).css("display", "block"); $($("#wrapper").children()[List.page - 1]).css("display", "block");
} else if($("#wrapper").children().length > List.page + (List.can_fit-1)){ } else if($("#wrapper").children().length > List.page + (List.can_fit-1)){
$($("#wrapper").children()[List.page + (List.can_fit - 1)]).css("display", "block"); $($("#wrapper").children()[List.page + (List.can_fit - 1)]).css("display", "block");
@@ -315,7 +337,7 @@ var List = {
} else if(List.page + List.can_fit >= $("#wrapper").children().length){ } else if(List.page + List.can_fit >= $("#wrapper").children().length){
$(".next_page_hide").css("display", "inline-block"); $(".next_page_hide").css("display", "inline-block");
$(".next_page").css("display", "none"); $(".next_page").css("display", "none");
} }*/
if(chromecastAvailable){ if(chromecastAvailable){
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id}); Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
} }
@@ -341,9 +363,9 @@ var List = {
$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>"); $("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>");
} }
$("#suggested-"+deleted).remove(); $("#suggested-"+deleted).remove();
if(List.page + List.can_fit < $("#wrapper").children().length){ if(List.page + List.can_fit < $("#wrapper").children().length + 1){
$(".next_page_hide").css("display", "none"); //$(".next_page_hide").css("display", "none");
$(".next_page").css("display", "inline-block"); //$(".next_page").css("display", "inline-block");
} }
if(List.page >= $("#wrapper").children().length){ if(List.page >= $("#wrapper").children().length){
List.dynamicContentPage(-1); List.dynamicContentPage(-1);
@@ -392,10 +414,14 @@ var List = {
}, },
vote: function(id, vote){ vote: function(id, vote){
if(!offline){ if(!offline || (vote == "del" && (hasadmin && (!w_p && adminpass != "")))){
socket.emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass}); socket.emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass});
} else { } else {
if(vote == "pos"){
List.voted_song(id, (new Date()).getTime()/1000); List.voted_song(id, (new Date()).getTime()/1000);
} else {
List.deleted_song(id);
}
} }
return true; return true;
}, },

View File

@@ -504,11 +504,13 @@ function change_offline(enabled){
list_html.find(".card-content").css("height", "100%"); list_html.find(".card-content").css("height", "100%");
list_html.find(".list-title").css("align-self", "center"); list_html.find(".list-title").css("align-self", "center");
list_html.find(".vote-span").addClass("hide"); list_html.find(".vote-span").addClass("hide");
list_html.find(".list-remove").removeClass("hide");
list_html = list_html.html(); list_html = list_html.html();
} }
$(".card-content").css("display", "flex"); $(".card-content").css("display", "flex");
$(".card-content").css("height", "100%"); $(".card-content").css("height", "100%");
$(".list-title").css("align-self", "center"); $(".list-title").css("align-self", "center");
$(".list-remove").removeClass("hide");
$(".vote-span").addClass("hide"); $(".vote-span").addClass("hide");
$("#viewers").addClass("hide"); $("#viewers").addClass("hide");
$("#offline-mode").removeClass("waves-cyan"); $("#offline-mode").removeClass("waves-cyan");
@@ -520,6 +522,9 @@ function change_offline(enabled){
list_html.find(".card-content").css("height", "initial"); list_html.find(".card-content").css("height", "initial");
list_html.find(".list-title").css("align-self", "center"); list_html.find(".list-title").css("align-self", "center");
list_html.find(".vote-span").removeClass("hide"); list_html.find(".vote-span").removeClass("hide");
if((!hasadmin || !w_p)){
list_html.find(".list-remove").addClass("hide");
}
list_html = list_html.html(); list_html = list_html.html();
} }
$(".card-content").css("display", "block"); $(".card-content").css("display", "block");
@@ -527,6 +532,9 @@ function change_offline(enabled){
$(".list-title").css("align-self", "center"); $(".list-title").css("align-self", "center");
$(".vote-span").removeClass("hide"); $(".vote-span").removeClass("hide");
$("#viewers").removeClass("hide"); $("#viewers").removeClass("hide");
if((!hasadmin || !w_p)){
$(".list-remove").addClass("hide");
}
$("#offline-mode").addClass("waves-cyan"); $("#offline-mode").addClass("waves-cyan");
$("#offline-mode").removeClass("cyan"); $("#offline-mode").removeClass("cyan");
if(window.location.pathname != "/"){ if(window.location.pathname != "/"){