More indentation

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-22 11:45:54 +02:00
parent 68d243c93a
commit 9372bf3bf0
14 changed files with 2241 additions and 2265 deletions

View File

@@ -1,40 +1,40 @@
window.addEventListener("load", function() {
var query = getQueryHash(window.location.hash);
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
var client_id;
var response;
var scope;
var query = getQueryHash(window.location.hash);
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
var client_id;
var response;
var scope;
if(query.spotify) {
client_id = "b934ecdd173648f5bcd38738af529d58";
response = "token";
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
state = query.nonce;
window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
if(query.spotify) {
client_id = "b934ecdd173648f5bcd38738af529d58";
response = "token";
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
state = query.nonce;
window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
} else if (query.youtube) {
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
response = "token";
scope = "https://www.googleapis.com/auth/youtube";
state = query.nonce;
} else if (query.youtube) {
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
response = "token";
scope = "https://www.googleapis.com/auth/youtube";
state = query.nonce;
//window.opener.callback(query);
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
} else {
var query_parameters = getQueryHash(window.location.hash);
window.opener.callback(query_parameters);
}
//window.opener.callback(query);
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
} else {
var query_parameters = getQueryHash(window.location.hash);
window.opener.callback(query_parameters);
}
});
function getQueryHash(url) {
var temp_arr = url.substring(1).split("&");
var done_obj = {};
var splitted;
for(var i in temp_arr) {
splitted = temp_arr[i].split("=");
if(splitted.length == 2) {
done_obj[splitted[0]] = splitted[1];
}
}
return done_obj;
var temp_arr = url.substring(1).split("&");
var done_obj = {};
var splitted;
for(var i in temp_arr) {
splitted = temp_arr[i].split("=");
if(splitted.length == 2) {
done_obj[splitted[0]] = splitted[1];
}
}
return done_obj;
}

View File

