mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Made major improvements to embedded player, added option for making server force clients to fully refresh, and added some more failsafes for the server
This commit is contained in:
@@ -311,7 +311,7 @@ var Admin = {
|
||||
shuffling = form.shuffle.checked;
|
||||
var pass_send = userpass == '' ? userpass : CryptoJS.SHA256(userpass).toString();
|
||||
configs = {
|
||||
voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: pass_send, userpass_changed: userpass_changed
|
||||
channel: chan.toLowerCase(), voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: pass_send, userpass_changed: userpass_changed
|
||||
};
|
||||
|
||||
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
|
||||
@@ -325,7 +325,7 @@ var Admin = {
|
||||
shuffle: function()
|
||||
{
|
||||
if(!offline){
|
||||
socket.emit('shuffle', adminpass !== undefined ? adminpass : "");
|
||||
socket.emit('shuffle', {adminpass: adminpass !== undefined ? adminpass : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
} else {
|
||||
for(var x = 0; x < full_playlist.length; x++){
|
||||
var num = Math.floor(Math.random()*1000000);
|
||||
|
||||
@@ -68,7 +68,7 @@ var Chat = {
|
||||
else if($(".chat-tab-li a.active").attr("href") == "#all_chat")
|
||||
socket.emit("all,chat", data.value);
|
||||
else
|
||||
socket.emit("chat", data.value);
|
||||
socket.emit("chat", {channel: chan.toLowerCase(), data: data.value});
|
||||
data.value = "";
|
||||
return;
|
||||
},
|
||||
|
||||
@@ -23,6 +23,7 @@ var chan = hash[0];
|
||||
var autoplay = false;
|
||||
var color = "#808080";
|
||||
var dragging = false;
|
||||
var user_auth_started = false;
|
||||
|
||||
var connection_options = {
|
||||
'sync disconnect on unload':true,
|
||||
@@ -38,12 +39,19 @@ $(document).ready(function(){
|
||||
paused = true;
|
||||
}
|
||||
|
||||
$("#locked_channel").modal({
|
||||
dismissible: false
|
||||
});
|
||||
color = "#" + hash[1];
|
||||
add = "https://zoff.me";
|
||||
add = "http://localhost";
|
||||
socket = io.connect(''+add+':8080', connection_options);
|
||||
|
||||
socket.on('auth_required', function() {
|
||||
$("#locked_channel").modal('open');
|
||||
});
|
||||
|
||||
socket.on("get_list", function(){
|
||||
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: Crypt.get_userpass(chan.toLowerCase())});},1000);
|
||||
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: ''});},1000);
|
||||
});
|
||||
|
||||
socket.on("viewers", function(view)
|
||||
|
||||
@@ -427,7 +427,12 @@ function initfp(){
|
||||
|
||||
if(window.location.hostname == "zoff.me") add = "https://zoff.me";
|
||||
else add = window.location.hostname;
|
||||
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) socket = io.connect(''+add+':8080', connection_options);
|
||||
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) {
|
||||
socket = io.connect(''+add+':8080', connection_options);
|
||||
socket.on('update_required', function() {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
|
||||
setup_playlist_listener();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ var Hostcontroller = {
|
||||
w_p = true;
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
|
||||
/*if(Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) != ""){
|
||||
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
||||
|
||||
@@ -465,7 +465,7 @@ var List = {
|
||||
|
||||
vote: function(id, vote){
|
||||
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, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
} else {
|
||||
if(vote == "pos"){
|
||||
List.voted_song(id, (new Date()).getTime()/1000);
|
||||
@@ -478,7 +478,7 @@ var List = {
|
||||
|
||||
skip: function(){
|
||||
if(!offline){
|
||||
socket.emit('skip', {pass: adminpass, id:video_id, channel: chan.toLowerCase()});
|
||||
socket.emit('skip', {pass: adminpass, id:video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
} else {
|
||||
Player.playNext();
|
||||
}
|
||||
|
||||
@@ -213,6 +213,9 @@ function init(){
|
||||
if(socket === undefined || Helper.mobilecheck()){
|
||||
no_socket = false;
|
||||
socket = io.connect(''+add+':8080', connection_options);
|
||||
socket.on('update_required', function() {
|
||||
window.location.reload(true);
|
||||
});
|
||||
}
|
||||
|
||||
Crypt.init();
|
||||
@@ -249,7 +252,7 @@ function init(){
|
||||
if(no_socket){
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}
|
||||
$("#viewers").tooltip({
|
||||
delay: 5,
|
||||
@@ -428,7 +431,7 @@ function hide_native(way){
|
||||
}
|
||||
} else {
|
||||
$("#volume").slider("value", 100);
|
||||
$("#player_overlay").width($("#player").width() + 1);
|
||||
//$("#player_overlay").width($("#player").width() + 1);
|
||||
}
|
||||
$("#player_overlay").css("background", "url(https://i.ytimg.com/vi/" + video_id + "/maxresdefault.jpg)");
|
||||
$("#player_overlay").css("background-position", "center");
|
||||
@@ -457,7 +460,7 @@ function hide_native(way){
|
||||
$("#chromecast_text").html("");
|
||||
$("#playing_on").css("display", "none");
|
||||
if(!offline){
|
||||
socket.emit('pos', {channel: chan.toLowerCase()});
|
||||
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
} else {
|
||||
Player.loadVideoById(video_id);
|
||||
}
|
||||
@@ -471,14 +474,14 @@ function chromecastListener(evt, data){
|
||||
if(offline){
|
||||
Player.playNext();
|
||||
} else {
|
||||
socket.emit("end", {id: json_parsed.videoId, channel: chan.toLowerCase()});
|
||||
socket.emit("end", {id: json_parsed.videoId, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
if(offline){
|
||||
Player.playNext();
|
||||
} else {
|
||||
socket.emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass, channel: chan.toLowerCase});
|
||||
socket.emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass, channel: chan.toLowerCase, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -529,7 +532,7 @@ function get_list_listener(){
|
||||
socket.on("get_list", function(){
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -721,10 +724,10 @@ function change_offline(enabled, already_offline){
|
||||
$("#controls").off("click", seekToClick);
|
||||
$("#seekToDuration").remove();
|
||||
if(window.location.pathname != "/"){
|
||||
socket.emit("pos");
|
||||
socket.emit("pos", {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
var add = "";
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
if($("#controls").hasClass("ewresize")) $("#controls").removeClass("ewresize");
|
||||
}
|
||||
}
|
||||
@@ -888,13 +891,13 @@ $(document).on("click", "#offline-mode", function(e){
|
||||
|
||||
$(document).on("submit", "#thumbnail_form", function(e){
|
||||
e.preventDefault();
|
||||
socket.emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||
socket.emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
$("#chan_thumbnail").val("");
|
||||
});
|
||||
|
||||
$(document).on("submit", "#description_form", function(e){
|
||||
e.preventDefault();
|
||||
socket.emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||
socket.emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
$("#chan_description").val("");
|
||||
});
|
||||
|
||||
@@ -1471,7 +1474,7 @@ $(window).resize(function(){
|
||||
List.can_fit = temp_fit;
|
||||
List.element_height = (($("#wrapper").height()) / List.can_fit)-5.3;
|
||||
$(".list-song").css("height", List.element_height + "px");
|
||||
$("#player_overlay").width($("#player").width()+1);
|
||||
//$("#player_overlay").width($("#player").width()+1);
|
||||
set_title_width();
|
||||
if($("#controls").length > 0 && !Helper.mobilecheck()) $("#seekToDuration").css("top", $("#controls").position().top - 55);
|
||||
else if($("#controls").length > 0) $("#seekToDuration").css("top", $("#controls").position().top - 20);
|
||||
@@ -1688,7 +1691,7 @@ function onepage_load(){
|
||||
var add = "";
|
||||
w_p = true;
|
||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}else if(url_split[3] === ""){
|
||||
user_change_password = false;
|
||||
clearTimeout(width_timeout);
|
||||
|
||||
@@ -138,7 +138,7 @@ var Player = {
|
||||
playing = false;
|
||||
paused = false;
|
||||
if(!offline){
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase()});
|
||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
} else {
|
||||
Player.playNext();
|
||||
}
|
||||
@@ -167,7 +167,7 @@ var Player = {
|
||||
}
|
||||
if(paused && !offline)
|
||||
{
|
||||
socket.emit('pos', {channel: chan.toLowerCase()});
|
||||
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
paused = false;
|
||||
}
|
||||
break;
|
||||
@@ -320,7 +320,7 @@ var Player = {
|
||||
curr_playing = Player.player.getVideoUrl().replace("https://www.youtube.com/watch?v=", "");
|
||||
|
||||
|
||||
socket.emit("skip", {error: newState.data, id: video_id, pass: adminpass, channel: chan.toLowerCase});
|
||||
socket.emit("skip", {error: newState.data, id: video_id, pass: adminpass, channel: chan.toLowerCase, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
//Helper.log(video_id, Player.player.getVideoUrl(), Player.player.getPlayerState());
|
||||
|
||||
/*}else{
|
||||
|
||||
@@ -20,6 +20,9 @@ $(document).ready(function (){
|
||||
if(window.location.hostname == "remote.zoff.me") add = "https://zoff.me";
|
||||
else add = "localhost";
|
||||
socket = io.connect(add+':8080', connection_options);
|
||||
socket.on('update_required', function() {
|
||||
window.location.reload(true);
|
||||
});
|
||||
id = window.location.pathname.split("/")[1];
|
||||
if(id)
|
||||
{
|
||||
|
||||
@@ -406,7 +406,7 @@ var Search = {
|
||||
List.vote(id, "pos");
|
||||
}
|
||||
} else {
|
||||
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num});
|
||||
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user