This commit is contained in:
Kasper Rynning-Tønnesen
2015-11-26 12:12:56 +01:00
828 changed files with 124396 additions and 675 deletions

View File

@@ -1,7 +1,10 @@
var Admin = {
beginning:true,
admin_listener: function()
{
socket.on("toast", function(msg)
{
switch(msg) {
@@ -13,9 +16,7 @@ var Admin = {
break;
case "wrongpass":
msg=Helper.rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."])
if(localStorage[chan.toLowerCase()]){
localStorage.removeItem(chan.toLowerCase());
}
Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
w_p = true;
break;
@@ -64,7 +65,7 @@ var Admin = {
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"];
localStorage.setItem(chan.toLowerCase(), msg);
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg))
for (var i = 0; i < names.length; i++) {
$("input[name="+names[i]+"]").attr("disabled", false);
@@ -81,21 +82,30 @@ var Admin = {
socket.on("conf", function(msg)
{
Crypt.init();
Admin.set_conf(msg[0]);
if(Crypt.get_pass(chan.toLowerCase()) !== undefined && Admin.beginning && Crypt.get_pass(chan.toLowerCase()) != ""){
socket.emit("password", [Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), chan.toLowerCase()]);
Admin.beginning = false;
}
});
},
pass_save: function()
{
if(!w_p)
socket.emit('password', [CryptoJS.SHA256(document.getElementById("password").value).toString(), chan.toLowerCase(), localStorage[chan.toLowerCase()]]);
{
socket.emit('password', [Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), chan.toLowerCase(), Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))]);
}
else
socket.emit('password', [CryptoJS.SHA256(document.getElementById("password").value).toString(), chan.toLowerCase()]);
{
socket.emit('password', [Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), chan.toLowerCase()]);
}
},
log_out: function(){
if(localStorage[chan.toLowerCase()]){
localStorage.removeItem(chan.toLowerCase());
if(Crypt.get_pass(chan.toLowerCase())){
Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
Materialize.toast("Logged out", 4000);
}else{
@@ -151,9 +161,9 @@ var Admin = {
$("input[name="+names[i]+"]").attr("disabled", hasadmin);
}
if((hasadmin && !localStorage[chan.toLowerCase()])){
if((hasadmin)){
Admin.display_logged_out();
}else if(!hasadmin && !localStorage[chan.toLowerCase()]){
}else if(!hasadmin && Crypt.get_pass(chan.toLowerCase()) === undefined){
$("#password").attr("placeholder", "Create channel password");
}

141
static/js/crypt.js Normal file
View File

@@ -0,0 +1,141 @@
var Crypt = {
conf_arr: {},
init: function(){
try{
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
}catch(err){
console.log("err")
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
}
Hostcontroller.change_enabled(conf_arr.remote);
},
decrypt: function(cookie, name){
if(Crypt.getCookie(name) === undefined) {
cookie = Crypt.create_cookie(name);
}
var decrypted = CryptoJS.AES.decrypt(
cookie,navigator.userAgent+navigator.languages,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
},
decrypt_pass: function(pass){
var decrypted = CryptoJS.AES.decrypt(
pass,socket.io.engine.id,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
return decrypted.toString(CryptoJS.enc.Utf8);
},
encrypt: function(json_formated, cookie){
var to_encrypt = JSON.stringify(json_formated);
var encrypted = CryptoJS.AES.encrypt(
to_encrypt,
navigator.userAgent+navigator.languages,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
var CookieDate = new Date;
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
if(cookie != "_opt") add = chan.toLowerCase()+";";
else add = ";"
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/"+add
},
get_volume: function(){
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").volume;
//return conf_arr.volume;
},
set_volume: function(val){
conf_arr.volume = val;
Crypt.encrypt(conf_arr, "_opt");
},
create_cookie: function(name){
if(name == "_opt") cookie_object = {volume: 100, width: 100, remote: true};
else cookie_object = {passwords: {}};
var string_it = JSON.stringify(cookie_object);
var encrypted = CryptoJS.AES.encrypt(
string_it,
navigator.userAgent+navigator.languages,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
var CookieDate = new Date;
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
if(name != "_opt") add = chan.toLowerCase();
else add = ";"
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/"+add
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
return Crypt.getCookie(name);
},
set_pass: function(chan, pass){
conf_pass.passwords[chan] = pass;
Crypt.encrypt(conf_pass, chan);
},
remove_pass:function(chan){
delete conf_pass.passwords[chan];
Crypt.encrypt(conf_pass, chan.toLowerCase());
},
get_pass: function(chan){
return conf_pass.passwords[chan];
},
set_remote: function(val){
conf_arr.remote = val;
Crypt.encrypt(conf_arr, "_opt");
},
get_remote: function(val){
return conf_arr.remote;
},
crypt_pass: function(pass){
var encrypted = CryptoJS.AES.encrypt(
pass,
socket.io.engine.id,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
return encrypted.toString();
},
getCookie: function(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
}

View File

@@ -1,5 +1,7 @@
var Hostcontroller = {
enabled: true,
host_listener: function() {
var old_id;
@@ -22,14 +24,13 @@ var Hostcontroller = {
began = true;
socket.on(id, function(arr)
{
if(arr[0] == "volume")
{
if(enabled){
if(arr[0] == "volume"){
$("#volume").slider("value", arr[1]);
ytplayer.setVolume(arr[1]);
localStorage.setItem("volume", arr[1]);
Playercontrols.choose_button(arr[1], false);
}else if(arr[0] == "channel")
{
}else if(arr[0] == "channel"){
socket.emit("change_channel");
chan = arr[1].toLowerCase();
@@ -38,8 +39,7 @@ var Hostcontroller = {
w_p = true;
socket.emit("list", chan.toLowerCase());
if(localStorage[chan.toLowerCase()])
{
if(localStorage[chan.toLowerCase()]){
//localStorage.removeItem(chan.toLowerCase());
if(localStorage[chan.toLowerCase()].length != 64)
localStorage.removeItem(chan.toLowerCase());
@@ -54,8 +54,21 @@ var Hostcontroller = {
ytplayer.playVideo();
else if(arr[0] == "skip")
List.skip();
}
});
}
});
$('input[class=remote_switch_class]').change(function()
{
enabled = document.getElementsByName("remote_switch")[0].checked;
Crypt.set_remote(enabled);
});
},
change_enabled:function(val){
enabled = val;
document.getElementsByName("remote_switch")[0].checked = enabled;
}
}

View File

@@ -68,18 +68,24 @@ var List = {
},
deleted_song: function(deleted){
var index = List.getIndexOfSong(deleted);
var to_delete = $("#wrapper").children()[index];
to_delete.style.height = 0;
try{
to_delete.style.height = 0;
setTimeout(function()
{
$("#"+deleted).remove();
setTimeout(function()
{
$("#"+deleted).remove();
full_playlist.splice(List.getIndexOfSong(deleted), 1);
}, 305);
document.getElementById('wrapper').scrollTop += 1;
document.getElementById('wrapper').scrollTop += -1;
}catch(err){
full_playlist.splice(List.getIndexOfSong(deleted), 1);
}, 305);
document.getElementById('wrapper').scrollTop += 1;
document.getElementById('wrapper').scrollTop += -1;
$("#wrapper").children()[$("#wrapper").children().length-1].remove();
}
},
voted_song: function(voted, time){
@@ -117,7 +123,7 @@ var List = {
},
skip: function(){
socket.emit('skip', [chan, localStorage[chan.toLowerCase()]]);
socket.emit('skip', [chan, adminpass]);
return true;
},

View File

@@ -43,7 +43,9 @@ var connection_options = {
'sync disconnect on unload':true
};
var socket = io.connect('http://'+window.location.hostname+':8880', connection_options);
if(window.location.hostname == "zoff.no") add = "dev.zoff.no";
else add = "localhost";
var socket = io.connect('http://'+add+':8880', connection_options);
socket.on("get_list", function(){
socket.emit('list', chan.toLowerCase());
});
@@ -71,17 +73,23 @@ $(document).ready(function()
});
//awdwad
$(".video-container").resizable({
start: function(event, ui) {
$('iframe').css('pointer-events','none');
},
stop: function(event, ui) {
$('iframe').css('pointer-events','auto');
},
handles: "e",
minWidth: 350
});
/*
if(localStorage[chan.toLowerCase()])
{
if(localStorage[chan.toLowerCase()].length != 64)
localStorage.removeItem(chan.toLowerCase());
else
socket.emit("password", [localStorage[chan.toLowerCase()], chan.toLowerCase()]);
}
}*/
if(window.mobilecheck()){
document.getElementById("search").blur();

View File

@@ -22,8 +22,14 @@ var Nochan = {
{
var output = "";
var num = 0;
var pinned;
if(lists[0][5] == 1){
pinned = lists.shift();
}
lists.sort(Nochan.sortFunction);
if(pinned !== undefined){
lists.unshift(pinned);
}
pre_card = $(list_html);
Nochan.add_backdrop(lists, 0);
@@ -42,6 +48,17 @@ var Nochan = {
//$("#channels").append(list_html);
var card = pre_card;
if(lists[x][5] == 1)
{
card.find(".pin").attr("style", "display:block;");
card.find(".card").attr("title", "Pinned!");
}
else
{
card.find(".pin").attr("style", "display:none;");
card.find(".card").attr("title", "");
}
card.find(".chan-name").text(chan);
card.find(".chan-name").attr("title", chan);
card.find(".chan-views").text(viewers);
@@ -158,7 +175,9 @@ $(document).ready(function (){
socket.emit('frontpage_lists');
socket.on('playlists', function(msg){
Nochan.populate_channels(msg);
})
});
window.socket = socket;
var pad = 0;
document.getElementById("zicon").addEventListener("click", function(){

View File

@@ -17,10 +17,12 @@ var Playercontrols = {
{
if(localStorage.volume)
{
vol = localStorage.getItem("volume");
//vol = localStorage.getItem("volume");
vol = (Crypt.get_volume());
}else{
vol = 100;
localStorage.setItem("volume", vol);
//localStorage.setItem("volume", vol);
Crypt.set_volume(vol);
}
$("#volume").slider({
min: 0,
@@ -29,11 +31,13 @@ var Playercontrols = {
range: "min",
animate: true,
slide: function(event, ui) {
Playercontrols.setVolume(ui.value);
localStorage.setItem("volume", ui.value);
Playercontrols.setVolume(ui.value);
//localStorage.setItem("volume", ui.value);
Crypt.set_volume(ui.value);
}
});
Playercontrols.choose_button(vol, false);
Playercontrols.choose_button(vol, false);
//$("#volume").slider("value", ytplayer.getVolume());
},
@@ -88,13 +92,13 @@ var Playercontrols = {
setVolume: function(vol)
{
ytplayer.setVolume(vol);
Playercontrols.choose_button(vol, false);
Playercontrols.choose_button(vol, false);
if(ytplayer.isMuted())
ytplayer.unMute();
},
choose_button: function(vol, mute)
{
{
if(!mute){
if(vol >= 0 && vol <= 33){
if(document.getElementById("v-full").className.split(" ").length == 1)

View File

@@ -130,7 +130,7 @@ var Youtube = {
Youtube.readyLooks();
Playercontrols.initYoutubeControls(ytplayer);
Playercontrols.initSlider();
ytplayer.setVolume(localStorage.getItem("volume"));
ytplayer.setVolume(Crypt.get_volume());
},
readyLooks: function()