@@ -1,149 +1,149 @@
var Chat = {
channel_received: 0,
all_received: 0,
chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "There are no commands.. As of now!"],
channel_received: 0,
all_received: 0,
chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "There are no commands.. As of now!"],
namechange: function(newName) {
socket.emit("namechange", {name: newName, channel: chan.toLowerCase()});
Crypt.set_name(newName);
},
namechange: function(newName) {
socket.emit("namechange", {name: newName, channel: chan.toLowerCase()});
Crypt.set_name(newName);
},
removename: function() {
socket.emit("removename");
Crypt.remove_name();
},
removename: function() {
socket.emit("removename");
Crypt.remove_name();
},
chat: function(data) {
if(data.value.length > 150)
return;
/*if(data.value.startsWith("/name ")){
Chat.namechange(data.value.substring(6));
} else */
if(data.value.startsWith("/help")) {
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
if($("#chatall").children().length > 100) {
$("#chatall").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++) {
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='Zoff''><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
}
} else {
if($("#chatchannel").children().length > 100) {
$("#chatchannel").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++) {
chat: function(data) {
if(data.value.length > 150)
return;
/*if(data.value.startsWith("/name ")){
Chat.namechange(data.value.substring(6));
} else */
if(data.value.startsWith("/help")) {
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
if($("#chatall").children().length > 100) {
$("#chatall").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++) {
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='Zoff''><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
}
} else {
if($("#chatchannel").children().length > 100) {
$("#chatchannel").children()[0].remove()
}
for(var x = 0; x < Chat.chat_help.length; x++) {
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
}
}
} else if(data.value.startsWith("/removename")) {
Chat.removename();
} else if($(".chat-tab-li a.active").attr("href") == "#all_chat") {
socket.emit("all,chat", {channel: chan.toLowerCase(), data: data.value});
} else {
socket.emit("chat", {channel: chan.toLowerCase(), data: data.value, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}
data.value = "";
return;
},
var color = Helper.intToARGB(Helper.hashCode("System"));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
var in_text = document.createTextNode(Chat.chat_help[x]);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
}
}
} else if(data.value.startsWith("/removename")) {
Chat.removename();
} else if($(".chat-tab-li a.active").attr("href") == "#all_chat") {
socket.emit("all,chat", {channel: chan.toLowerCase(), data: data.value});
} else {
socket.emit("chat", {channel: chan.toLowerCase(), data: data.value, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
}
data.value = "";
return;
},
allchat: function(inp) {
if(inp.msg.substring(0,1) == ":" && !chat_active) {
Chat.all_received += 1;
$("#favicon").attr("href", "/assets/images/highlogo.png");
unseen = true;
chat_unseen = true;
if($(".chat-link span.badge.new.white").hasClass("hide")){
$(".chat-link span.badge.new.white").removeClass("hide");
}
var to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
$(".chat-link span.badge.new.white").html(to_display);
}
allchat: function(inp) {
if(inp.msg.substring(0,1) == ":" && !chat_active) {
Chat.all_received += 1;
$("#favicon").attr("href", "/assets/images/highlogo.png");
unseen = true;
chat_unseen = true;
if($(".chat-link span.badge.new.white").hasClass("hide")){
$(".chat-link span.badge.new.white").removeClass("hide");
}
var to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
$(".chat-link span.badge.new.white").html(to_display);
}
if(document.hidden) {
$("#favicon").attr("href", "/assets/images/highlogo.png");
}
if(document.hidden) {
$("#favicon").attr("href", "/assets/images/highlogo.png");
}
if($("#chatall").children().length > 100) {
$("#chatall").children()[0].remove()
}
var color = Helper.intToARGB(Helper.hashCode(inp.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='"+inp.channel+"''><span style='color:"+color_temp+";'>"+inp.from+"</span></li>");
var in_text = document.createTextNode(inp.msg);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
},
if($("#chatall").children().length > 100) {
$("#chatall").children()[0].remove()
}
var color = Helper.intToARGB(Helper.hashCode(inp.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='"+inp.channel+"''><span style='color:"+color_temp+";'>"+inp.from+"</span></li>");
var in_text = document.createTextNode(inp.msg);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
},
channelchat: function(data) {
if(data.msg.substring(0,1) == ":" && !chat_active) {
$("#favicon").attr("href", "/assets/images/highlogo.png");
unseen = true;
chat_unseen = true;
Chat.channel_received += 1;
//blink_interval = setTimeout(Chat.chat_blink, 1000);
if($(".chat-link span.badge.new.white").hasClass("hide")) {
$(".chat-link span.badge.new.white").removeClass("hide");
}
var to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
$(".chat-link span.badge.new.white").html(to_display);
}
channelchat: function(data) {
if(data.msg.substring(0,1) == ":" && !chat_active) {
$("#favicon").attr("href", "/assets/images/highlogo.png");
unseen = true;
chat_unseen = true;
Chat.channel_received += 1;
//blink_interval = setTimeout(Chat.chat_blink, 1000);
if($(".chat-link span.badge.new.white").hasClass("hide")) {
$(".chat-link span.badge.new.white").removeClass("hide");
}
var to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
$(".chat-link span.badge.new.white").html(to_display);
}
if($("#chatchannel").children().length > 100) {
$("#chatchannel").children()[0].remove()
}
if($("#chatchannel").children().length > 100) {
$("#chatchannel").children()[0].remove()
}
var color = Helper.intToARGB(Helper.hashCode(data.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data.from+"</span></li>");
var in_text = document.createTextNode(data.msg);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
},
var color = Helper.intToARGB(Helper.hashCode(data.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++) {
color = "0" + color;
}
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data.from+"</span></li>");
var in_text = document.createTextNode(data.msg);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
},
chat_blink: function() {
blinking = true;
$(".chat-link").attr("style", "color: grey !important;");
setTimeout(function () {
$(".chat-link").attr("style", "color: white !important;");
setTimeout(function() {
if(blinking) Chat.chat_blink();
}, 1000);
}, 1000);
}
chat_blink: function() {
blinking = true;
$(".chat-link").attr("style", "color: grey !important;");
setTimeout(function () {
$(".chat-link").attr("style", "color: white !important;");
setTimeout(function() {
if(blinking) Chat.chat_blink();
}, 1000);
}, 1000);
}
};

View File

@@ -1,238 +1,238 @@
var Crypt = {
conf_pass: undefined,
user_pass: undefined,
tmp_pass: "",
conf_pass: undefined,
user_pass: undefined,
tmp_pass: "",
init: function() {
init: function() {
if(window.location.pathname != "/") {
if (location.protocol != "https:") {
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';expires=' + new Date(0).toUTCString();
} else {
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';secure;expires=' + new Date(0).toUTCString();
}
}
if(window.location.pathname != "/") {
if (location.protocol != "https:") {
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';expires=' + new Date(0).toUTCString();
} else {
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';secure;expires=' + new Date(0).toUTCString();
}
}
try {
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
} catch(err) {
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
}
try {
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
} catch(err) {
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
}
if(window.location.pathname != "/") {
try {
Crypt.conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
} catch(err) {
Crypt.conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
}
if(window.location.pathname != "/") {
try {
Crypt.conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
} catch(err) {
Crypt.conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
}
Hostcontroller.change_enabled(conf_arr.remote);
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
//if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
}
},
Hostcontroller.change_enabled(conf_arr.remote);
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
//if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
}
},
decrypt: function(cookie, name) {
if(Crypt.getCookie(name) === undefined) {
cookie = Crypt.create_cookie(name);
}
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var decrypted = CryptoJS.AES.decrypt(
cookie,key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
decrypt: function(cookie, name) {
if(Crypt.getCookie(name) === undefined) {
cookie = Crypt.create_cookie(name);
}
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var decrypted = CryptoJS.AES.decrypt(
cookie,key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
},
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
},
decrypt_pass: function(pass) {
var key = btoa(socket.id) + btoa(socket.id);
key = key.substring(0,32);
key = btoa(key);
var decrypted = CryptoJS.AES.decrypt(
pass,key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
return decrypted.toString(CryptoJS.enc.Utf8);
},
decrypt_pass: function(pass) {
var key = btoa(socket.id) + btoa(socket.id);
key = key.substring(0,32);
key = btoa(key);
var decrypted = CryptoJS.AES.decrypt(
pass,key,
{
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 key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var encrypted = CryptoJS.AES.encrypt(
to_encrypt,
key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
encrypt: function(json_formated, cookie) {
var to_encrypt = JSON.stringify(json_formated);
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var encrypted = CryptoJS.AES.encrypt(
to_encrypt,
key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
var CookieDate = new Date();
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
if (location.protocol != "https:"){
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
} else {
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
}
},
var CookieDate = new Date();
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
if (location.protocol != "https:"){
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
} else {
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
}
},
get_volume: function() {
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").volume;
//return conf_arr.volume;
},
get_volume: function() {
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").volume;
//return conf_arr.volume;
},
get_offline: function() {
var temp_offline = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
if(temp_offline != undefined){
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
} else {
Crypt.set_offline(false);
return false;
}
},
get_offline: function() {
var temp_offline = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
if(temp_offline != undefined){
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
} else {
Crypt.set_offline(false);
return false;
}
},
set_volume: function(val) {
conf_arr.volume = val;
Crypt.encrypt(conf_arr, "_opt");
},
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, name: "", offline: false};
else cookie_object = {passwords: {}};
create_cookie: function(name) {
if(name == "_opt") cookie_object = {volume: 100, width: 100, remote: true, name: "", offline: false};
else cookie_object = {passwords: {}};
var string_it = JSON.stringify(cookie_object);
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var encrypted = CryptoJS.AES.encrypt(
string_it,
key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
var string_it = JSON.stringify(cookie_object);
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
key = key.substring(0,32);
key = btoa(key);
var encrypted = CryptoJS.AES.encrypt(
string_it,
key,
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
);
var CookieDate = new Date();
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
var CookieDate = new Date();
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
if (location.protocol != "https:"){
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
} else {
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
}
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
return Crypt.getCookie(name);
},
if (location.protocol != "https:"){
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
} else {
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
}
//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) {
Crypt.conf_pass.passwords[chan] = pass;
Crypt.encrypt(Crypt.conf_pass, chan);
},
set_pass: function(chan, pass) {
Crypt.conf_pass.passwords[chan] = pass;
Crypt.encrypt(Crypt.conf_pass, chan);
},
remove_pass:function(chan) {
delete Crypt.conf_pass.passwords[chan];
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
},
remove_pass:function(chan) {
delete Crypt.conf_pass.passwords[chan];
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
},
set_userpass: function(chan, pass) {
Crypt.conf_pass.passwords["userpass"] = pass;
Crypt.encrypt(Crypt.conf_pass, chan);
},
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());
},
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");
},
set_name:function(name) {
conf_arr.name = encodeURIComponent(name).replace(/\W/g, '');
Crypt.encrypt(conf_arr, "_opt");
},
set_offline: function(enabled) {
conf_arr.offline = enabled;
Crypt.encrypt(conf_arr, "_opt");
},
set_offline: function(enabled) {
conf_arr.offline = enabled;
Crypt.encrypt(conf_arr, "_opt");
},
remove_name:function() {
conf_arr.name = "";
Crypt.encrypt(conf_arr, "_opt");
},
remove_name:function() {
conf_arr.name = "";
Crypt.encrypt(conf_arr, "_opt");
},
get_pass: function(chan) {
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords[chan];
return undefined;
},
get_pass: function(chan) {
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords[chan];
return undefined;
},
get_userpass: function(chan) {
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords["userpass"];
return "";
},
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");
},
set_remote: function(val) {
conf_arr.remote = val;
Crypt.encrypt(conf_arr, "_opt");
},
get_remote: function(val) {
return conf_arr.remote;
},
get_remote: function(val) {
return conf_arr.remote;
},
crypt_pass: function(pass) {
Crypt.tmp_pass = pass;
var key = btoa(socket.id) + btoa(socket.id);
key = key.substring(0,32);
key = btoa(key);
var iv = btoa(Crypt.makeiv());
var encrypted = CryptoJS.AES.encrypt(
pass,
CryptoJS.enc.Base64.parse(key),
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
iv: CryptoJS.enc.Base64.parse(iv),
}
);
window.encrypted = encrypted;
return encrypted.toString() + "$" + iv;
},
crypt_pass: function(pass) {
Crypt.tmp_pass = pass;
var key = btoa(socket.id) + btoa(socket.id);
key = key.substring(0,32);
key = btoa(key);
var iv = btoa(Crypt.makeiv());
var encrypted = CryptoJS.AES.encrypt(
pass,
CryptoJS.enc.Base64.parse(key),
{
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
iv: CryptoJS.enc.Base64.parse(iv),
}
);
window.encrypted = encrypted;
return encrypted.toString() + "$" + iv;
},
makeiv: function() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
makeiv: function() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 16; i++ )
for( var i=0; i < 16; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
},
return text;
},
get_width: function() {
return conf_arr.width;
},
get_width: function() {
return conf_arr.width;
},
set_width: function(val) {
conf_arr.width = val;
Crypt.encrypt(conf_arr, "_opt");
},
set_width: function(val) {
conf_arr.width = val;
Crypt.encrypt(conf_arr, "_opt");
},
getCookie: function(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
getCookie: function(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
};

View File

@@ -28,136 +28,136 @@ var user_auth_started = false;
var user_auth_avoid = false;
var connection_options = {
'sync disconnect on unload':true,
'secure': true,
'force new connection': true
'sync disconnect on unload':true,
'secure': true,
'force new connection': true
};
var Crypt = {
crypt_pass: function(pass) {
return pass;
}
crypt_pass: function(pass) {
return pass;
}
};
function receiveMessage(event) {
if(event.data == "parent") {
//console.log(event);
window.parentWindow = event.source;
window.parentOrigin = event.origin;
}
if(event.data == "lower") {
window.setVolume(10);
}else if(event.data == "reset") {
window.setVolume(100);
} else if(event.data == "get_info") {
window.parentWindow.postMessage({type: "np", title: song_title}, window.parentOrigin);
window.parentWindow.postMessage({type: "controller", id: Hostcontroller.old_id}, window.parentOrigin);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
}
if(event.data == "parent") {
//console.log(event);
window.parentWindow = event.source;
window.parentOrigin = event.origin;
}
if(event.data == "lower") {
window.setVolume(10);
}else if(event.data == "reset") {
window.setVolume(100);
} else if(event.data == "get_info") {
window.parentWindow.postMessage({type: "np", title: song_title}, window.parentOrigin);
window.parentWindow.postMessage({type: "controller", id: Hostcontroller.old_id}, window.parentOrigin);
if(full_playlist.length > 0) {
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
}
}
}
window.addEventListener("message", receiveMessage, false);
$(document).ready(function() {
if(hash.length >= 3 && hash[2] == "autoplay"){
autoplay = true;
} else {
paused = true;
}
if(hash.length >= 3 && hash[2] == "autoplay"){
autoplay = true;
} else {
paused = true;
}
if(hash.indexOf("videoonly") > -1) {
$("#playlist").addClass("hide");
$("#controls").addClass("hide");
$("#player").addClass("video_only");
}
if(hash.indexOf("videoonly") > -1) {
$("#playlist").addClass("hide");
$("#controls").addClass("hide");
$("#player").addClass("video_only");
}
$("#locked_channel").modal({
dismissible: false
});
color = "#" + hash[1];
add = "https://zoff.me";
socket = io.connect(''+add+':8080', connection_options);
$("#locked_channel").modal({
dismissible: false
});
color = "#" + hash[1];
add = "https://zoff.me";
socket = io.connect(''+add+':8080', connection_options);
socket.on('auth_required', function() {
$("#locked_channel").modal('open');
});
socket.on('auth_required', function() {
$("#locked_channel").modal('open');
});
socket.on("get_list", function() {
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: ''});},1000);
});
socket.on("get_list", function() {
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: ''});},1000);
});
socket.on("self_ping", function() {
if(chan != undefined && chan.toLowerCase() != "") {
socket.emit("self_ping", {channel: chan.toLowerCase()});
}
});
socket.on("self_ping", function() {
if(chan != undefined && chan.toLowerCase() != "") {
socket.emit("self_ping", {channel: chan.toLowerCase()});
}
});
socket.on("viewers", function(view) {
viewers = view;
socket.on("viewers", function(view) {
viewers = view;
if(song_title !== undefined)
Player.getTitle(song_title, viewers);
});
if(song_title !== undefined)
Player.getTitle(song_title, viewers);
});
setup_host_initialization();
setup_youtube_listener();
setup_list_listener();
setup_host_initialization();
setup_youtube_listener();
setup_list_listener();
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
Player.loadPlayer();
Player.loadPlayer();
Playercontrols.initSlider();
Playercontrols.initSlider();
window.setVolume = setVolume;
$("#controls").css("background-color", color);
$("#playlist").css("background-color", color);
if(hash.indexOf("controll") > -1) {
Hostcontroller.change_enabled(true);
} else {
Hostcontroller.change_enabled(false);
}
window.setVolume = setVolume;
$("#controls").css("background-color", color);
$("#playlist").css("background-color", color);
if(hash.indexOf("controll") > -1) {
Hostcontroller.change_enabled(true);
} else {
Hostcontroller.change_enabled(false);
}
});
function setup_host_listener(id) {
socket.on(id, Hostcontroller.host_on_action);
socket.on(id, Hostcontroller.host_on_action);
}
function setup_host_initialization() {
socket.on("id", Hostcontroller.host_listener);
socket.on("id", Hostcontroller.host_listener);
}
function setup_youtube_listener() {
socket.on("np", Player.youtube_listener);
socket.on("np", Player.youtube_listener);
}
function setup_list_listener() {
socket.on("channel", List.channel_function);
socket.on("channel", List.channel_function);
}
function setVolume(val) {
$("#volume").slider('value', val);
Playercontrols.setVolume(val);
$("#volume").slider('value', val);
Playercontrols.setVolume(val);
}
$(document).on( "click", "#zoffbutton", function(e) {
window.open("https://zoff.me/" + chan.toLowerCase() + "/", '_blank');
window.open("https://zoff.me/" + chan.toLowerCase() + "/", '_blank');
});
$(document).on( "click", ".vote-container", function(e) {
var id = $(this).attr("data-video-id");
List.vote(id, "pos");
var id = $(this).attr("data-video-id");
List.vote(id, "pos");
});
$(document).on("click", ".prev_page", function(e) {
e.preventDefault();
List.dynamicContentPage(-1);
e.preventDefault();
List.dynamicContentPage(-1);
});
$(document).on("click", ".next_page", function(e) {
e.preventDefault();
List.dynamicContentPage(1);
e.preventDefault();
List.dynamicContentPage(1);
});

