Merge pull request #163 from zoff-music/listpasswords

Listpasswords
This commit is contained in:
Kasper Rynning-Tønnesen
2017-05-04 23:36:52 +02:00
committed by GitHub
16 changed files with 300 additions and 82 deletions

View File

@@ -428,6 +428,22 @@ footer{
/* global colors */
.modal-overlay {
z-index: 999999 !important;
}
.modal {
z-index: 9999999999 !important;
}
.material-tooltip {
z-index: 999999 !important;
}
#user_password {
width: 50% !important;
}
.modal-header-fixed{
position:fixed;
width:100px;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),t.control());try{git_info=$.ajax({type:"GET",url:"https://api.github.com/users/zoff-music/received_events",async:!1}).responseText,git_info=$.parseJSON(git_info),$("#latest-commit").html("Latest Commit: <br>"+git_info[0].created_at.substring(0,10)+": "+git_info[0].actor.display_login+"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/"+git_info[0].payload.commits[0].sha+"' target='_blank'>"+git_info[0].payload.commits[0].sha.substring(0,10)+"</a>: "+git_info[0].payload.commits[0].message+"<br")}catch(e){}}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){console.log("testing"),e.preventDefault(),t.control()});var t={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){socket.emit("id",{id:id,type:"volume",value:t.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),t.control());try{git_info=$.ajax({type:"GET",url:"https://api.github.com/users/zoff-music/received_events",async:!1}).responseText,git_info=$.parseJSON(git_info),$("#latest-commit").html("Latest Commit: <br>"+git_info[0].created_at.substring(0,10)+": "+git_info[0].actor.display_login+"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/"+git_info[0].payload.commits[0].sha+"' target='_blank'>"+git_info[0].payload.commits[0].sha.substring(0,10)+"</a>: "+git_info[0].payload.commits[0].message+"<br")}catch(e){}}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),t.control()});var t={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){socket.emit("id",{id:id,type:"volume",value:t.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();

View File

@@ -100,7 +100,7 @@ var Admin = {
w_p = false;
adminpass = msg;
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"];
"removeplay", "skip", "shuffle", "userpass"];
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg));
@@ -120,6 +120,10 @@ var Admin = {
}
$("#password").val("");
$("#password").attr("placeholder", "Change channel password");
$(".user-password-li").removeClass("hide");
if($(".password_protected").prop("checked")) {
$(".change_user_pass").removeClass("hide");
}
//if(!Helper.mobilecheck()){
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
$(".playlist-tabs-loggedIn").removeClass("hide");
@@ -200,6 +204,18 @@ var Admin = {
}
}
if(!$(".user-password-li").hasClass("hide")) {
$(".user-password-li").addClass("hide")
}
if($(".password_protected").prop("checked")) {
$(".change_user_pass").removeClass("hide");
}
if(!$(".change_user_pass").hasClass("hide")) {
$(".change_user_pass").addClass("hide");
}
if(!Helper.contains($(".playlist-tabs-loggedIn").attr("class").split(" "), "hide")){
$(".playlist-tabs-loggedIn").addClass("hide");
$(".playlist-tabs").removeClass("hide");
@@ -224,8 +240,8 @@ var Admin = {
},
//function used in html onlick
save: function(){
Admin.submitAdmin(document.getElementById("adminForm").elements);
save: function(userpass){
Admin.submitAdmin(document.getElementById("adminForm").elements, userpass);
},
set_conf: function(conf_array)
@@ -233,7 +249,7 @@ var Admin = {
music = conf_array.allvideos;
longsongs = conf_array.longsongs;
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"];
"removeplay", "skip", "shuffle", "userpass"];
if(conf_array.adminpass === "" || !w_p){
@@ -259,6 +275,14 @@ var Admin = {
$(".playlist-tabs").addClass("hide");
}
$("#password").attr("placeholder", "Create channel password");
} else {
if($(".password_protected").prop("checked")) {
$(".change_user_pass").removeClass("hide");
}
}
if(!$(".password_protected").prop("checked") && !$(".change_user_pass").hasClass("hide")) {
$(".change_user_pass").addClass("hide");
}
if(conf_array.thumbnail != undefined && conf_array.thumbnail != ""){
@@ -275,7 +299,7 @@ var Admin = {
}*/
},
submitAdmin: function(form)
submitAdmin: function(form, userpass_changed)
{
voting = form.vote.checked;
addsongs = form.addsongs.checked;
@@ -286,9 +310,10 @@ var Admin = {
skipping = form.skip.checked;
shuffling = form.shuffle.checked;
configs = {
voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling
voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: CryptoJS.SHA256(userpass).toString(), userpass_changed: userpass_changed
};
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
socket.emit("conf", configs);
},

View File

@@ -1,6 +1,7 @@
var Crypt = {
conf_pass: undefined,
user_pass: undefined,
init: function(){
@@ -13,7 +14,7 @@ var Crypt = {
}
try{
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
}catch(err){
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
}
@@ -150,6 +151,16 @@ var Crypt = {
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
},
set_userpass: function(chan, pass) {
Crypt.conf_pass.passwords["userpass"] = pass;
Crypt.encrypt(Crypt.conf_pass, chan);
},
remove_userpass:function(chan){
delete Crypt.conf_pass.passwords["userpass"];
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
},
set_name:function(name){
conf_arr.name = encodeURIComponent(name).replace(/\W/g, '');
Crypt.encrypt(conf_arr, "_opt");
@@ -170,6 +181,11 @@ var Crypt = {
return undefined;
},
get_userpass: function(chan) {
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords["userpass"];
return "";
},
set_remote: function(val){
conf_arr.remote = val;
Crypt.encrypt(conf_arr, "_opt");

View File

@@ -43,7 +43,7 @@ $(document).ready(function(){
socket = io.connect(''+add+':8080', connection_options);
socket.on("get_list", function(){
setTimeout(function(){socket.emit('list', chan.toLowerCase());},1000);
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: Crypt.get_userpass(chan.toLowerCase())});},1000);
});
socket.on("viewers", function(view)

View File

@@ -427,8 +427,8 @@ function initfp(){
if(window.location.hostname == "zoff.me") add = "https://zoff.me";
else add = window.location.hostname;
if(socket === undefined || Helper.mobilecheck()) socket = io.connect(''+add+':8080', connection_options);
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists){
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) socket = io.connect(''+add+':8080', connection_options);
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
setup_playlist_listener();
}

View File

@@ -42,7 +42,7 @@ var Hostcontroller = {
w_p = true;
var add = "";
if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", add + chan.toLowerCase());
socket.emit("list", {channel: add + chan.toLowerCase(), pass: 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()});

View File

@@ -10,6 +10,10 @@ var List = {
channel_function: function(msg)
{
if(user_auth_started) {
user_auth_started = false;
$("#user_password").modal("close");
}
switch(msg.type)
{
case "list":

View File

@@ -15,7 +15,11 @@ var adminpass = "";
var filesadded = "";
var player_ready = false;
var viewers = 1;
var temp_user_pass = "";
var dragging = false;
var user_auth_started = false;
var user_auth_avoid = false;
var user_change_password = false;
var paused = false;
var currently_showing_channels = 1;
var playing = false;
@@ -23,6 +27,7 @@ var SAMPLE_RATE = 6000; // 6 seconds
var lastSample = Date.now();
var fireplace_initiated = false;
var began = false;
var userpass = "";
var i = -1;
var lazy_load = false;
var embed = false;
@@ -177,6 +182,9 @@ function init(){
$("#help").modal();
$("#contact").modal();
$("#embed").modal();
$("#user_password").modal({
dismissible: false
});
spotify_is_authenticated(spotify_authenticated);
@@ -206,7 +214,9 @@ function init(){
socket = io.connect(''+add+':8080', connection_options);
}
Crypt.init();
Crypt.init();
setup_auth_listener();
if(Crypt.get_offline()){
$(".offline_switch_class")[0].checked = true;
change_offline(true, offline);
@@ -238,7 +248,7 @@ function init(){
if(no_socket){
var add = "";
if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", add + chan.toLowerCase());
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}
$("#viewers").tooltip({
delay: 5,
@@ -473,6 +483,23 @@ function chromecastListener(evt, data){
}
}
function setup_auth_listener() {
socket.on('auth_required', function() {
user_auth_started = true;
$("#player_overlay").removeClass("hide");
$("#player_overlay").css("display", "block");
$("#user_password").modal("open");
Crypt.remove_userpass(chan.toLowerCase());
});
socket.on('auth_accepted', function(msg) {
if(msg.hasOwnProperty("value") && msg.value) {
userpass = temp_user_pass;
Crypt.set_userpass(chan.toLowerCase(), userpass);
}
});
}
function setup_no_connection_listener(){
socket.on('connect_failed', function(){
Helper.log('Connection Failed');
@@ -499,7 +526,7 @@ function get_list_listener(){
socket.on("get_list", function(){
var add = "";
if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", add + chan.toLowerCase());
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
});
}
@@ -694,7 +721,7 @@ function change_offline(enabled, already_offline){
socket.emit("pos");
var add = "";
if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", add + chan.toLowerCase());
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
if($("#controls").hasClass("ewresize")) $("#controls").removeClass("ewresize");
}
}
@@ -724,7 +751,6 @@ window.disable_debug = disable_debug;
function seekToMove(e){
//if(!Helper.mobilecheck()) {
console.log("hello");
var pos_x = e.clientX - Math.ceil($("#seekToDuration").width() / 2) - 8;
if(pos_x < 0) pos_x = 0;
else if(pos_x + $("#seekToDuration").width() > $("#controls").width()) {
@@ -951,9 +977,84 @@ $(document).on("click", ".modal-close", function(e){
e.preventDefault();
});
$(document).on("change", ".password_protected", function(e) {
e.preventDefault();
if(this.checked) {
//alert("kwek");
$("#user_password").modal('open');
$("#user-pass-input").focus();
} else {
userpass = "";
if(!$(".change_user_pass").hasClass("hide")) $(".change_user_pass").addClass("hide");
Admin.save(false);
}
});
$(document).on("submit", "#user-password-channel-form", function(e) {
e.preventDefault();
if(user_auth_started) {
//user_auth_started = false;
//$("#user_password").modal('close');
temp_user_pass = CryptoJS.SHA256($("#user-pass-input").val()).toString();
$("#user-pass-input").val("");
socket.emit("list", {channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
} else {
$("#user_password").modal('close');
userpass = $("#user-pass-input").val();
user_change_password = false;
$("#user-pass-input").val("");
Admin.save(true);
}
});
$(document).on("click", ".change_user_pass_btn", function(e) {
e.preventDefault();
user_change_password = true;
$("#user_password").modal('open');
$("#user-pass-input").focus();
});
$(document).on("click", ".submit-user-password", function(e) {
e.preventDefault();
if(user_auth_started) {
//user_auth_started = false;
//$("#user_password").modal('close');
temp_user_pass = CryptoJS.SHA256($("#user-pass-input").val()).toString();
$("#user-pass-input").val("");
socket.emit("list", {channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
} else {
$("#user_password").modal('close');
userpass = $("#user-pass-input").val();
user_change_password = false;
$("#user-pass-input").val("");
Admin.save(true);
}
});
$(document).on("click", ".close-user-password", function() {
if(user_auth_started) {
Player.stopInterval = true;
user_auth_avoid = true;
$('.castButton-active').tooltip("remove");
$("#viewers").tooltip("remove");
$('.castButton-unactive').tooltip("remove");
$("#offline-mode").tooltip("remove");
$('#chan_thumbnail').tooltip("remove");
$('#admin-lock').tooltip("remove");
window.history.pushState("to the frontpage!", "Title", "/");
onepage_load();
} else {
$("#user-pass-input").val("");
if(!user_change_password) {
$(".password_protected").prop("checked", false);
}
user_change_password = false;
}
});
$(document).on("click", ".not-exported-container .not-exported-element #extra-export-container-text .extra-add-text", function(){
this.select();
})
});
$(document).on("click", ".next_page", function(e){
e.preventDefault();
@@ -1029,16 +1130,14 @@ $(document).on("submit", ".channel-finder", function(e){
$(document).off("keyup", "keyup.autocomplete", function(e){
if(e.keyCode == 13){
e.preventDefault();
console.log(e.keyCode);
console.log($(this).val());
}
});
$(document).off("keydown", "keydown.autocomplete", function(e){
if(e.keyCode == 13){
e.preventDefault();
console.log(e.keyCode);
console.log($(this).val());
}
});*/
@@ -1063,7 +1162,7 @@ $(document).on("change", 'input[class=offline_switch_class]', function()
$(document).on("change", 'input[class=conf]', function()
{
Admin.save();
Admin.save(false);
});
$("#clickme").click(function(){
@@ -1586,8 +1685,9 @@ function onepage_load(){
var add = "";
w_p = true;
if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", add + chan.toLowerCase());
socket.emit("list", {channel: add + chan.toLowerCase(), pass: Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}else if(url_split[3] === ""){
user_change_password = false;
clearTimeout(width_timeout);
if(fireplace_initiated){
fireplace_initiated = false;
@@ -1616,7 +1716,7 @@ function onepage_load(){
url: "/",
success: function(e){
if(Helper.mobilecheck()) {
if(Helper.mobilecheck() || user_auth_avoid) {
Helper.log("Removing all listeners");
socket.removeAllListeners();
socket.disconnect();
@@ -1634,14 +1734,14 @@ function onepage_load(){
document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
if(Helper.mobilecheck()) {
if(Helper.mobilecheck() || user_auth_avoid) {
video_id = "";
song_title = "";
}
$("meta[name=theme-color]").attr("content", "#2D2D2D");
if(!Helper.mobilecheck()){
if(!Helper.mobilecheck() && !user_auth_avoid){
$(".video-container").resizable("destroy");
$("main").append("<a id='closePlayer' title='Close Player'>X</a>");
$("#playbar").remove();
@@ -1673,7 +1773,7 @@ function onepage_load(){
$("header").html($(response.find("header")).html());
$($(response.find(".section.mega"))).insertAfter("header");
$($(response.find(".section.mobile-search"))).insertAfter(".mega");
if(Helper.mobilecheck()) $("main").html($(response.find("main")).html());
if(Helper.mobilecheck() || user_auth_avoid) $("main").html($(response.find("main")).html());
else $("main").append($(response.find("#main_section_frontpage")).wrap("<div>").parent().html());
$(".page-footer").removeClass("padding-bottom-extra");
$(".page-footer").removeClass("padding-bottom-novideo");
@@ -1688,11 +1788,13 @@ function onepage_load(){
initfp();
}
if($("#alreadychannel").length === 0){
if($("#alreadychannel").length === 0 && !user_auth_avoid){
$("head").append("<div id='alreadychannel'></div");
}
} else if(user_auth_avoid) {
$("#alreadychannel").remove();
}
$("#channel-load").css("display", "none");
user_auth_avoid = false;
}
});
}

View File

@@ -307,29 +307,32 @@ var Player = {
errorHandler: function(newState)
{
if(newState.data == 5 || newState.data == 100 ||
newState.data == 101 || newState.data == 150)
{
/*if(Player.count == 2){
Player.count = 0;*/
/*Helper.log("Before: " + Player.before_load);
Helper.log("Now: " + video_id);
Helper.log("After: " + Player.after_load);
Helper.log(Player.before_load == Player.player.getVideoUrl);*/
curr_playing = Player.player.getVideoUrl().replace("https://www.youtube.com/watch?v=", "");
if(!user_auth_started) {
if(newState.data == 5 || newState.data == 100 ||
newState.data == 101 || newState.data == 150)
{
/*if(Player.count == 2){
Player.count = 0;*/
/*Helper.log("Before: " + Player.before_load);
Helper.log("Now: " + video_id);
Helper.log("After: " + Player.after_load);
Helper.log(Player.before_load == Player.player.getVideoUrl);*/
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});
//Helper.log(video_id, Player.player.getVideoUrl(), Player.player.getPlayerState());
socket.emit("skip", {error: newState.data, id: video_id, pass: adminpass, channel: chan.toLowerCase});
//Helper.log(video_id, Player.player.getVideoUrl(), Player.player.getPlayerState());
/*}else{
setTimeout(function(){
Player.loadVideoById(video_id);
Player.count ++;
}, Math.floor((Math.random() * 100) + 1));
}*/
}else if(video_id !== undefined)
Player.loadVideoById(video_id);
/*}else{
setTimeout(function(){
Player.loadVideoById(video_id);
Player.count ++;
}, Math.floor((Math.random() * 100) + 1));
}*/
}else if(video_id !== undefined) {
Player.loadVideoById(video_id);
}
}
},
onPlayerReady: function(event) {
@@ -477,8 +480,9 @@ var Player = {
/*try{
//duration = Player.player.getDuration();
}catch(e){};*/
if(duration !== undefined){
try{
try{
if(!user_auth_avoid && duration !== undefined){
if(!Player.stopInterval) durationBegun = true;
dMinutes = Math.floor(duration / 60);
dSeconds = duration - dMinutes * 60;
@@ -495,9 +499,10 @@ var Player = {
per = 0;
if(!dragging) $("#bar").width(per+"%");
}catch(e){
}
}catch(e){
}
if(!Player.stopInterval) setTimeout(Player.durationSetter, 1000);
},

View File

@@ -60,7 +60,6 @@ $(document).on("click", "#skipbutton", function()
$(document).on("submit", "#remoteform", function(e)
{
console.log("testing");
e.preventDefault();
/*
if(start)

View File

@@ -89,6 +89,21 @@
</div>
</nav>
</div>
<div id="user_password" class="modal">
<div class="modal-content">
<h5>Locked Channel</h5>
<form id="user-password-channel-form">
<div class="input-field">
<input id="user-pass-input" name="user-pass" type="password" autocomplete="off" />
<label for="user-pass-input" class="noselect">Password</label>
</div>
</form>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat close-user-password">Close</a>
<a href="#!" class="waves-effect waves-green btn-flat submit-user-password">Submit</a>
</div>
</div>
<div id="help" class="modal modal-fixed-footer">
<div class="modal-content">
<h4>Help</h4>

View File

@@ -91,6 +91,18 @@
<input name="removeplay" type="checkbox" class="conf" /><span class="lever"></span>
<span class="right-span">Remove</span>
</label></div></li>
<li class="user-password-li hide"><span class="switch-text">
User password
</span>
<div class="switch"><label>
<span class="left-span">No</span>
<input name="userpass" type="checkbox" class="conf password_protected" /><span class="lever"></span>
<span class="right-span">Yes</span>
</label></div></li>
<li class="change_user_pass hide">
<a href="#!" class="change_user_pass_btn btn waves-effect">Change password</a>
</li>
</ul>
</form>
</div>

View File

@@ -351,34 +351,45 @@ io.on('connection', function(socket){
io.to(arr.id).emit(arr.id, {type: arr.type, value: arr.value});
});
socket.on('list', function(list)
socket.on('list', function(msg)
{
if(typeof(list) === 'string' && list !== undefined && list !== null && list !== "")
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel"))
{
in_list = true;
coll = emojiStrip(list).toLowerCase();
//coll = decodeURIComponent(coll);
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = filter.clean(coll);
socket.join(coll);
socket.join(short_id);
socket.emit("id", short_id);
check_inlist(coll, guid, socket, name, offline);
io.to(coll).emit("viewers", lists[coll] == undefined ? 0 : lists[coll].length);
db.getCollectionNames(function(err, docs){
if(contains(docs, coll))
{
send_list(coll, socket, true, false, true);
}else{
db.createCollection(coll, function(err, docs){
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs){
var list = msg.channel;
var pass = decrypt_string(socketid, msg.pass);
db.collection(list).find({views: {$exists: true}}, function(err, docs) {
if(docs.length == 0 || docs[0].userpass == "" || docs[0].userpass == undefined || docs[0].userpass == pass) {
if(docs[0].userpass != "" && docs[0].userpass == pass) {
socket.emit("auth_accepted", {value: true});
}
in_list = true;
coll = emojiStrip(list).toLowerCase();
//coll = decodeURIComponent(coll);
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = filter.clean(coll);
socket.join(coll);
socket.join(short_id);
socket.emit("id", short_id);
check_inlist(coll, guid, socket, name, offline);
io.to(coll).emit("viewers", lists[coll] == undefined ? 0 : lists[coll].length);
db.getCollectionNames(function(err, docs){
if(contains(docs, coll))
{
send_list(coll, socket, true, false, true);
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": get_time()});
});
}else{
db.createCollection(coll, function(err, docs){
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs){
send_list(coll, socket, true, false, true);
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": get_time()});
});
});
}
});
}
});
} else {
socket.emit("auth_required");
}
})
}
});
@@ -703,6 +714,12 @@ io.on('connection', function(socket){
var adminpass = params.adminpass;
var skipping = params.skipping;
var shuffling = params.shuffling;
var userpass = params.userpass;
if(!params.userpass_changed && frontpage) {
userpass = "";
} else if(params.userpass_changed && userpass != "") {
frontpage = false;
}
var description = "";
var hash;
if(params.description) description = params.description;
@@ -725,10 +742,13 @@ io.on('connection', function(socket){
shuffle:shuffling,
longsongs:longsongs,
adminpass:hash,
desc: description
desc: description,
userpass: userpass,
}}, function(err, docs){
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
if(docs[0].adminpass !== "") docs[0].adminpass = true;
if(docs[0].hasOwnProperty("userpass") && docs[0].userpass != "") docs[0].userpass = true;
else docs[0].userpass = false;
io.to(coll).emit("conf", docs);
socket.emit("toast", "savedsettings");
@@ -1160,6 +1180,8 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
if(configs)
{
if(conf[0].adminpass !== "") conf[0].adminpass = true;
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
else conf[0].userpass = false;
io.to(coll).emit("conf", conf);
}
});
@@ -1182,6 +1204,8 @@ function send_play(coll, socket)
}else if(conf !== null && conf !== undefined && conf.length !== 0)
{
if(conf[0].adminpass !== "") conf[0].adminpass = true;
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
else conf[0].userpass = false;
toSend = {np: np, conf: conf, time: get_time()};
if(socket === undefined)
io.to(coll).emit("np", toSend);