mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Votes and shuffled lists remain the same if the user navigates from a frontpage, and back to the same list in private mode
This commit is contained in:
4
public/dist/embed.min.js
vendored
4
public/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
8
public/dist/main.min.js
vendored
8
public/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -282,6 +282,8 @@ var Frontpage = {
|
|||||||
|
|
||||||
if(!popstate){
|
if(!popstate){
|
||||||
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
||||||
|
if(prev_chan_list == "") prev_chan_list = new_channel;
|
||||||
|
if(prev_chan_player == "") prev_chan_player = new_channel;
|
||||||
window.chan = new_channel;
|
window.chan = new_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +378,7 @@ function initfp(){
|
|||||||
|
|
||||||
Crypt.init();
|
Crypt.init();
|
||||||
if(Crypt.get_offline()){
|
if(Crypt.get_offline()){
|
||||||
change_offline(true);
|
change_offline(true, offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('frontpage_lists');
|
socket.emit('frontpage_lists');
|
||||||
|
|||||||
@@ -14,11 +14,17 @@ var List = {
|
|||||||
{
|
{
|
||||||
case "list":
|
case "list":
|
||||||
//if(full_playlist == undefined || !offline){
|
//if(full_playlist == undefined || !offline){
|
||||||
if(!offline || (offline && !msg.shuffled)){
|
if((!offline || (offline && !msg.shuffled)) && !(offline && prev_chan_list == chan)){
|
||||||
|
prev_chan_list = chan;
|
||||||
List.populate_list(msg.playlist);
|
List.populate_list(msg.playlist);
|
||||||
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});
|
||||||
}
|
}
|
||||||
|
} else if(offline && prev_chan_list == chan && full_playlist != undefined && !msg.shuffled){
|
||||||
|
List.populate_list(full_playlist, true);
|
||||||
|
if(chromecastAvailable){
|
||||||
|
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "added":
|
case "added":
|
||||||
@@ -84,7 +90,7 @@ var List = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
populate_list: function(msg)
|
populate_list: function(msg, no_reset)
|
||||||
{
|
{
|
||||||
if(!Helper.mobilecheck() && !embed){
|
if(!Helper.mobilecheck() && !embed){
|
||||||
List.can_fit = Math.round(($("#wrapper").height()) / 71)+1;
|
List.can_fit = Math.round(($("#wrapper").height()) / 71)+1;
|
||||||
@@ -98,7 +104,7 @@ var List = {
|
|||||||
}
|
}
|
||||||
if(list_html === undefined) list_html = $("#list-song-html").html();
|
if(list_html === undefined) list_html = $("#list-song-html").html();
|
||||||
full_playlist = msg;
|
full_playlist = msg;
|
||||||
if(offline){
|
if(offline && !no_reset){
|
||||||
for(var x = 0; x < full_playlist.length; x++){
|
for(var x = 0; x < full_playlist.length; x++){
|
||||||
full_playlist[x].votes = 0;
|
full_playlist[x].votes = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ var color = "808080";
|
|||||||
var find_start = false;
|
var find_start = false;
|
||||||
var find_started = false;
|
var find_started = false;
|
||||||
var offline = false;
|
var offline = false;
|
||||||
|
var prev_chan_list = "";
|
||||||
|
var prev_chan_player = "";
|
||||||
var chromecastReady = false;
|
var chromecastReady = false;
|
||||||
var found_array = [];
|
var found_array = [];
|
||||||
var found_array_index = 0;
|
var found_array_index = 0;
|
||||||
@@ -198,7 +200,7 @@ function init(){
|
|||||||
Crypt.init();
|
Crypt.init();
|
||||||
if(Crypt.get_offline()){
|
if(Crypt.get_offline()){
|
||||||
$(".offline_switch_class")[0].checked = true;
|
$(".offline_switch_class")[0].checked = true;
|
||||||
change_offline(true);
|
change_offline(true, offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#alreadychannel").length === 0 || Helper.mobilecheck()){
|
if($("#alreadychannel").length === 0 || Helper.mobilecheck()){
|
||||||
@@ -497,61 +499,61 @@ function randomString(length){
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_offline(enabled){
|
function change_offline(enabled, already_offline){
|
||||||
Crypt.set_offline(enabled);
|
Crypt.set_offline(enabled);
|
||||||
offline = enabled;
|
offline = enabled;
|
||||||
socket.emit("offline", enabled);
|
socket.emit("offline", enabled);
|
||||||
if(enabled){
|
if(enabled){
|
||||||
if(list_html){
|
if(list_html){
|
||||||
list_html = $("<div>" + list_html + "</div>");
|
list_html = $("<div>" + list_html + "</div>");
|
||||||
//list_html.find(".card-content").css("display", "flex");
|
//list_html.find(".card-content").css("display", "flex");
|
||||||
//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.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");
|
$(".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");
|
||||||
$("#offline-mode").addClass("cyan");
|
$("#offline-mode").addClass("cyan");
|
||||||
if(full_playlist != undefined){
|
if(full_playlist != undefined && !already_offline){
|
||||||
for(var x = 0; x < full_playlist.length; x++){
|
for(var x = 0; x < full_playlist.length; x++){
|
||||||
full_playlist[x].votes = 0;
|
full_playlist[x].votes = 0;
|
||||||
}
|
}
|
||||||
List.sortList();
|
List.sortList();
|
||||||
List.populate_list(full_playlist);
|
List.populate_list(full_playlist);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(list_html){
|
if(list_html){
|
||||||
list_html = $("<div>" + list_html + "</div>");
|
list_html = $("<div>" + list_html + "</div>");
|
||||||
//list_html.find(".card-content").css("display", "block");
|
//list_html.find(".card-content").css("display", "block");
|
||||||
//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)){
|
if((!hasadmin || !w_p)){
|
||||||
list_html.find(".list-remove").addClass("hide");
|
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");
|
||||||
//$(".card-content").css("height", "initial");
|
//$(".card-content").css("height", "initial");
|
||||||
//$(".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)){
|
if((!hasadmin || !w_p)){
|
||||||
$(".list-remove").addClass("hide");
|
$(".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 != "/"){
|
||||||
socket.emit("pos");
|
socket.emit("pos");
|
||||||
socket.emit('list', chan.toLowerCase());
|
socket.emit('list', chan.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,11 +599,11 @@ $(document).keyup(function(e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", "#offline-mode", function(e){
|
$(document).on("click", "#offline-mode", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if(!Crypt.get_offline()){
|
if(!Crypt.get_offline()){
|
||||||
change_offline(true);
|
change_offline(true, offline);
|
||||||
} else{
|
} else{
|
||||||
change_offline(false);
|
change_offline(false, offline);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -766,7 +768,7 @@ $(document).on("change", 'input[class=offline_switch_class]', function()
|
|||||||
{
|
{
|
||||||
//Hostcontroller.change_enabled(document.getElementsByName("remote_switch")[0].checked);
|
//Hostcontroller.change_enabled(document.getElementsByName("remote_switch")[0].checked);
|
||||||
offline = document.getElementsByName("offline_switch")[0].checked;
|
offline = document.getElementsByName("offline_switch")[0].checked;
|
||||||
change_offline(offline);
|
change_offline(offline, !offline);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("change", 'input[class=conf]', function()
|
$(document).on("change", 'input[class=conf]', function()
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ var Player = {
|
|||||||
}catch(e){
|
}catch(e){
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
if((!offline && (state != null || from_frontpage)) || (offline && (!(state != null) || from_frontpage))|| (!offline && (!(state != null) || from_frontpage)) || (offline && state == -1)){
|
if(((!offline && (state != null || from_frontpage)) || (offline && (!(state != null) || from_frontpage))|| (!offline && (!(state != null) || from_frontpage)) || (offline && state == -1)) && !(offline && prev_chan_player == chan)){
|
||||||
|
prev_chan_player = chan;
|
||||||
from_frontpage = false;
|
from_frontpage = false;
|
||||||
Player.loaded = false;
|
Player.loaded = false;
|
||||||
Helper.log("--------youtube_listener--------");
|
Helper.log("--------youtube_listener--------");
|
||||||
@@ -114,6 +115,7 @@ var Player = {
|
|||||||
} else {
|
} else {
|
||||||
if(!durationBegun)
|
if(!durationBegun)
|
||||||
Player.durationSetter();
|
Player.durationSetter();
|
||||||
|
duration = Player.player.getDuration();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user