View File

@@ -7,462 +7,462 @@ var rotation_timeout;
var Frontpage = {
blob_list: [],
blob_list: [],
winter: (new Date()).getMonth() >= 10 ? true : false,
winter: (new Date()).getMonth() >= 10 ? true : false,
times_rotated: 0,
times_rotated: 0,
all_channels: [],
all_channels: [],
frontpage_function: function(msg) {
frontpage = true;
frontpage_function: function(msg) {
frontpage = true;
Helper.log("-----------");
Helper.log("Frontpage fetch");
Helper.log(msg);
Helper.log("------------");
Frontpage.all_channels = msg.channels;
Frontpage.populate_channels(msg.channels, true);
Frontpage.set_viewers(msg.viewers);
},
Helper.log("-----------");
Helper.log("Frontpage fetch");
Helper.log(msg);
Helper.log("------------");
Frontpage.all_channels = msg.channels;
Frontpage.populate_channels(msg.channels, true);
Frontpage.set_viewers(msg.viewers);
},
populate_channels: function(lists, popular) {
$("#channels").empty();
populate_channels: function(lists, popular) {
$("#channels").empty();
var num = 0;
var num = 0;
if(popular) {
lists = lists.sort(Helper.predicate({
name: 'pinned',
reverse: true
}, {
name: 'viewers',
reverse: true
}, {
name: 'accessed',
reverse: true
}, {
name: 'count',
reverse: true
}));
} else {
lists = lists.sort(Helper.predicate({
name: 'viewers',
reverse: true
}, {
name: 'count',
reverse: true
}));
}
if(popular) {
lists = lists.sort(Helper.predicate({
name: 'pinned',
reverse: true
}, {
name: 'viewers',
reverse: true
}, {
name: 'accessed',
reverse: true
}, {
name: 'count',
reverse: true
}));
} else {
lists = lists.sort(Helper.predicate({
name: 'viewers',
reverse: true
}, {
name: 'count',
reverse: true
}));
}
if(!Helper.mobilecheck()) {
clearTimeout(rotation_timeout);
Frontpage.add_backdrop(lists, 0);
}
if(!Helper.mobilecheck()) {
clearTimeout(rotation_timeout);
Frontpage.add_backdrop(lists, 0);
}
pre_card = $(channel_list);
pre_card = $(channel_list);
Helper.log("------------");
Helper.log(pre_card);
Helper.log("-------------");
Helper.log("------------");
Helper.log(pre_card);
Helper.log("-------------");
for(var x in lists) {
var chan = lists[x]._id;
if(num<12 || !popular) {
var id = lists[x].id;
var viewers = lists[x].viewers;
var description = lists[x].description;
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
if(lists[x].thumbnail) {
img = "background-image:url('" + lists[x].thumbnail + "');";
}
for(var x in lists) {
var chan = lists[x]._id;
if(num<12 || !popular) {
var id = lists[x].id;
var viewers = lists[x].viewers;
var description = lists[x].description;
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
if(lists[x].thumbnail) {
img = "background-image:url('" + lists[x].thumbnail + "');";
}
var song_count = lists[x].count;
var song_count = lists[x].count;
var card = pre_card.clone();
if(lists[x].pinned == 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);
card.find(".chan-songs").text(song_count);
card.find(".chan-bg").attr("style", img);
card.find(".chan-link").attr("href", chan + "/");
var card = pre_card.clone();
if(lists[x].pinned == 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);
card.find(".chan-songs").text(song_count);
card.find(".chan-bg").attr("style", img);
card.find(".chan-link").attr("href", chan + "/");
if(description != "" && description != undefined && !Helper.mobilecheck()) {
card.find(".card-title").text(chan);
card.find(".description_text").text(description);
description = "";
} else {
card.find(".card-reveal").remove();
card.find(".card").removeClass("sticky-action")
}
if(description != "" && description != undefined && !Helper.mobilecheck()) {
card.find(".card-title").text(chan);
card.find(".description_text").text(description);
description = "";
} else {
card.find(".card-reveal").remove();
card.find(".card").removeClass("sticky-action")
}
$("#channels").append(card.html());
}
num++;
}
$("#channels").append(card.html());
}
num++;
}
var options_list = lists.slice();
var options_list = lists.slice();
options_list = options_list.sort(Frontpage.sortFunction_active);
var data = {};
for(var x in options_list) {
data[options_list[x]._id] = null;
}
options_list = options_list.sort(Frontpage.sortFunction_active);
var data = {};
for(var x in options_list) {
data[options_list[x]._id] = null;
}
var to_autocomplete = "input.desktop-search";
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
var to_autocomplete = "input.desktop-search";
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
$(to_autocomplete).autocomplete({
data: data,
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) {
Frontpage.to_channel(val, false);
},
});
$(to_autocomplete).autocomplete({
data: data,
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
onAutocomplete: function(val) {
Frontpage.to_channel(val, false);
},
});
document.getElementById("preloader").style.display = "none";
//Materialize.fadeInImage('#channels');
$("#channels").fadeIn(800);
$("#searchFrontpage").focus();
num = 0;
},
document.getElementById("preloader").style.display = "none";
//Materialize.fadeInImage('#channels');
$("#channels").fadeIn(800);
$("#searchFrontpage").focus();
num = 0;
},
sortFunction: function(a, b) {
var o1 = a.viewers;
var o2 = b.viewers;
sortFunction: function(a, b) {
var o1 = a.viewers;
var o2 = b.viewers;
var p1 = a.count;
var p2 = b.count;
var p1 = a.count;
var p2 = b.count;
if (o1 < o2) return 1;
if (o1 > o2) return -1;
if (p1 < p2) return 1;
if (p1 > p2) return -1;
return 0;
},
if (o1 < o2) return 1;
if (o1 > o2) return -1;
if (p1 < p2) return 1;
if (p1 > p2) return -1;
return 0;
},
sortFunction_active: function(a, b){
var o1 = a.accessed;
var o2 = b.accessed;
sortFunction_active: function(a, b){
var o1 = a.accessed;
var o2 = b.accessed;
var p1 = a.count;
var p2 = b.count;
var p1 = a.count;
var p2 = b.count;
if (o1 < o2) return 1;
if (o1 > o2) return -1;
if (p1 < p2) return 1;
if (p1 > p2) return -1;
return 0;
},
if (o1 < o2) return 1;
if (o1 > o2) return -1;
if (p1 < p2) return 1;
if (p1 > p2) return -1;
return 0;
},
getCookie: function(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
}
return "";
},
getCookie: function(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
}
return "";
},
add_backdrop: function(list, i) {
if(i >= list.length || i >= 20) i = 0;
add_backdrop: function(list, i) {
if(i >= list.length || i >= 20) i = 0;
var id = list[i].id;
if(Frontpage.blob_list[i] !== undefined){
//$(".room-namer").css("opacity", 0);
setTimeout(function(){
if(frontpage){
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
//$(".room-namer").css("opacity", 1);
}
},500);
} else {
var img = new Image();
img.src = "/assets/images/thumbnails/"+id+".jpg";
var id = list[i].id;
if(Frontpage.blob_list[i] !== undefined){
//$(".room-namer").css("opacity", 0);
setTimeout(function(){
if(frontpage){
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
//$(".room-namer").css("opacity", 1);
}
},500);
} else {
var img = new Image();
img.src = "/assets/images/thumbnails/"+id+".jpg";
img.onerror = function(){ // Failed to load
$.ajax({
type: "POST",
data: {id:id},
url: "/api/imageblob",
success: function(data){
setTimeout(function(){
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
},500);
}
});
};
img.onload = function(){ // Loaded successfully
$("#mega-background").css("background", "url("+img.src+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
};
img.onerror = function(){ // Failed to load
$.ajax({
type: "POST",
data: {id:id},
url: "/api/imageblob",
success: function(data){
setTimeout(function(){
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
},500);
}
});
};
img.onload = function(){ // Loaded successfully
$("#mega-background").css("background", "url("+img.src+")");
$("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1);
$(".desktop-search").attr("placeholder", list[i]._id);
};
}
rotation_timeout = setTimeout(function(){
if(Frontpage.times_rotated == 50 && frontpage){
Frontpage.times_rotated = 0;
i = 0;
Frontpage.get_frontpage_lists();
//socket.emit("frontpage_lists", {version: parseInt(localStorage.getItem("VERSION"))});
socket.emit('get_userlists', Crypt.getCookie('_uI'));
}else if(frontpage){
Frontpage.times_rotated += 1;
Frontpage.add_backdrop(list, i+1);
}
},6000);
},
}
rotation_timeout = setTimeout(function(){
if(Frontpage.times_rotated == 50 && frontpage){
Frontpage.times_rotated = 0;
i = 0;
Frontpage.get_frontpage_lists();
//socket.emit("frontpage_lists", {version: parseInt(localStorage.getItem("VERSION"))});
socket.emit('get_userlists', Crypt.getCookie('_uI'));
}else if(frontpage){
Frontpage.times_rotated += 1;
Frontpage.add_backdrop(list, i+1);
}
},6000);
},
get_frontpage_lists: function() {
$.ajax({
url: "/api/frontpages",
method: "get",
success: function(response){
Frontpage.frontpage_function(response);
},
error: function() {
Materialize.toast("Couldn't fetch lists, trying again in 3 seconds..", 3000, "red lighten connect_error");
retry_frontpage = setTimeout(function(){
Frontpage.get_frontpage_lists();
}, 3000);
},
});
},
get_frontpage_lists: function() {
$.ajax({
url: "/api/frontpages",
method: "get",
success: function(response){
Frontpage.frontpage_function(response);
},
error: function() {
Materialize.toast("Couldn't fetch lists, trying again in 3 seconds..", 3000, "red lighten connect_error");
retry_frontpage = setTimeout(function(){
Frontpage.get_frontpage_lists();
}, 3000);
},
});
},
start_snowfall: function() {
setTimeout(function(){
var x = Math.floor((Math.random() * window.innerWidth) + 1);
var snow = document.createElement("div");
var parent = document.getElementsByClassName("mega")[0];
start_snowfall: function() {
setTimeout(function(){
var x = Math.floor((Math.random() * window.innerWidth) + 1);
var snow = document.createElement("div");
var parent = document.getElementsByClassName("mega")[0];
snow.className = "snow";
//snow.attr("left", x);
snow.style.left = x+"px";
snow.style.top = "0px";
parent.appendChild(snow);
Frontpage.fall_snow(snow);
Frontpage.start_snowfall();
}, 800);
},
snow.className = "snow";
//snow.attr("left", x);
snow.style.left = x+"px";
snow.style.top = "0px";
parent.appendChild(snow);
Frontpage.fall_snow(snow);
Frontpage.start_snowfall();
}, 800);
},
fall_snow: function(corn) {
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
setTimeout(function(){
Frontpage.fall_snow(corn);
},50);
}else{
corn.remove();
}
},
fall_snow: function(corn) {
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
setTimeout(function(){
Frontpage.fall_snow(corn);
},50);
}else{
corn.remove();
}
},
set_viewers: function(viewers) {
$("#frontpage-viewer-counter").html("<i class='material-icons frontpage-viewers'>visibility</i>" + viewers);
},
set_viewers: function(viewers) {
$("#frontpage-viewer-counter").html("<i class='material-icons frontpage-viewers'>visibility</i>" + viewers);
},
to_channel: function(new_channel, popstate) {
$("#channel-load").css("display", "block");
window.scrollTo(0, 0);
frontpage = false;
new_channel = new_channel.toLowerCase();
clearTimeout(rotation_timeout);
if(Helper.mobilecheck()){
Helper.log("removing all listeners");
socket.removeAllListeners();
}
$("#main-container").css("background-color", "#2d2d2d");
$("#frontpage-viewer-counter").tooltip("remove");
$("#offline-mode").tooltip("remove");
currently_showing_channels = 1;
clearTimeout(retry_frontpage);
$.ajax({
url: "/" + new_channel,
method: "get",
data: {channel: new_channel},
success: function(e){
to_channel: function(new_channel, popstate) {
$("#channel-load").css("display", "block");
window.scrollTo(0, 0);
frontpage = false;
new_channel = new_channel.toLowerCase();
clearTimeout(rotation_timeout);
if(Helper.mobilecheck()){
Helper.log("removing all listeners");
socket.removeAllListeners();
}
$("#main-container").css("background-color", "#2d2d2d");
$("#frontpage-viewer-counter").tooltip("remove");
$("#offline-mode").tooltip("remove");
currently_showing_channels = 1;
clearTimeout(retry_frontpage);
$.ajax({
url: "/" + new_channel,
method: "get",
data: {channel: new_channel},
success: function(e){
if(Player.player !== ""){
//Player.player.destroy();
socket.emit("change_channel", {channel: chan.toLowerCase()});
}
$("#frontpage_player").empty();
if(Helper.mobilecheck()) {
Helper.log("disconnecting");
socket.disconnect();
}
if(Player.player !== ""){
//Player.player.destroy();
socket.emit("change_channel", {channel: chan.toLowerCase()});
}
$("#frontpage_player").empty();
if(Helper.mobilecheck()) {
Helper.log("disconnecting");
socket.disconnect();
}
if(!popstate){
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;
}
if(!popstate){
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;
}
var response = $("<div>" + e + "</div>");
var response = $("<div>" + e + "</div>");
$('select').material_select('destroy');
$(".mega").remove();
$(".mobile-search").remove();
$("main").attr("class", "container center-align main");
$("#main-container").addClass("channelpage");
//$("header").html($($(e)[63]).html());
$("header").html($(response.find("header")).html());
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
$("main").html($(response.find("main")).html());
} else {
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
$("#main-row").append("<div id='playbar'></div>");
$("#player").removeClass("player_bottom");
$("#main-row").removeClass("frontpage_modified_heights");
$("#main_section_frontpage").remove();
$("#closePlayer").remove();
$("#player_bottom_overlay").remove();
}
$("#search").attr("placeholder", "Find song on YouTube...");
$(".page-footer").addClass("padding-bottom-novideo");
from_frontpage = true;
if($("#alreadychannel").length == 1){
init();
}else{
fromFront = true;
init();
}
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
$('select').material_select('destroy');
$(".mega").remove();
$(".mobile-search").remove();
$("main").attr("class", "container center-align main");
$("#main-container").addClass("channelpage");
//$("header").html($($(e)[63]).html());
$("header").html($(response.find("header")).html());
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
$("main").html($(response.find("main")).html());
} else {
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
$("#main-row").append("<div id='playbar'></div>");
$("#player").removeClass("player_bottom");
$("#main-row").removeClass("frontpage_modified_heights");
$("#main_section_frontpage").remove();
$("#closePlayer").remove();
$("#player_bottom_overlay").remove();
}
$("#search").attr("placeholder", "Find song on YouTube...");
$(".page-footer").addClass("padding-bottom-novideo");
from_frontpage = true;
if($("#alreadychannel").length == 1){
init();
}else{
fromFront = true;
init();
}
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
}
});
}
}
});
}
};
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
return this.charAt(0).toUpperCase() + this.slice(1);
};
function share_link_modifier_frontpage() {
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/");
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;");
$("#twitter-code-link").attr("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic");
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
//$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/");
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;");
$("#twitter-code-link").attr("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic");
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&amp;text=Check%20out%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
//$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
}
function initfp() {
var date = new Date();
Frontpage.blob_list = [];
if(date.getMonth() == 3 && date.getDate() == 1){
$(".mega").css("-webkit-transform", "rotate(180deg)");
$(".mega").css("-moz-transform", "rotate(180deg)");
//Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000);
}
var date = new Date();
Frontpage.blob_list = [];
if(date.getMonth() == 3 && date.getDate() == 1){
$(".mega").css("-webkit-transform", "rotate(180deg)");
$(".mega").css("-moz-transform", "rotate(180deg)");
//Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000);
}
window.onpopstate = function(e){
var url_split = window.location.href.split("/");
window.onpopstate = function(e){
var url_split = window.location.href.split("/");
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
Frontpage.to_channel(url_split[3], true);
}
};
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
Frontpage.to_channel(url_split[3], true);
}
};
channel_list = $("#channel-list-container").clone().html();
channel_list = $("#channel-list-container").clone().html();
if(window.location.hostname != "fb.zoff.me") share_link_modifier_frontpage();
if(window.location.hostname != "fb.zoff.me") share_link_modifier_frontpage();
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.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);
socket.on('update_required', function() {
window.location.reload(true);
});
}
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
setup_playlist_listener();
}
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.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);
socket.on('update_required', function() {
window.location.reload(true);
});
}
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
setup_playlist_listener();
}
$("#about").modal();
$("#help").modal();
$("#contact").modal();
$('select').material_select();
$("#about").modal();
$("#help").modal();
$("#contact").modal();
$('select').material_select();
Helper.log("----");
Helper.log("Sending frontpage_lists");
Helper.log("Socket", socket);
Helper.log("-----");
Helper.log("----");
Helper.log("Sending frontpage_lists");
Helper.log("Socket", socket);
Helper.log("-----");
Crypt.init();
if(Crypt.get_offline()){
change_offline(true, offline);
} else {
$("#offline-mode").tooltip({
delay: 5,
position: "bottom",
tooltip: "Enable local mode"
});
}
$("#frontpage-viewer-counter").tooltip({
delay: 5,
position: "bottom",
tooltip: "Total Viewers"
});
Frontpage.get_frontpage_lists();
//socket.emit('frontpage_lists', {version: parseInt(localStorage.getItem("VERSION"))});
//socket.emit('get_userlists', Crypt.getCookie('_uI'));
Crypt.init();
if(Crypt.get_offline()){
change_offline(true, offline);
} else {
$("#offline-mode").tooltip({
delay: 5,
position: "bottom",
tooltip: "Enable local mode"
});
}
$("#frontpage-viewer-counter").tooltip({
delay: 5,
position: "bottom",
tooltip: "Total Viewers"
});
Frontpage.get_frontpage_lists();
//socket.emit('frontpage_lists', {version: parseInt(localStorage.getItem("VERSION"))});
//socket.emit('get_userlists', Crypt.getCookie('_uI'));
$("#channel-load").css("display", "none");
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
if(window.location.hash == "#donation") {
window.location.hash = "#";
$('#donation').modal();
$('#donation').modal('open');
}
$("#channel-load").css("display", "none");
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
if(window.location.hash == "#donation") {
window.location.hash = "#";
$('#donation').modal();
$('#donation').modal('open');
}
if(!localStorage.ok_cookie){
before_toast();
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);
}
if(!localStorage.ok_cookie){
before_toast();
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);
}
var pad = 0;
document.getElementById("zicon").addEventListener("click", function(){
pad+=10;
document.getElementById("zicon").style.paddingLeft = pad+"%";
if(pad >= 100)
window.location.href = 'http://etys.no';
});
var pad = 0;
document.getElementById("zicon").addEventListener("click", function(){
pad+=10;
document.getElementById("zicon").style.paddingLeft = pad+"%";
if(pad >= 100)
window.location.href = 'http://etys.no';
});
if(!Helper.mobilecheck() && Frontpage.winter) {
$(".mega").prepend('<div id="snow"></div>');
//Frontpage.start_snowfall();
}
if(!Helper.mobilecheck() && Frontpage.winter) {
$(".mega").prepend('<div id="snow"></div>');
//Frontpage.start_snowfall();
}
if(Helper.mobilecheck()){
$('input#searchFrontpage').characterCounter();
}
if(Helper.mobilecheck()){
$('input#searchFrontpage').characterCounter();
}
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
if (loaded) {
chromecastReady = true;
} else {
}
}
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
if (loaded) {
chromecastReady = true;
} else {
}
}
}