mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed a lot of indentations
This commit is contained in:
2
server/public/assets/dist/callback.min.js
vendored
2
server/public/assets/dist/callback.min.js
vendored
@@ -1 +1 @@
|
|||||||
!function(){function e(e){var t,a=e.substring(1).split("&"),n={};for(var i in a)t=a[i].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t,a,n,i=e(window.location.hash),o=window.location.protocol+"//"+window.location.hostname+"/o_callback";if(i.spotify)t="b934ecdd173648f5bcd38738af529d58",a="token",n="playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public",state=i.nonce,window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+n+"&show_dialog=false&response_type="+a+"&redirect_uri="+o+"&state="+state;else if(i.youtube)t="944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com",a="token",n="https://www.googleapis.com/auth/youtube",state=i.nonce,window.location.href="https://accounts.google.com/o/oauth2/v2/auth?client_id="+t+"&response_type="+a+"&state="+state+"&redirect_uri="+o+"&scope="+n;else{var s=e(window.location.hash);window.opener.callback(s)}})}();
|
!function(){function e(e){var t,a=e.substring(1).split("&"),n={};for(var s in a)t=a[s].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t,a,n,s=e(window.location.hash),i=window.location.protocol+"//"+window.location.hostname+"/o_callback";if(s.spotify)t="b934ecdd173648f5bcd38738af529d58",a="token",n="playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public",state=s.nonce,window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+n+"&show_dialog=false&response_type="+a+"&redirect_uri="+i+"&state="+state;else if(s.youtube)t="944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com",a="token",n="https://www.googleapis.com/auth/youtube",state=s.nonce,window.location.href="https://accounts.google.com/o/oauth2/v2/auth?client_id="+t+"&response_type="+a+"&state="+state+"&redirect_uri="+i+"&scope="+n;else{var o=e(window.location.hash);window.opener.callback(o)}})}();
|
||||||
@@ -105,7 +105,7 @@ var Admin = {
|
|||||||
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg));
|
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg));
|
||||||
|
|
||||||
for (var i = 0; i < names.length; i++) {
|
for (var i = 0; i < names.length; i++) {
|
||||||
$("input[name="+names[i]+"]").attr("disabled", false);
|
$("input[name="+names[i]+"]").attr("disabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".card-action").removeClass("hide");
|
$(".card-action").removeClass("hide");
|
||||||
@@ -124,25 +124,21 @@ var Admin = {
|
|||||||
if($(".password_protected").prop("checked")) {
|
if($(".password_protected").prop("checked")) {
|
||||||
$(".change_user_pass").removeClass("hide");
|
$(".change_user_pass").removeClass("hide");
|
||||||
}
|
}
|
||||||
//if(!Helper.mobilecheck()){
|
|
||||||
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
|
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
|
||||||
$(".playlist-tabs-loggedIn").removeClass("hide");
|
$(".playlist-tabs-loggedIn").removeClass("hide");
|
||||||
$(".playlist-tabs").addClass("hide");
|
$(".playlist-tabs").addClass("hide");
|
||||||
}
|
}
|
||||||
//$("#top-button").toggleClass("top-button-with-tabs");
|
|
||||||
//$("#wrapper").toggleClass("tabs_height");
|
|
||||||
//}
|
|
||||||
|
|
||||||
if($("#admin-lock").html() != "lock_open"){
|
if($("#admin-lock").html() != "lock_open"){
|
||||||
$("#admin-lock").addClass("clickable");
|
$("#admin-lock").addClass("clickable");
|
||||||
$("#admin-lock").html("lock_open");
|
$("#admin-lock").html("lock_open");
|
||||||
if(!Helper.mobilecheck()){
|
if(!Helper.mobilecheck()){
|
||||||
$('#admin-lock').tooltip({
|
$('#admin-lock').tooltip({
|
||||||
delay: 5,
|
delay: 5,
|
||||||
position: "left",
|
position: "left",
|
||||||
tooltip: "Logout"
|
tooltip: "Logout"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('ul.playlist-tabs-loggedIn').tabs('select_tab', $(".playlist-tabs li a.active").attr("href").substring(1));
|
$('ul.playlist-tabs-loggedIn').tabs('select_tab', $(".playlist-tabs li a.active").attr("href").substring(1));
|
||||||
},
|
},
|
||||||
@@ -163,41 +159,41 @@ var Admin = {
|
|||||||
{
|
{
|
||||||
if(!w_p)
|
if(!w_p)
|
||||||
{
|
{
|
||||||
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
log_out: function(){
|
log_out: function(){
|
||||||
before_toast();
|
before_toast();
|
||||||
if(Crypt.get_pass(chan.toLowerCase())){
|
if(Crypt.get_pass(chan.toLowerCase())){
|
||||||
Crypt.remove_pass(chan.toLowerCase());
|
Crypt.remove_pass(chan.toLowerCase());
|
||||||
Admin.display_logged_out();
|
Admin.display_logged_out();
|
||||||
Materialize.toast("Logged out", 4000);
|
Materialize.toast("Logged out", 4000);
|
||||||
}else{
|
}else{
|
||||||
Materialize.toast("Not logged in", 4000);
|
Materialize.toast("Not logged in", 4000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
display_logged_out: function()
|
display_logged_out: function()
|
||||||
{
|
{
|
||||||
w_p = true;
|
w_p = true;
|
||||||
adminpass = "";
|
adminpass = "";
|
||||||
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
|
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
|
||||||
"removeplay", "skip", "shuffle"];
|
"removeplay", "skip", "shuffle"];
|
||||||
|
|
||||||
document.getElementById("password").value = "";
|
document.getElementById("password").value = "";
|
||||||
$("#thumbnail_form").css("display", "none");
|
$("#thumbnail_form").css("display", "none");
|
||||||
$("#description_form").css("display", "none");
|
$("#description_form").css("display", "none");
|
||||||
for (i = 0; i < names.length; i++) {
|
for (i = 0; i < names.length; i++) {
|
||||||
$("input[name="+names[i]+"]").attr("disabled", true);
|
$("input[name="+names[i]+"]").attr("disabled", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#admin-lock").html() != "lock"){
|
if($("#admin-lock").html() != "lock"){
|
||||||
$("#admin-lock").removeClass("clickable");
|
$("#admin-lock").removeClass("clickable");
|
||||||
$("#admin-lock").html("lock");
|
$("#admin-lock").html("lock");
|
||||||
if(!Helper.mobilecheck()){
|
if(!Helper.mobilecheck()){
|
||||||
$('#admin-lock').tooltip('remove');
|
$('#admin-lock').tooltip('remove');
|
||||||
@@ -221,27 +217,24 @@ var Admin = {
|
|||||||
$(".playlist-tabs").removeClass("hide");
|
$(".playlist-tabs").removeClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($(".card-action").length !== 0 &&
|
if($(".card-action").length !== 0 &&
|
||||||
!Helper.contains($(".card-action").attr("class").split(" "), "hide") && !offline){
|
!Helper.contains($(".card-action").attr("class").split(" "), "hide") && !offline){
|
||||||
$(".card-action").addClass("hide");
|
$(".card-action").addClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("ul.playlist-tabs-loggedIn .playlist-tab-links.active").attr("href") == "#suggestions")
|
if($("ul.playlist-tabs-loggedIn .playlist-tab-links.active").attr("href") == "#suggestions")
|
||||||
{
|
{
|
||||||
$('ul.playlist-tabs').tabs('select_tab', 'wrapper');
|
$('ul.playlist-tabs').tabs('select_tab', 'wrapper');
|
||||||
$('ul.playlist-tabs-loggedIn').tabs('select_tab', 'wrapper');
|
$('ul.playlist-tabs-loggedIn').tabs('select_tab', 'wrapper');
|
||||||
//$("#wrapper").removeClass("tabs_height");
|
|
||||||
} else {
|
} else {
|
||||||
$('ul.playlist-tabs').tabs('select_tab', $(".playlist-tabs-loggedIn li a.active").attr("href").substring(1));
|
$('ul.playlist-tabs').tabs('select_tab', $(".playlist-tabs-loggedIn li a.active").attr("href").substring(1));
|
||||||
}
|
}
|
||||||
$("#admin-lock").removeClass("clickable");
|
$("#admin-lock").removeClass("clickable");
|
||||||
$("#password").attr("placeholder", "Enter admin password");
|
$("#password").attr("placeholder", "Enter admin password");
|
||||||
//$("#top-button").removeClass("top-button-with-tabs");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//function used in html onlick
|
|
||||||
save: function(userpass){
|
save: function(userpass){
|
||||||
Admin.submitAdmin(document.getElementById("adminForm").elements, userpass);
|
Admin.submitAdmin(document.getElementById("adminForm").elements, userpass);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_conf: function(conf_array)
|
set_conf: function(conf_array)
|
||||||
@@ -249,7 +242,7 @@ var Admin = {
|
|||||||
music = conf_array.allvideos;
|
music = conf_array.allvideos;
|
||||||
longsongs = conf_array.longsongs;
|
longsongs = conf_array.longsongs;
|
||||||
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
|
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
|
||||||
"removeplay", "skip", "shuffle", "userpass"];
|
"removeplay", "skip", "shuffle", "userpass"];
|
||||||
|
|
||||||
|
|
||||||
if(conf_array.adminpass === "" || !w_p){
|
if(conf_array.adminpass === "" || !w_p){
|
||||||
@@ -294,33 +287,29 @@ var Admin = {
|
|||||||
$("#description_area").html(conf_array.description);
|
$("#description_area").html(conf_array.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(conf_array.desc !== undefined)
|
|
||||||
{
|
|
||||||
document.getElementById("description").innerHTML = conf_array.desc;
|
|
||||||
}*/
|
|
||||||
},
|
},
|
||||||
|
|
||||||
submitAdmin: function(form, userpass_changed)
|
submitAdmin: function(form, userpass_changed)
|
||||||
{
|
{
|
||||||
voting = form.vote.checked;
|
voting = form.vote.checked;
|
||||||
addsongs = form.addsongs.checked;
|
addsongs = form.addsongs.checked;
|
||||||
longsongs = form.longsongs.checked;
|
longsongs = form.longsongs.checked;
|
||||||
frontpage = form.frontpage.checked;
|
frontpage = form.frontpage.checked;
|
||||||
allvideos = form.allvideos.checked;
|
allvideos = form.allvideos.checked;
|
||||||
removeplay = form.removeplay.checked;
|
removeplay = form.removeplay.checked;
|
||||||
skipping = form.skip.checked;
|
skipping = form.skip.checked;
|
||||||
shuffling = form.shuffle.checked;
|
shuffling = form.shuffle.checked;
|
||||||
var pass_send = userpass == '' ? userpass : CryptoJS.SHA256(userpass).toString();
|
var pass_send = userpass == '' ? userpass : CryptoJS.SHA256(userpass).toString();
|
||||||
configs = {
|
configs = {
|
||||||
channel: chan.toLowerCase(), voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: pass_send, userpass_changed: userpass_changed
|
channel: chan.toLowerCase(), voting: voting, addsongs: addsongs, longsongs: longsongs, frontpage: frontpage, allvideos: allvideos, removeplay: removeplay, adminpass: adminpass, skipping: skipping, shuffling: shuffling, userpass: pass_send, userpass_changed: userpass_changed
|
||||||
};
|
};
|
||||||
|
|
||||||
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
|
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
|
||||||
socket.emit("conf", configs);
|
socket.emit("conf", configs);
|
||||||
},
|
},
|
||||||
|
|
||||||
hide_settings: function(){
|
hide_settings: function(){
|
||||||
$('#settings').sideNav('hide');
|
$('#settings').sideNav('hide');
|
||||||
},
|
},
|
||||||
|
|
||||||
shuffle: function()
|
shuffle: function()
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
window.addEventListener("load", function(){
|
window.addEventListener("load", function(){
|
||||||
var query = getQueryHash(window.location.hash);
|
var query = getQueryHash(window.location.hash);
|
||||||
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
|
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
|
||||||
var client_id;
|
var client_id;
|
||||||
var response;
|
var response;
|
||||||
var scope;
|
var scope;
|
||||||
|
|
||||||
if(query.spotify){
|
if(query.spotify){
|
||||||
client_id = "b934ecdd173648f5bcd38738af529d58";
|
client_id = "b934ecdd173648f5bcd38738af529d58";
|
||||||
response = "token";
|
response = "token";
|
||||||
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
|
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
|
||||||
state = query.nonce;
|
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;
|
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) {
|
} else if (query.youtube) {
|
||||||
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
|
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
|
||||||
response = "token";
|
response = "token";
|
||||||
scope = "https://www.googleapis.com/auth/youtube";
|
scope = "https://www.googleapis.com/auth/youtube";
|
||||||
state = query.nonce;
|
state = query.nonce;
|
||||||
|
|
||||||
//window.opener.callback(query);
|
//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;
|
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 {
|
} else {
|
||||||
var query_parameters = getQueryHash(window.location.hash);
|
var query_parameters = getQueryHash(window.location.hash);
|
||||||
window.opener.callback(query_parameters);
|
window.opener.callback(query_parameters);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getQueryHash(url){
|
function getQueryHash(url){
|
||||||
var temp_arr = url.substring(1).split("&");
|
var temp_arr = url.substring(1).split("&");
|
||||||
var done_obj = {};
|
var done_obj = {};
|
||||||
var splitted;
|
var splitted;
|
||||||
for(var i in temp_arr) {
|
for(var i in temp_arr) {
|
||||||
splitted = temp_arr[i].split("=");
|
splitted = temp_arr[i].split("=");
|
||||||
if(splitted.length == 2) {
|
if(splitted.length == 2) {
|
||||||
done_obj[splitted[0]] = splitted[1];
|
done_obj[splitted[0]] = splitted[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return done_obj;
|
return done_obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,162 +1,163 @@
|
|||||||
var Chat = {
|
var Chat = {
|
||||||
|
|
||||||
channel_received: 0,
|
channel_received: 0,
|
||||||
all_received: 0,
|
all_received: 0,
|
||||||
chat_help: ["/name <new name> to change name", "/removename to remove name"],
|
chat_help: ["/name <new name> to change name", "/removename to remove name"],
|
||||||
|
|
||||||
namechange: function(newName)
|
namechange: function(newName)
|
||||||
{
|
{
|
||||||
socket.emit("namechange", newName);
|
socket.emit("namechange", newName);
|
||||||
Crypt.set_name(newName);
|
Crypt.set_name(newName);
|
||||||
},
|
},
|
||||||
|
|
||||||
removename: function()
|
removename: function()
|
||||||
{
|
{
|
||||||
socket.emit("removename");
|
socket.emit("removename");
|
||||||
Crypt.remove_name();
|
Crypt.remove_name();
|
||||||
},
|
},
|
||||||
|
|
||||||
chat: function(data)
|
chat: function(data)
|
||||||
{
|
{
|
||||||
if(data.value.length > 150)
|
if(data.value.length > 150)
|
||||||
return;
|
return;
|
||||||
if(data.value.startsWith("/name ")){
|
if(data.value.startsWith("/name ")){
|
||||||
Chat.namechange(data.value.substring(6));
|
Chat.namechange(data.value.substring(6));
|
||||||
} else if(data.value.startsWith("/help")){
|
} else if(data.value.startsWith("/help")){
|
||||||
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
|
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
|
||||||
if($("#chatall").children().length > 100){
|
if($("#chatall").children().length > 100){
|
||||||
$("#chatall").children()[0].remove()
|
$("#chatall").children()[0].remove()
|
||||||
}
|
}
|
||||||
for(var x = 0; x < Chat.chat_help.length; x++){
|
for(var x = 0; x < Chat.chat_help.length; x++){
|
||||||
var color = Helper.intToARGB(Helper.hashCode("System"));
|
var color = Helper.intToARGB(Helper.hashCode("System"));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++){
|
for(x = color.length; x < 6; x++){
|
||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
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>");
|
$("#chatall").append("<li title='Zoff''><span style='color:"+color_temp+";'>System</span>: </li>");
|
||||||
var in_text = document.createTextNode(Chat.chat_help[x]);
|
var in_text = document.createTextNode(Chat.chat_help[x]);
|
||||||
$("#chatall li:last")[0].appendChild(in_text);
|
$("#chatall li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($("#chatchannel").children().length > 100){
|
if($("#chatchannel").children().length > 100){
|
||||||
$("#chatchannel").children()[0].remove()
|
$("#chatchannel").children()[0].remove()
|
||||||
}
|
}
|
||||||
for(var x = 0; x < Chat.chat_help.length; x++){
|
for(var x = 0; x < Chat.chat_help.length; x++){
|
||||||
|
|
||||||
var color = Helper.intToARGB(Helper.hashCode("System"));
|
var color = Helper.intToARGB(Helper.hashCode("System"));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++){
|
for(x = color.length; x < 6; x++){
|
||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
|
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
|
||||||
var in_text = document.createTextNode(Chat.chat_help[x]);
|
var in_text = document.createTextNode(Chat.chat_help[x]);
|
||||||
$("#chatchannel li:last")[0].appendChild(in_text);
|
$("#chatchannel li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if(data.value.startsWith("/removename")){
|
} else if(data.value.startsWith("/removename")){
|
||||||
Chat.removename();
|
Chat.removename();
|
||||||
}
|
} else if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
|
||||||
else if($(".chat-tab-li a.active").attr("href") == "#all_chat")
|
socket.emit("all,chat", data.value);
|
||||||
socket.emit("all,chat", data.value);
|
} else {
|
||||||
else
|
socket.emit("chat", {channel: chan.toLowerCase(), data: data.value, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
socket.emit("chat", {channel: chan.toLowerCase(), data: data.value, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
}
|
||||||
data.value = "";
|
data.value = "";
|
||||||
return;
|
|
||||||
},
|
|
||||||
|
|
||||||
allchat: function(inp)
|
return;
|
||||||
{
|
},
|
||||||
//$("#chat-btn").css("color", "grey");
|
|
||||||
|
|
||||||
if(inp.msg.substring(0,1) == ":" && !chat_active)
|
allchat: function(inp)
|
||||||
{
|
{
|
||||||
Chat.all_received += 1;
|
//$("#chat-btn").css("color", "grey");
|
||||||
$("#favicon").attr("href", "public/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(!blinking) Chat.chat_blink();
|
|
||||||
//blink_interval = setTimeout(Chat.chat_blink, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(document.hidden)
|
if(inp.msg.substring(0,1) == ":" && !chat_active)
|
||||||
{
|
{
|
||||||
$("#favicon").attr("href", "public/images/highlogo.png");
|
Chat.all_received += 1;
|
||||||
}
|
$("#favicon").attr("href", "public/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(!blinking) Chat.chat_blink();
|
||||||
|
//blink_interval = setTimeout(Chat.chat_blink, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
if($("#chatall").children().length > 100){
|
if(document.hidden)
|
||||||
$("#chatall").children()[0].remove()
|
{
|
||||||
}
|
$("#favicon").attr("href", "public/images/highlogo.png");
|
||||||
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($("#chatall").children().length > 100){
|
||||||
{
|
$("#chatall").children()[0].remove()
|
||||||
if(data.msg.substring(0,1) == ":" && !chat_active)
|
}
|
||||||
{
|
var color = Helper.intToARGB(Helper.hashCode(inp.from));
|
||||||
$("#favicon").attr("href", "public/images/highlogo.png");
|
if(color.length < 6) {
|
||||||
unseen = true;
|
for(x = color.length; x < 6; x++){
|
||||||
chat_unseen = true;
|
color = "0" + color;
|
||||||
Chat.channel_received += 1;
|
}
|
||||||
//blink_interval = setTimeout(Chat.chat_blink, 1000);
|
}
|
||||||
if($(".chat-link span.badge.new.white").hasClass("hide")){
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
$(".chat-link span.badge.new.white").removeClass("hide");
|
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 to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
|
var in_text = document.createTextNode(inp.msg);
|
||||||
$(".chat-link span.badge.new.white").html(to_display);
|
$("#chatall li:last")[0].appendChild(in_text);
|
||||||
}
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
|
},
|
||||||
|
|
||||||
if($("#chatchannel").children().length > 100){
|
channelchat: function(data)
|
||||||
$("#chatchannel").children()[0].remove()
|
{
|
||||||
}
|
if(data.msg.substring(0,1) == ":" && !chat_active)
|
||||||
|
{
|
||||||
|
$("#favicon").attr("href", "public/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);
|
||||||
|
}
|
||||||
|
|
||||||
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
if($("#chatchannel").children().length > 100){
|
||||||
if(color.length < 6) {
|
$("#chatchannel").children()[0].remove()
|
||||||
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() {
|
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
||||||
blinking = true;
|
if(color.length < 6) {
|
||||||
$(".chat-link").attr("style", "color: grey !important;");
|
for(x = color.length; x < 6; x++){
|
||||||
setTimeout(function () {
|
color = "0" + color;
|
||||||
$(".chat-link").attr("style", "color: white !important;");
|
}
|
||||||
setTimeout(function() {
|
}
|
||||||
if(blinking) Chat.chat_blink();
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
}, 1000);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
}, 1000);
|
$("#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);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,21 +14,21 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
|
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
|
||||||
}catch(err){
|
}catch(err){
|
||||||
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
|
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(window.location.pathname != "/"){
|
if(window.location.pathname != "/"){
|
||||||
try{
|
try{
|
||||||
Crypt.conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
|
Crypt.conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
|
||||||
}catch(err){
|
}catch(err){
|
||||||
Crypt.conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
|
Crypt.conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
Hostcontroller.change_enabled(conf_arr.remote);
|
Hostcontroller.change_enabled(conf_arr.remote);
|
||||||
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
||||||
if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -38,57 +38,57 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var decrypted = CryptoJS.AES.decrypt(
|
var decrypted = CryptoJS.AES.decrypt(
|
||||||
cookie,"0103060703080703080701",
|
cookie,"0103060703080703080701",
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
||||||
},
|
},
|
||||||
|
|
||||||
decrypt_pass: function(pass){
|
decrypt_pass: function(pass){
|
||||||
var decrypted = CryptoJS.AES.decrypt(
|
var decrypted = CryptoJS.AES.decrypt(
|
||||||
pass,socket.id,
|
pass,socket.id,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return decrypted.toString(CryptoJS.enc.Utf8);
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
||||||
},
|
},
|
||||||
|
|
||||||
encrypt: function(json_formated, cookie){
|
encrypt: function(json_formated, cookie){
|
||||||
var to_encrypt = JSON.stringify(json_formated);
|
var to_encrypt = JSON.stringify(json_formated);
|
||||||
|
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
to_encrypt,
|
to_encrypt,
|
||||||
"0103060703080703080701",
|
"0103060703080703080701",
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var CookieDate = new Date();
|
var CookieDate = new Date();
|
||||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||||
if (location.protocol != "https:"){
|
if (location.protocol != "https:"){
|
||||||
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
} else {
|
} else {
|
||||||
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
encrypt_string: function(string){
|
encrypt_string: function(string){
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
string,
|
string,
|
||||||
socket.id,
|
socket.id,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return encrypted.toString();
|
return encrypted.toString();
|
||||||
},
|
},
|
||||||
@@ -117,28 +117,28 @@ var Crypt = {
|
|||||||
if(name == "_opt") cookie_object = {volume: 100, width: 100, remote: true, name: "", offline: false};
|
if(name == "_opt") cookie_object = {volume: 100, width: 100, remote: true, name: "", offline: false};
|
||||||
else cookie_object = {passwords: {}};
|
else cookie_object = {passwords: {}};
|
||||||
|
|
||||||
var string_it = JSON.stringify(cookie_object);
|
var string_it = JSON.stringify(cookie_object);
|
||||||
|
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
string_it,
|
string_it,
|
||||||
"0103060703080703080701",
|
"0103060703080703080701",
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var CookieDate = new Date();
|
var CookieDate = new Date();
|
||||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||||
|
|
||||||
if (location.protocol != "https:"){
|
if (location.protocol != "https:"){
|
||||||
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
} else {
|
} else {
|
||||||
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
}
|
}
|
||||||
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||||
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||||
return Crypt.getCookie(name);
|
return Crypt.getCookie(name);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_pass: function(chan, pass){
|
set_pass: function(chan, pass){
|
||||||
@@ -196,13 +196,13 @@ var Crypt = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
crypt_pass: function(pass){
|
crypt_pass: function(pass){
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
pass,
|
pass,
|
||||||
socket.id,
|
socket.id,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return encrypted.toString();
|
return encrypted.toString();
|
||||||
},
|
},
|
||||||
@@ -217,8 +217,8 @@ var Crypt = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getCookie: function(name) {
|
getCookie: function(name) {
|
||||||
var value = "; " + document.cookie;
|
var value = "; " + document.cookie;
|
||||||
var parts = value.split("; " + name + "=");
|
var parts = value.split("; " + name + "=");
|
||||||
if (parts.length == 2) return parts.pop().split(";").shift();
|
if (parts.length == 2) return parts.pop().split(";").shift();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
var song_title = "";
|
var song_title = "";
|
||||||
var paused = false;
|
var paused = false;
|
||||||
var player_ready = false;
|
var player_ready = false;
|
||||||
var list_html = $("#list-song-html").html();
|
var list_html = $("#list-song-html").html();
|
||||||
var w_p = true;
|
var w_p = true;
|
||||||
var lazy_load = false;
|
var lazy_load = false;
|
||||||
var embed = true;
|
var embed = true;
|
||||||
var vol = 100;
|
var vol = 100;
|
||||||
var adminpass = "";
|
var adminpass = "";
|
||||||
var mobile_beginning = false;
|
var mobile_beginning = false;
|
||||||
var durationBegun = false;
|
var durationBegun = false;
|
||||||
var chromecastAvailable = false;
|
var chromecastAvailable = false;
|
||||||
var private_channel = false;
|
var private_channel = false;
|
||||||
var offline = false;
|
var offline = false;
|
||||||
@@ -18,8 +18,8 @@ var seekTo;
|
|||||||
var socket;
|
var socket;
|
||||||
var video_id;
|
var video_id;
|
||||||
var previous_video_id;
|
var previous_video_id;
|
||||||
var hash = window.location.hash.substring(1).split("&");
|
var hash = window.location.hash.substring(1).split("&");
|
||||||
var chan = hash[0];
|
var chan = hash[0];
|
||||||
var autoplay = false;
|
var autoplay = false;
|
||||||
var color = "#808080";
|
var color = "#808080";
|
||||||
var dragging = false;
|
var dragging = false;
|
||||||
@@ -52,7 +52,7 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("get_list", function(){
|
socket.on("get_list", function(){
|
||||||
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: ''});},1000);
|
setTimeout(function(){socket.emit('list', {channel: chan.toLowerCase(), pass: ''});},1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("viewers", function(view)
|
socket.on("viewers", function(view)
|
||||||
@@ -60,7 +60,7 @@ $(document).ready(function(){
|
|||||||
viewers = view;
|
viewers = view;
|
||||||
|
|
||||||
if(song_title !== undefined)
|
if(song_title !== undefined)
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -102,11 +102,11 @@ $(document).on( "click", ".vote-container", function(e){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".prev_page", function(e){
|
$(document).on("click", ".prev_page", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
List.dynamicContentPage(-1);
|
List.dynamicContentPage(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".next_page", function(e){
|
$(document).on("click", ".next_page", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
List.dynamicContentPage(1);
|
List.dynamicContentPage(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,497 +6,475 @@ var frontpage = true;
|
|||||||
var socket;
|
var socket;
|
||||||
var rotation_timeout;
|
var rotation_timeout;
|
||||||
|
|
||||||
/*
|
|
||||||
function getCookie(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 "";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var Frontpage = {
|
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_function: function(msg) {
|
||||||
{
|
frontpage = true;
|
||||||
frontpage = true;
|
|
||||||
|
|
||||||
Helper.log("-----------");
|
Helper.log("-----------");
|
||||||
Helper.log("Frontpage fetch");
|
Helper.log("Frontpage fetch");
|
||||||
Helper.log(msg);
|
Helper.log(msg);
|
||||||
Helper.log("------------");
|
Helper.log("------------");
|
||||||
Frontpage.all_channels = msg.channels;
|
Frontpage.all_channels = msg.channels;
|
||||||
Frontpage.populate_channels(msg.channels, true);
|
Frontpage.populate_channels(msg.channels, true);
|
||||||
|
|
||||||
Frontpage.set_viewers(msg.viewers);
|
Frontpage.set_viewers(msg.viewers);
|
||||||
},
|
},
|
||||||
|
|
||||||
populate_channels: function(lists, popular)
|
populate_channels: function(lists, popular)
|
||||||
{
|
{
|
||||||
$("#channels").empty();
|
$("#channels").empty();
|
||||||
|
|
||||||
var num = 0;
|
var num = 0;
|
||||||
var pinned;
|
var pinned;
|
||||||
if(lists[0].pinned == 1){
|
if(lists[0].pinned == 1){
|
||||||
pinned = lists.shift();
|
pinned = lists.shift();
|
||||||
}
|
}
|
||||||
//lists.sort(Frontpage.sortFunction);
|
//lists.sort(Frontpage.sortFunction);
|
||||||
if(popular) {
|
if(popular) {
|
||||||
lists = lists.sort(Helper.predicate({
|
lists = lists.sort(Helper.predicate({
|
||||||
name: 'viewers',
|
name: 'viewers',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'accessed',
|
name: 'accessed',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'count',
|
name: 'count',
|
||||||
reverse: true
|
reverse: true
|
||||||
}
|
}));
|
||||||
)
|
} else {
|
||||||
);
|
lists = lists.sort(Helper.predicate({
|
||||||
} else {
|
name: 'viewers',
|
||||||
lists = lists.sort(Helper.predicate({
|
reverse: true
|
||||||
name: 'viewers',
|
}, {
|
||||||
reverse: true
|
name: 'count',
|
||||||
}, {
|
reverse: true
|
||||||
name: 'count',
|
}));
|
||||||
reverse: true
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pinned !== undefined){
|
if(pinned !== undefined){
|
||||||
lists.unshift(pinned);
|
lists.unshift(pinned);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Helper.mobilecheck()) {
|
if(!Helper.mobilecheck()) {
|
||||||
clearTimeout(rotation_timeout);
|
clearTimeout(rotation_timeout);
|
||||||
Frontpage.add_backdrop(lists, 0);
|
Frontpage.add_backdrop(lists, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre_card = $(channel_list);
|
pre_card = $(channel_list);
|
||||||
|
|
||||||
Helper.log("------------");
|
Helper.log("------------");
|
||||||
Helper.log(pre_card);
|
Helper.log(pre_card);
|
||||||
Helper.log("-------------");
|
Helper.log("-------------");
|
||||||
|
|
||||||
for(var x in lists)
|
for(var x in lists)
|
||||||
{
|
{
|
||||||
|
|
||||||
var chan = lists[x].channel;
|
var chan = lists[x].channel;
|
||||||
if(num<12 || !popular)
|
if(num<12 || !popular)
|
||||||
{
|
{
|
||||||
var id = lists[x].id;
|
var id = lists[x].id;
|
||||||
var viewers = lists[x].viewers;
|
var viewers = lists[x].viewers;
|
||||||
var description = lists[x].description;
|
var description = lists[x].description;
|
||||||
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
|
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
|
||||||
if(lists[x].thumbnail){
|
if(lists[x].thumbnail){
|
||||||
img = "background-image:url('" + lists[x].thumbnail + "');";
|
img = "background-image:url('" + lists[x].thumbnail + "');";
|
||||||
}
|
}
|
||||||
|
|
||||||
var song_count = lists[x].count;
|
var song_count = lists[x].count;
|
||||||
|
|
||||||
//$("#channels").append(channel_list);
|
//$("#channels").append(channel_list);
|
||||||
|
|
||||||
var card = pre_card.clone();
|
var card = pre_card.clone();
|
||||||
if(lists[x].pinned == 1)
|
if(lists[x].pinned == 1)
|
||||||
{
|
{
|
||||||
card.find(".pin").attr("style", "display:block;");
|
card.find(".pin").attr("style", "display:block;");
|
||||||
card.find(".card").attr("title", "Pinned!");
|
card.find(".card").attr("title", "Pinned!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
card.find(".pin").attr("style", "display:none;");
|
card.find(".pin").attr("style", "display:none;");
|
||||||
card.find(".card").attr("title", "");
|
card.find(".card").attr("title", "");
|
||||||
}
|
}
|
||||||
card.find(".chan-name").text(chan);
|
card.find(".chan-name").text(chan);
|
||||||
card.find(".chan-name").attr("title", chan);
|
card.find(".chan-name").attr("title", chan);
|
||||||
card.find(".chan-views").text(viewers);
|
card.find(".chan-views").text(viewers);
|
||||||
card.find(".chan-songs").text(song_count);
|
card.find(".chan-songs").text(song_count);
|
||||||
card.find(".chan-bg").attr("style", img);
|
card.find(".chan-bg").attr("style", img);
|
||||||
card.find(".chan-link").attr("href", chan + "/");
|
card.find(".chan-link").attr("href", chan + "/");
|
||||||
|
|
||||||
if(description != "" && !Helper.mobilecheck()){
|
if(description != "" && !Helper.mobilecheck()){
|
||||||
card.find(".card-title").text(chan);
|
card.find(".card-title").text(chan);
|
||||||
card.find(".description_text").text(description);
|
card.find(".description_text").text(description);
|
||||||
description = "";
|
description = "";
|
||||||
} else {
|
} else {
|
||||||
card.find(".card-reveal").remove();
|
card.find(".card-reveal").remove();
|
||||||
card.find(".card").removeClass("sticky-action")
|
card.find(".card").removeClass("sticky-action")
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#channels").append(card.html());
|
$("#channels").append(card.html());
|
||||||
|
|
||||||
//$("#channels").append(card);
|
//$("#channels").append(card);
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
//if(num>19)break;
|
//if(num>19)break;
|
||||||
}
|
}
|
||||||
var options_list = lists.slice();
|
var options_list = lists.slice();
|
||||||
|
|
||||||
options_list = options_list.sort(Frontpage.sortFunction_active);
|
options_list = options_list.sort(Frontpage.sortFunction_active);
|
||||||
var data = {};
|
var data = {};
|
||||||
//num = 0;
|
//num = 0;
|
||||||
for(var x in options_list){
|
for(var x in options_list){
|
||||||
//if(options_list[x].count > 5 && Math.floor((new Date).getTime()/1000) - options_list[x].accessed < 604800){
|
//if(options_list[x].count > 5 && Math.floor((new Date).getTime()/1000) - options_list[x].accessed < 604800){
|
||||||
/*var chan = options_list[x].channel;
|
/*var chan = options_list[x].channel;
|
||||||
output+="<option value='"+chan+"'> ";*/
|
output+="<option value='"+chan+"'> ";*/
|
||||||
data[options_list[x].channel] = null;
|
data[options_list[x].channel] = null;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
var to_autocomplete = "input.desktop-search";
|
var to_autocomplete = "input.desktop-search";
|
||||||
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
|
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
|
||||||
|
|
||||||
$(to_autocomplete).autocomplete({
|
$(to_autocomplete).autocomplete({
|
||||||
data: data,
|
data: data,
|
||||||
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
|
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
|
||||||
onAutocomplete: function(val) {
|
onAutocomplete: function(val) {
|
||||||
Frontpage.to_channel(val, false);
|
Frontpage.to_channel(val, false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
//$(".autocomplete").off('keydown.autocomplete');
|
//$(".autocomplete").off('keydown.autocomplete');
|
||||||
|
|
||||||
document.getElementById("preloader").style.display = "none";
|
document.getElementById("preloader").style.display = "none";
|
||||||
//Materialize.fadeInImage('#channels');
|
//Materialize.fadeInImage('#channels');
|
||||||
$("#channels").fadeIn(800);
|
$("#channels").fadeIn(800);
|
||||||
$("#searchFrontpage").focus();
|
$("#searchFrontpage").focus();
|
||||||
num = 0;
|
num = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
sortFunction: function(a, b) {
|
sortFunction: function(a, b) {
|
||||||
var o1 = a.viewers;
|
var o1 = a.viewers;
|
||||||
var o2 = b.viewers;
|
var o2 = b.viewers;
|
||||||
|
|
||||||
var p1 = a.count;
|
var p1 = a.count;
|
||||||
var p2 = b.count;
|
var p2 = b.count;
|
||||||
|
|
||||||
if (o1 < o2) return 1;
|
if (o1 < o2) return 1;
|
||||||
if (o1 > o2) return -1;
|
if (o1 > o2) return -1;
|
||||||
if (p1 < p2) return 1;
|
if (p1 < p2) return 1;
|
||||||
if (p1 > p2) return -1;
|
if (p1 > p2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
sortFunction_active: function(a, b){
|
sortFunction_active: function(a, b){
|
||||||
var o1 = a.accessed;
|
var o1 = a.accessed;
|
||||||
var o2 = b.accessed;
|
var o2 = b.accessed;
|
||||||
|
|
||||||
var p1 = a.count;
|
var p1 = a.count;
|
||||||
var p2 = b.count;
|
var p2 = b.count;
|
||||||
|
|
||||||
if (o1 < o2) return 1;
|
if (o1 < o2) return 1;
|
||||||
if (o1 > o2) return -1;
|
if (o1 > o2) return -1;
|
||||||
if (p1 < p2) return 1;
|
if (p1 < p2) return 1;
|
||||||
if (p1 > p2) return -1;
|
if (p1 > p2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
getCookie: function(cname) {
|
getCookie: function(cname) {
|
||||||
var name = cname + "=";
|
var name = cname + "=";
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
for(var i=0; i<ca.length; i++) {
|
for(var i=0; i<ca.length; i++) {
|
||||||
var c = ca[i];
|
var c = ca[i];
|
||||||
while (c.charAt(0)==' ') c = c.substring(1);
|
while (c.charAt(0)==' ') c = c.substring(1);
|
||||||
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
|
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
add_backdrop: function(list, i) {
|
add_backdrop: function(list, i) {
|
||||||
if(i >= list.length || i >= 20) i = 0;
|
if(i >= list.length || i >= 20) i = 0;
|
||||||
|
|
||||||
var id = list[i].id;
|
var id = list[i].id;
|
||||||
if(Frontpage.blob_list[i] !== undefined){
|
if(Frontpage.blob_list[i] !== undefined){
|
||||||
//$(".room-namer").css("opacity", 0);
|
//$(".room-namer").css("opacity", 0);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if(frontpage){
|
if(frontpage){
|
||||||
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
|
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i].channel);
|
$(".desktop-search").attr("placeholder", list[i].channel);
|
||||||
//$(".room-namer").css("opacity", 1);
|
//$(".room-namer").css("opacity", 1);
|
||||||
}
|
}
|
||||||
},500);
|
},500);
|
||||||
} else {
|
} else {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = "/assets/images/thumbnails/"+id+".jpg";
|
img.src = "/assets/images/thumbnails/"+id+".jpg";
|
||||||
|
|
||||||
img.onerror = function(){ // Failed to load
|
img.onerror = function(){ // Failed to load
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {id:id},
|
data: {id:id},
|
||||||
url: "/api/imageblob",
|
url: "/api/imageblob",
|
||||||
success: function(data){
|
success: function(data){
|
||||||
//Frontpage.blob_list.push(data);
|
//Frontpage.blob_list.push(data);
|
||||||
//data will contain the vote count echoed by the controller i.e.
|
//data will contain the vote count echoed by the controller i.e.
|
||||||
//$(".room-namer").css("opacity", 0);
|
//$(".room-namer").css("opacity", 0);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
|
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i].channel);
|
$(".desktop-search").attr("placeholder", list[i].channel);
|
||||||
//$(".room-namer").css("opacity", 1);
|
//$(".room-namer").css("opacity", 1);
|
||||||
},500);
|
},500);
|
||||||
//then append the result where ever you want like
|
//then append the result where ever you want like
|
||||||
//$("span#votes_number").html(data); //data will be containing the vote count which you have echoed from the controller
|
//$("span#votes_number").html(data); //data will be containing the vote count which you have echoed from the controller
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
img.onload = function(){ // Loaded successfully
|
img.onload = function(){ // Loaded successfully
|
||||||
$("#mega-background").css("background", "url("+img.src+")");
|
$("#mega-background").css("background", "url("+img.src+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i].channel);
|
$(".desktop-search").attr("placeholder", list[i].channel);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
rotation_timeout = setTimeout(function(){
|
rotation_timeout = setTimeout(function(){
|
||||||
if(Frontpage.times_rotated == 50 && frontpage){
|
if(Frontpage.times_rotated == 50 && frontpage){
|
||||||
Frontpage.times_rotated = 0;
|
Frontpage.times_rotated = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
socket.emit("frontpage_lists");
|
socket.emit("frontpage_lists");
|
||||||
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||||
}else if(frontpage){
|
}else if(frontpage){
|
||||||
Frontpage.times_rotated += 1;
|
Frontpage.times_rotated += 1;
|
||||||
Frontpage.add_backdrop(list, i+1);
|
Frontpage.add_backdrop(list, i+1);
|
||||||
}
|
}
|
||||||
},6000);
|
},6000);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
start_snowfall: function(){
|
start_snowfall: function(){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
var x = Math.floor((Math.random() * window.innerWidth) + 1);
|
var x = Math.floor((Math.random() * window.innerWidth) + 1);
|
||||||
var snow = document.createElement("div");
|
var snow = document.createElement("div");
|
||||||
var parent = document.getElementsByClassName("mega")[0];
|
var parent = document.getElementsByClassName("mega")[0];
|
||||||
|
|
||||||
snow.className = "snow";
|
snow.className = "snow";
|
||||||
//snow.attr("left", x);
|
//snow.attr("left", x);
|
||||||
snow.style.left = x+"px";
|
snow.style.left = x+"px";
|
||||||
snow.style.top = "0px";
|
snow.style.top = "0px";
|
||||||
parent.appendChild(snow);
|
parent.appendChild(snow);
|
||||||
Frontpage.fall_snow(snow);
|
Frontpage.fall_snow(snow);
|
||||||
Frontpage.start_snowfall();
|
Frontpage.start_snowfall();
|
||||||
}, 800);
|
}, 800);
|
||||||
},
|
},
|
||||||
|
|
||||||
fall_snow: function(corn){
|
fall_snow: function(corn){
|
||||||
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
|
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){
|
if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
Frontpage.fall_snow(corn);
|
Frontpage.fall_snow(corn);
|
||||||
},50);
|
},50);
|
||||||
}else{
|
}else{
|
||||||
corn.remove();
|
corn.remove();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_viewers: function(viewers){
|
set_viewers: function(viewers){
|
||||||
//if(viewers > 0){
|
//if(viewers > 0){
|
||||||
//var to_add = viewers > 1 ? "listeners" : "listener";
|
//var to_add = viewers > 1 ? "listeners" : "listener";
|
||||||
$("#frontpage-viewer-counter").html("<i class='material-icons frontpage-viewers'>visibility</i>" + viewers);
|
$("#frontpage-viewer-counter").html("<i class='material-icons frontpage-viewers'>visibility</i>" + viewers);
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
|
|
||||||
to_channel: function(new_channel, popstate){
|
to_channel: function(new_channel, popstate){
|
||||||
|
|
||||||
$("#channel-load").css("display", "block");
|
$("#channel-load").css("display", "block");
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
frontpage = false;
|
frontpage = false;
|
||||||
clearTimeout(rotation_timeout);
|
clearTimeout(rotation_timeout);
|
||||||
if(Helper.mobilecheck()){
|
if(Helper.mobilecheck()){
|
||||||
Helper.log("removing all listeners");
|
Helper.log("removing all listeners");
|
||||||
socket.removeAllListeners();
|
socket.removeAllListeners();
|
||||||
}
|
}
|
||||||
$("#main-container").css("background-color", "#2d2d2d");
|
$("#main-container").css("background-color", "#2d2d2d");
|
||||||
$("#offline-mode").tooltip("remove");
|
$("#offline-mode").tooltip("remove");
|
||||||
currently_showing_channels = 1;
|
currently_showing_channels = 1;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/" + new_channel,
|
url: "/" + new_channel,
|
||||||
method: "get",
|
method: "get",
|
||||||
data: {channel: new_channel},
|
data: {channel: new_channel},
|
||||||
success: function(e){
|
success: function(e){
|
||||||
|
|
||||||
if(Player.player !== ""){
|
if(Player.player !== ""){
|
||||||
//Player.player.destroy();
|
//Player.player.destroy();
|
||||||
socket.emit("change_channel", {channel: chan.toLowerCase()});
|
socket.emit("change_channel", {channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
$("#frontpage_player").empty();
|
$("#frontpage_player").empty();
|
||||||
if(Helper.mobilecheck()) {
|
if(Helper.mobilecheck()) {
|
||||||
Helper.log("disconnecting");
|
Helper.log("disconnecting");
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!popstate){
|
if(!popstate){
|
||||||
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
||||||
if(prev_chan_list == "") prev_chan_list = new_channel;
|
if(prev_chan_list == "") prev_chan_list = new_channel;
|
||||||
if(prev_chan_player == "") prev_chan_player = new_channel;
|
if(prev_chan_player == "") prev_chan_player = new_channel;
|
||||||
window.chan = new_channel;
|
window.chan = new_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = $("<div>" + e + "</div>");
|
var response = $("<div>" + e + "</div>");
|
||||||
|
|
||||||
$('select').material_select('destroy');
|
$('select').material_select('destroy');
|
||||||
$(".mega").remove();
|
$(".mega").remove();
|
||||||
$(".mobile-search").remove();
|
$(".mobile-search").remove();
|
||||||
$("main").attr("class", "container center-align main");
|
$("main").attr("class", "container center-align main");
|
||||||
$("#main-container").addClass("channelpage");
|
$("#main-container").addClass("channelpage");
|
||||||
//$("header").html($($(e)[63]).html());
|
//$("header").html($($(e)[63]).html());
|
||||||
$("header").html($(response.find("header")).html());
|
$("header").html($(response.find("header")).html());
|
||||||
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
|
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
|
||||||
$("main").html($(response.find("main")).html());
|
$("main").html($(response.find("main")).html());
|
||||||
} else {
|
} else {
|
||||||
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
|
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
|
||||||
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
|
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
|
||||||
$("#main-row").append("<div id='playbar'></div>");
|
$("#main-row").append("<div id='playbar'></div>");
|
||||||
$("#player").removeClass("player_bottom");
|
$("#player").removeClass("player_bottom");
|
||||||
$("#main-row").removeClass("frontpage_modified_heights");
|
$("#main-row").removeClass("frontpage_modified_heights");
|
||||||
$("#main_section_frontpage").remove();
|
$("#main_section_frontpage").remove();
|
||||||
$("#closePlayer").remove();
|
$("#closePlayer").remove();
|
||||||
$("#player_bottom_overlay").remove();
|
$("#player_bottom_overlay").remove();
|
||||||
}
|
}
|
||||||
$("#search").attr("placeholder", "Find song on YouTube...");
|
$("#search").attr("placeholder", "Find song on YouTube...");
|
||||||
$(".page-footer").addClass("padding-bottom-novideo");
|
$(".page-footer").addClass("padding-bottom-novideo");
|
||||||
from_frontpage = true;
|
from_frontpage = true;
|
||||||
if($("#alreadychannel").length == 1){
|
if($("#alreadychannel").length == 1){
|
||||||
init();
|
init();
|
||||||
}else{
|
}else{
|
||||||
fromFront = true;
|
fromFront = true;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
|
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.capitalizeFirstLetter = function() {
|
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(){
|
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("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;");
|
$("#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/&text=Check%20out%20Zoff!&via=zoffmusic");
|
$("#twitter-code-link").attr("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic");
|
||||||
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
|
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&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-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");
|
$("#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(){
|
function initfp(){
|
||||||
|
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
Frontpage.blob_list = [];
|
Frontpage.blob_list = [];
|
||||||
if(date.getMonth() == 3 && date.getDate() == 1){
|
if(date.getMonth() == 3 && date.getDate() == 1){
|
||||||
$(".mega").css("-webkit-transform", "rotate(180deg)");
|
$(".mega").css("-webkit-transform", "rotate(180deg)");
|
||||||
$(".mega").css("-moz-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);
|
//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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(window.location.hostname != "zoff.me"){
|
|
||||||
console.log("not zoff.me, redirecting"); //redirect
|
window.onpopstate = function(e){
|
||||||
window.location.href = "https://zoff.me";
|
var url_split = window.location.href.split("/");
|
||||||
}*/
|
|
||||||
|
|
||||||
window.onpopstate = function(e){
|
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
|
||||||
var url_split = window.location.href.split("/");
|
Frontpage.to_channel(url_split[3], true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
|
channel_list = $("#channel-list-container").clone().html();
|
||||||
Frontpage.to_channel(url_split[3], true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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") 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") add = "https://zoff.me";
|
$("#about").modal();
|
||||||
else add = window.location.hostname;
|
$("#help").modal();
|
||||||
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) {
|
$("#contact").modal();
|
||||||
socket = io.connect(''+add+':8080', connection_options);
|
$('select').material_select();
|
||||||
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();
|
Helper.log("----");
|
||||||
$("#help").modal();
|
Helper.log("Sending frontpage_lists");
|
||||||
$("#contact").modal();
|
Helper.log("Socket", socket);
|
||||||
$('select').material_select();
|
Helper.log("-----");
|
||||||
|
|
||||||
Helper.log("----");
|
Crypt.init();
|
||||||
Helper.log("Sending frontpage_lists");
|
if(Crypt.get_offline()){
|
||||||
Helper.log("Socket", socket);
|
change_offline(true, offline);
|
||||||
Helper.log("-----");
|
} else {
|
||||||
|
$("#offline-mode").tooltip({
|
||||||
|
delay: 5,
|
||||||
|
position: "bottom",
|
||||||
|
tooltip: "Enable private mode"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
socket.emit('frontpage_lists');
|
||||||
|
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||||
|
|
||||||
Crypt.init();
|
$("#channel-load").css("display", "none");
|
||||||
if(Crypt.get_offline()){
|
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
|
||||||
change_offline(true, offline);
|
if(window.location.hash == "#donation")
|
||||||
} else {
|
{
|
||||||
$("#offline-mode").tooltip({
|
window.location.hash = "#";
|
||||||
delay: 5,
|
$('#donation').modal('open');
|
||||||
position: "bottom",
|
}
|
||||||
tooltip: "Enable private mode"
|
//window.channel_list = channel_list;
|
||||||
});
|
|
||||||
}
|
|
||||||
socket.emit('frontpage_lists');
|
|
||||||
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
|
||||||
|
|
||||||
$("#channel-load").css("display", "none");
|
if(!localStorage.ok_cookie){
|
||||||
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
|
before_toast();
|
||||||
if(window.location.hash == "#donation")
|
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);
|
||||||
{
|
}
|
||||||
window.location.hash = "#";
|
|
||||||
$('#donation').modal('open');
|
|
||||||
}
|
|
||||||
//window.channel_list = channel_list;
|
|
||||||
|
|
||||||
if(!localStorage.ok_cookie){
|
var pad = 0;
|
||||||
before_toast();
|
document.getElementById("zicon").addEventListener("click", function(){
|
||||||
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);
|
pad+=10;
|
||||||
}
|
document.getElementById("zicon").style.paddingLeft = pad+"%";
|
||||||
|
if(pad >= 100)
|
||||||
|
window.location.href = 'http://etys.no';
|
||||||
|
});
|
||||||
|
|
||||||
var pad = 0;
|
if(!Helper.mobilecheck() && Frontpage.winter) {
|
||||||
document.getElementById("zicon").addEventListener("click", function(){
|
$(".mega").prepend('<div id="snow"></div>');
|
||||||
pad+=10;
|
//Frontpage.start_snowfall();
|
||||||
document.getElementById("zicon").style.paddingLeft = pad+"%";
|
}
|
||||||
if(pad >= 100)
|
|
||||||
window.location.href = 'http://etys.no';
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!Helper.mobilecheck() && Frontpage.winter) {
|
if(Helper.mobilecheck()){
|
||||||
$(".mega").prepend('<div id="snow"></div>');
|
$('input#searchFrontpage').characterCounter();
|
||||||
//Frontpage.start_snowfall();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(Helper.mobilecheck()){
|
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
|
||||||
$('input#searchFrontpage').characterCounter();
|
if (loaded) {
|
||||||
}
|
chromecastReady = true;
|
||||||
|
} else {
|
||||||
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
|
}
|
||||||
if (loaded) {
|
}
|
||||||
chromecastReady = true;
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,273 +1,273 @@
|
|||||||
var Helper = {
|
var Helper = {
|
||||||
|
|
||||||
log: function(to_log){
|
log: function(to_log){
|
||||||
if(localStorage.debug === "true") {
|
if(localStorage.debug === "true") {
|
||||||
console.log(to_log);
|
console.log(to_log);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
rnd: function(arr)
|
rnd: function(arr)
|
||||||
{
|
{
|
||||||
return arr[Math.floor(Math.random() * arr.length)];
|
return arr[Math.floor(Math.random() * arr.length)];
|
||||||
},
|
},
|
||||||
|
|
||||||
mobilecheck: function() {
|
mobilecheck: function() {
|
||||||
var isMobile = false; //initiate as false
|
var isMobile = false; //initiate as false
|
||||||
// device detection
|
// device detection
|
||||||
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|Android|Silk|lge |maemo|midp|mmp|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|phone)|xda|xiino/i.test(navigator.userAgent)
|
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|Android|Silk|lge |maemo|midp|mmp|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|phone)|xda|xiino/i.test(navigator.userAgent)
|
||||||
|| /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(navigator.userAgent.substr(0,4))) isMobile = true;
|
|| /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(navigator.userAgent.substr(0,4))) isMobile = true;
|
||||||
return isMobile;
|
return isMobile;
|
||||||
},
|
},
|
||||||
|
|
||||||
predicate: function() {
|
predicate: function() {
|
||||||
var fields = [],
|
var fields = [],
|
||||||
n_fields = arguments.length,
|
n_fields = arguments.length,
|
||||||
field, name, cmp;
|
field, name, cmp;
|
||||||
|
|
||||||
var default_cmp = function (a, b) {
|
var default_cmp = function (a, b) {
|
||||||
if (a === b) return 0;
|
if (a === b) return 0;
|
||||||
return a < b ? -1 : 1;
|
return a < b ? -1 : 1;
|
||||||
},
|
},
|
||||||
getCmpFunc = function (primer, reverse) {
|
getCmpFunc = function (primer, reverse) {
|
||||||
var dfc = default_cmp,
|
var dfc = default_cmp,
|
||||||
// closer in scope
|
// closer in scope
|
||||||
cmp = default_cmp;
|
cmp = default_cmp;
|
||||||
if (primer) {
|
if (primer) {
|
||||||
cmp = function (a, b) {
|
cmp = function (a, b) {
|
||||||
return dfc(primer(a), primer(b));
|
return dfc(primer(a), primer(b));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
return function (a, b) {
|
return function (a, b) {
|
||||||
return -1 * cmp(a, b);
|
return -1 * cmp(a, b);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
// preprocess sorting options
|
// preprocess sorting options
|
||||||
for (var i = 0; i < n_fields; i++) {
|
for (var i = 0; i < n_fields; i++) {
|
||||||
field = arguments[i];
|
field = arguments[i];
|
||||||
if (typeof field === 'string') {
|
if (typeof field === 'string') {
|
||||||
name = field;
|
name = field;
|
||||||
cmp = default_cmp;
|
cmp = default_cmp;
|
||||||
} else {
|
} else {
|
||||||
name = field.name;
|
name = field.name;
|
||||||
cmp = getCmpFunc(field.primer, field.reverse);
|
cmp = getCmpFunc(field.primer, field.reverse);
|
||||||
}
|
}
|
||||||
fields.push({
|
fields.push({
|
||||||
name: name,
|
name: name,
|
||||||
cmp: cmp
|
cmp: cmp
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// final comparison function
|
// final comparison function
|
||||||
return function (A, B) {
|
return function (A, B) {
|
||||||
var name, result;
|
var name, result;
|
||||||
for (var i = 0; i < n_fields; i++) {
|
for (var i = 0; i < n_fields; i++) {
|
||||||
result = 0;
|
result = 0;
|
||||||
field = fields[i];
|
field = fields[i];
|
||||||
name = field.name;
|
name = field.name;
|
||||||
|
|
||||||
result = field.cmp(A[name], B[name]);
|
result = field.cmp(A[name], B[name]);
|
||||||
if (result !== 0) break;
|
if (result !== 0) break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
hashCode: function(str) { // java String#hashCode
|
hashCode: function(str) { // java String#hashCode
|
||||||
var hash = 0;
|
var hash = 0;
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
},
|
},
|
||||||
|
|
||||||
intToARGB: function(i){
|
intToARGB: function(i){
|
||||||
return ((i>>24)&0xFF).toString(16) +
|
return ((i>>24)&0xFF).toString(16) +
|
||||||
((i>>16)&0xFF).toString(16) +
|
((i>>16)&0xFF).toString(16) +
|
||||||
((i>>8)&0xFF).toString(16) +
|
((i>>8)&0xFF).toString(16) +
|
||||||
(i&0xFF).toString(16);
|
(i&0xFF).toString(16);
|
||||||
},
|
},
|
||||||
|
|
||||||
hexToRgb: function(hex) {
|
hexToRgb: function(hex) {
|
||||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||||
return result ? {
|
return result ? {
|
||||||
r: parseInt(result[1], 16),
|
r: parseInt(result[1], 16),
|
||||||
g: parseInt(result[2], 16),
|
g: parseInt(result[2], 16),
|
||||||
b: parseInt(result[3], 16)
|
b: parseInt(result[3], 16)
|
||||||
} : null;
|
} : null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
pad: function(n)
|
pad: function(n)
|
||||||
{
|
{
|
||||||
return n < 10 ? "0"+Math.floor(n) : Math.floor(n);
|
return n < 10 ? "0"+Math.floor(n) : Math.floor(n);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
contains: function(a, obj) {
|
contains: function(a, obj) {
|
||||||
var i = a.length;
|
var i = a.length;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (a[i] === obj) {
|
if (a[i] === obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
sample: function() {
|
sample: function() {
|
||||||
if (Date.now() - lastSample >= SAMPLE_RATE * 2) {
|
if (Date.now() - lastSample >= SAMPLE_RATE * 2) {
|
||||||
socket.removeAllListeners();
|
socket.removeAllListeners();
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
socket.connect();
|
socket.connect();
|
||||||
Player.setup_all_listeners();
|
Player.setup_all_listeners();
|
||||||
}
|
}
|
||||||
lastSample = Date.now();
|
lastSample = Date.now();
|
||||||
setTimeout(Helper.sample, SAMPLE_RATE);
|
setTimeout(Helper.sample, SAMPLE_RATE);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadjsfile: function(filename)
|
loadjsfile: function(filename)
|
||||||
{
|
{
|
||||||
if (filesadded.indexOf("["+filename+"]")==-1){
|
if (filesadded.indexOf("["+filename+"]")==-1){
|
||||||
var fileref=document.createElement('script');
|
var fileref=document.createElement('script');
|
||||||
fileref.setAttribute("type","text/javascript");
|
fileref.setAttribute("type","text/javascript");
|
||||||
fileref.setAttribute("src", filename);
|
fileref.setAttribute("src", filename);
|
||||||
document.getElementsByTagName("head")[0].appendChild(fileref);
|
document.getElementsByTagName("head")[0].appendChild(fileref);
|
||||||
filesadded+="["+filename+"]";
|
filesadded+="["+filename+"]";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
msieversion: function() {
|
msieversion: function() {
|
||||||
|
|
||||||
var ua = window.navigator.userAgent;
|
var ua = window.navigator.userAgent;
|
||||||
var msie = ua.indexOf("MSIE ");
|
var msie = ua.indexOf("MSIE ");
|
||||||
|
|
||||||
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
|
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
|
||||||
return true;
|
return true;
|
||||||
else // If another browser, return 0
|
else // If another browser, return 0
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getRandomInt: function(min, max) {
|
getRandomInt: function(min, max) {
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
},
|
},
|
||||||
|
|
||||||
secondsToOther: function(seconds){
|
secondsToOther: function(seconds){
|
||||||
var time = seconds;
|
var time = seconds;
|
||||||
var minutes = Math.floor(time/60);
|
var minutes = Math.floor(time/60);
|
||||||
time = time - (minutes * 60);
|
time = time - (minutes * 60);
|
||||||
return [minutes, time];
|
return [minutes, time];
|
||||||
},
|
},
|
||||||
|
|
||||||
rgbToHsl: function(arr, light){
|
rgbToHsl: function(arr, light){
|
||||||
r = arr[0];
|
r = arr[0];
|
||||||
g = arr[1];
|
g = arr[1];
|
||||||
b = arr[2];
|
b = arr[2];
|
||||||
r /= 255;
|
r /= 255;
|
||||||
g /= 255;
|
g /= 255;
|
||||||
b /= 255;
|
b /= 255;
|
||||||
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
||||||
var h, s, l = (max + min) / 2;
|
var h, s, l = (max + min) / 2;
|
||||||
|
|
||||||
if(max == min){
|
if(max == min){
|
||||||
h = s = 0; // achromatic
|
h = s = 0; // achromatic
|
||||||
}else{
|
}else{
|
||||||
var d = max - min;
|
var d = max - min;
|
||||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||||
switch(max){
|
switch(max){
|
||||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||||
case g: h = (b - r) / d + 2; break;
|
case g: h = (b - r) / d + 2; break;
|
||||||
case b: h = (r - g) / d + 4; break;
|
case b: h = (r - g) / d + 4; break;
|
||||||
}
|
}
|
||||||
h /= 6;
|
h /= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(l>0.5 && light)l=0.4; //make sure it isnt too light
|
if(l>0.5 && light)l=0.4; //make sure it isnt too light
|
||||||
else if(l<0.65 && !light)l=0.65;
|
else if(l<0.65 && !light)l=0.65;
|
||||||
|
|
||||||
return "hsl("+Math.floor(h*360)+", "+Math.floor(s*100)+"%, "+Math.floor(l*100)+"%)";
|
return "hsl("+Math.floor(h*360)+", "+Math.floor(s*100)+"%, "+Math.floor(l*100)+"%)";
|
||||||
},
|
},
|
||||||
|
|
||||||
componentToHex: function(c) {
|
componentToHex: function(c) {
|
||||||
var hex = c.toString(16);
|
var hex = c.toString(16);
|
||||||
return hex.length == 1 ? "0" + hex : hex;
|
return hex.length == 1 ? "0" + hex : hex;
|
||||||
},
|
},
|
||||||
|
|
||||||
rgbToHex: function(r, g, b) {
|
rgbToHex: function(r, g, b) {
|
||||||
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
|
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
|
||||||
},
|
},
|
||||||
|
|
||||||
upperFirst: function(string){
|
upperFirst: function(string){
|
||||||
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
addClass: function(object, toAdd){
|
addClass: function(object, toAdd){
|
||||||
if(!Helper.contains($(object).attr("class").split(" "), toAdd)){
|
if(!Helper.contains($(object).attr("class").split(" "), toAdd)){
|
||||||
$(object).addClass(toAdd);
|
$(object).addClass(toAdd);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
send_mail: function(from, message){
|
send_mail: function(from, message){
|
||||||
|
|
||||||
|
|
||||||
if(from !== "" && message !== ""){
|
if(from !== "" && message !== ""){
|
||||||
|
|
||||||
$("#submit-contact-form").addClass("hide");
|
$("#submit-contact-form").addClass("hide");
|
||||||
$("#send-loader").removeClass("hide");
|
$("#send-loader").removeClass("hide");
|
||||||
$("#contact-form-from").attr("disabled", "true");
|
$("#contact-form-from").attr("disabled", "true");
|
||||||
$("#contact-form-message").attr("disabled", "true");
|
$("#contact-form-message").attr("disabled", "true");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {from: from, message: message},
|
data: {from: from, message: message},
|
||||||
url: "/api/mail",
|
url: "/api/mail",
|
||||||
success: function(data){
|
success: function(data){
|
||||||
if(data == "success"){
|
if(data == "success"){
|
||||||
$("#contact-container").empty();
|
$("#contact-container").empty();
|
||||||
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
||||||
}else{
|
}else{
|
||||||
$("#contact-container").empty();
|
$("#contact-container").empty();
|
||||||
$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: <a title='Open in client' href='mailto:contact@zoff.no?Subject=Contact%20Zoff'>contact@zoff.no</a>")
|
$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: <a title='Open in client' href='mailto:contact@zoff.no?Subject=Contact%20Zoff'>contact@zoff.no</a>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*from = $("#contact-form-from").val();
|
/*from = $("#contact-form-from").val();
|
||||||
message = $("#contact-form-message").val();
|
message = $("#contact-form-message").val();
|
||||||
$("#contact-container").empty();
|
$("#contact-container").empty();
|
||||||
newWindow = window.open("mailto:contact@zoff.no?Subject=Contact%20Zoff&Body=" + message, "_blank");
|
newWindow = window.open("mailto:contact@zoff.no?Subject=Contact%20Zoff&Body=" + message, "_blank");
|
||||||
$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: <a title='Open in client' href='mailto:contact@zoff.no?Subject=Contact%20Zoff&Body=" + message + "'>contact@zoff.no</a>");
|
$("#contact-container").html("Something went wrong, sorry about that. You could instead try with your own mail-client: <a title='Open in client' href='mailto:contact@zoff.no?Subject=Contact%20Zoff&Body=" + message + "'>contact@zoff.no</a>");
|
||||||
setTimeout(function(){newWindow.close();},500);*/
|
setTimeout(function(){newWindow.close();},500);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).on('submit', '#contact-form', function(e){
|
$(document).on('submit', '#contact-form', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var message = $("#contact-form-message").val();
|
var message = $("#contact-form-message").val();
|
||||||
var from = $("#contact-form-from").val();
|
var from = $("#contact-form-from").val();
|
||||||
|
|
||||||
Helper.send_mail(from, message);
|
Helper.send_mail(from, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Element.prototype.remove = function() {
|
Element.prototype.remove = function() {
|
||||||
this.parentElement.removeChild(this);
|
this.parentElement.removeChild(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
|
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
|
||||||
for(var i = 0, len = this.length; i < len; i++) {
|
for(var i = 0, len = this.length; i < len; i++) {
|
||||||
if(this[i] && this[i].parentElement) {
|
if(this[i] && this[i].parentElement) {
|
||||||
this[i].parentElement.removeChild(this[i]);
|
this[i].parentElement.removeChild(this[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
String.prototype.startsWith = function(searchString, position) {
|
String.prototype.startsWith = function(searchString, position) {
|
||||||
position = position || 0;
|
position = position || 0;
|
||||||
return this.indexOf(searchString, position) === position;
|
return this.indexOf(searchString, position) === position;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,65 +1,59 @@
|
|||||||
var Hostcontroller = {
|
var Hostcontroller = {
|
||||||
|
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
||||||
old_id: null,
|
old_id: null,
|
||||||
|
|
||||||
host_listener: function(id) {
|
host_listener: function(id) {
|
||||||
|
|
||||||
if(Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
if(Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
||||||
else
|
else {
|
||||||
{
|
socket.removeAllListeners(id);
|
||||||
socket.removeAllListeners(id);
|
began = false;
|
||||||
began = false;
|
Hostcontroller.old_id = id;
|
||||||
Hostcontroller.old_id = id;
|
}
|
||||||
}
|
var codeURL = "https://remote."+window.location.hostname+"/"+id;
|
||||||
var codeURL = "https://remote."+window.location.hostname+"/"+id;
|
$("#code-text").text(id);
|
||||||
$("#code-text").text(id);
|
$("#code-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
||||||
$("#code-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
$("#code-link").attr("href", codeURL);
|
||||||
$("#code-link").attr("href", codeURL);
|
if(!began) {
|
||||||
if(!began)
|
began = true;
|
||||||
{
|
setup_host_listener(id);
|
||||||
began = true;
|
}
|
||||||
setup_host_listener(id);
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
host_on_action: function(arr)
|
host_on_action: function(arr)
|
||||||
{
|
{
|
||||||
if(enabled){
|
if(enabled){
|
||||||
if(arr.type == "volume"){
|
if(arr.type == "volume") {
|
||||||
$("#volume").slider("value", arr.value);
|
$("#volume").slider("value", arr.value);
|
||||||
Player.player.setVolume(arr.value);
|
Player.player.setVolume(arr.value);
|
||||||
localStorage.setItem("volume", arr.value);
|
localStorage.setItem("volume", arr.value);
|
||||||
Playercontrols.choose_button(arr.value, false);
|
Playercontrols.choose_button(arr.value, false);
|
||||||
}else if(arr.type == "channel"){
|
} else if(arr.type == "channel") {
|
||||||
socket.emit("change_channel");
|
socket.emit("change_channel");
|
||||||
Admin.beginning = true;
|
Admin.beginning = true;
|
||||||
|
|
||||||
chan = arr.value.toLowerCase();
|
chan = arr.value.toLowerCase();
|
||||||
$("#chan").html(Helper.upperFirst(chan));
|
$("#chan").html(Helper.upperFirst(chan));
|
||||||
|
|
||||||
w_p = true;
|
w_p = true;
|
||||||
var add = "";
|
var add = "";
|
||||||
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
if(private_channel) add = Crypt.getCookie("_uI") + "_";
|
||||||
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
socket.emit("list", {channel: add + chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
|
|
||||||
/*if(Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) != ""){
|
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
|
||||||
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
} else if(arr.type == "pause") {
|
||||||
}*/
|
Player.pauseVideo();
|
||||||
|
} else if(arr.type == "play") {
|
||||||
|
Player.playVideo();
|
||||||
|
} else if(arr.type == "skip") {
|
||||||
|
List.skip();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
|
change_enabled:function(val){
|
||||||
}else if(arr.type == "pause")
|
enabled = val;
|
||||||
Player.pauseVideo();
|
document.getElementsByName("remote_switch")[0].checked = enabled;
|
||||||
else if(arr.type == "play")
|
}
|
||||||
Player.playVideo();
|
};
|
||||||
else if(arr.type == "skip")
|
|
||||||
List.skip();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
change_enabled:function(val){
|
|
||||||
enabled = val;
|
|
||||||
document.getElementsByName("remote_switch")[0].checked = enabled;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -40,16 +40,16 @@ var Mobile_remote = {
|
|||||||
|
|
||||||
initiate_volume: function() {
|
initiate_volume: function() {
|
||||||
$("#volume-control-remote").slider({
|
$("#volume-control-remote").slider({
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
value: 100,
|
value: 100,
|
||||||
range: "min",
|
range: "min",
|
||||||
animate: true,
|
animate: true,
|
||||||
stop:function(event, ui) {
|
stop:function(event, ui) {
|
||||||
socket.emit("id", {id: Mobile_remote.id, type: "volume", value: ui.value});
|
socket.emit("id", {id: Mobile_remote.id, type: "volume", value: ui.value});
|
||||||
Helper.log("volume");
|
Helper.log("volume");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,525 +1,495 @@
|
|||||||
var Player = {
|
var Player = {
|
||||||
|
|
||||||
loaded: true,
|
loaded: true,
|
||||||
before_load: "",
|
before_load: "",
|
||||||
after_load: "",
|
after_load: "",
|
||||||
player: "",
|
player: "",
|
||||||
stopInterval: false,
|
stopInterval: false,
|
||||||
fireplace: "",
|
fireplace: "",
|
||||||
|
|
||||||
youtube_listener: function(obj)
|
youtube_listener: function(obj)
|
||||||
{
|
{
|
||||||
var state;
|
var state;
|
||||||
try{
|
try{
|
||||||
state = Player.player.getPlayerState();
|
state = Player.player.getPlayerState();
|
||||||
}catch(e){
|
}catch(e){
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
if(((!offline && (state != null || from_frontpage)) || (offline && (!(state != null) || from_frontpage))|| (!offline && (!(state != null) || from_frontpage)) || (offline && state == -1)) && !(offline && prev_chan_player == chan)){
|
if(((!offline && (state != null || from_frontpage)) || (offline && (!(state != null) || from_frontpage))|| (!offline && (!(state != null) || from_frontpage)) || (offline && state == -1)) && !(offline && prev_chan_player == chan)){
|
||||||
prev_chan_player = chan;
|
prev_chan_player = chan;
|
||||||
from_frontpage = false;
|
from_frontpage = false;
|
||||||
Player.loaded = false;
|
Player.loaded = false;
|
||||||
Helper.log("--------youtube_listener--------");
|
Helper.log("--------youtube_listener--------");
|
||||||
Helper.log("Received: ");
|
Helper.log("Received: ");
|
||||||
Helper.log(obj);
|
Helper.log(obj);
|
||||||
Helper.log("paused variable: " + paused);
|
Helper.log("paused variable: " + paused);
|
||||||
Helper.log("mobile_beginning variable: " + mobile_beginning);
|
Helper.log("mobile_beginning variable: " + mobile_beginning);
|
||||||
try{
|
try{
|
||||||
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
Helper.log("video_id variable: " + video_id);
|
Helper.log("video_id variable: " + video_id);
|
||||||
Helper.log("---------------------------------");
|
Helper.log("---------------------------------");
|
||||||
if(!obj.np){
|
if(!obj.np){
|
||||||
|
|
||||||
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
||||||
//$("#player_overlay").height($("#player").height());
|
//$("#player_overlay").height($("#player").height());
|
||||||
|
|
||||||
if(!window.MSStream && !chromecastAvailable) $("#player_overlay").toggleClass("hide");
|
if(!window.MSStream && !chromecastAvailable) $("#player_overlay").toggleClass("hide");
|
||||||
try{
|
try{
|
||||||
if(!chromecastAvailable) Player.stopVideo();
|
if(!chromecastAvailable) Player.stopVideo();
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
//List.importOldList(channel.toLowerCase());
|
//List.importOldList(channel.toLowerCase());
|
||||||
} else if(paused){
|
} else if(paused){
|
||||||
Player.getTitle(obj.np[0].title, viewers);
|
Player.getTitle(obj.np[0].title, viewers);
|
||||||
//Player.setBGimage(video_id);
|
//Player.setBGimage(video_id);
|
||||||
if(!Helper.mobilecheck()) Player.notifyUser(obj.np[0].id, obj.np[0].title);
|
if(!Helper.mobilecheck()) Player.notifyUser(obj.np[0].id, obj.np[0].title);
|
||||||
if(!chromecastAvailable) Player.stopVideo();
|
if(!chromecastAvailable) Player.stopVideo();
|
||||||
video_id = obj.np[0].id;
|
video_id = obj.np[0].id;
|
||||||
conf = obj.conf[0];
|
conf = obj.conf[0];
|
||||||
time = obj.time;
|
time = obj.time;
|
||||||
seekTo = time - conf.startTime;
|
seekTo = time - conf.startTime;
|
||||||
song_title = obj.np[0].title;
|
song_title = obj.np[0].title;
|
||||||
duration = obj.np[0].duration;
|
duration = obj.np[0].duration;
|
||||||
Player.setBGimage(video_id);
|
Player.setBGimage(video_id);
|
||||||
}else if(!paused){
|
}else if(!paused){
|
||||||
//Helper.log("gotten new song");
|
//Helper.log("gotten new song");
|
||||||
if(previous_video_id === undefined)
|
if(previous_video_id === undefined)
|
||||||
previous_video_id = obj.np[0].id;
|
previous_video_id = obj.np[0].id;
|
||||||
else if(previous_video_id != video_id)
|
else if(previous_video_id != video_id)
|
||||||
previous_video_id = video_id;
|
previous_video_id = video_id;
|
||||||
|
|
||||||
video_id = obj.np[0].id;
|
video_id = obj.np[0].id;
|
||||||
conf = obj.conf[0];
|
conf = obj.conf[0];
|
||||||
time = obj.time;
|
time = obj.time;
|
||||||
seekTo = time - conf.startTime;
|
seekTo = time - conf.startTime;
|
||||||
song_title = obj.np[0].title;
|
song_title = obj.np[0].title;
|
||||||
duration = obj.np[0].duration;
|
duration = obj.np[0].duration;
|
||||||
|
|
||||||
if(mobile_beginning && Helper.mobilecheck() && seekTo === 0 && !chromecastAvailable)
|
if(mobile_beginning && Helper.mobilecheck() && seekTo === 0 && !chromecastAvailable)
|
||||||
seekTo = 1;
|
seekTo = 1;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(full_playlist[0].id == video_id && !mobile_beginning){
|
if(full_playlist[0].id == video_id && !mobile_beginning){
|
||||||
List.song_change(full_playlist[0].added);
|
List.song_change(full_playlist[0].added);
|
||||||
}
|
}
|
||||||
Suggestions.fetchYoutubeSuggests(video_id);
|
Suggestions.fetchYoutubeSuggests(video_id);
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
Player.setBGimage(video_id);
|
Player.setBGimage(video_id);
|
||||||
//if(player_ready && !Helper.mobilecheck())
|
//if(player_ready && !Helper.mobilecheck())
|
||||||
if(player_ready && !window.MSStream)
|
if(player_ready && !window.MSStream)
|
||||||
{
|
{
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if(Player.player.getVideoUrl().split('v=')[1] != video_id || chromecastAvailable){
|
if(Player.player.getVideoUrl().split('v=')[1] != video_id || chromecastAvailable){
|
||||||
Player.loadVideoById(video_id);
|
Player.loadVideoById(video_id);
|
||||||
if(!Helper.mobilecheck()) Player.notifyUser(video_id, song_title);
|
if(!Helper.mobilecheck()) Player.notifyUser(video_id, song_title);
|
||||||
Player.seekTo(seekTo);
|
Player.seekTo(seekTo);
|
||||||
if(paused && !chromecastAvailable){
|
if(paused && !chromecastAvailable){
|
||||||
Player.pauseVideo();
|
Player.pauseVideo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!paused){
|
if(!paused){
|
||||||
if(!mobile_beginning || chromecastAvailable)
|
if(!mobile_beginning || chromecastAvailable)
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
if(!durationBegun)
|
if(!durationBegun)
|
||||||
Player.durationSetter();
|
Player.durationSetter();
|
||||||
}
|
}
|
||||||
if(Player.player.getDuration() > seekTo || Player.player.getDuration() === 0 || chromecastAvailable || Player.player.getCurrentTime() != seekTo)
|
if(Player.player.getDuration() > seekTo || Player.player.getDuration() === 0 || chromecastAvailable || Player.player.getCurrentTime() != seekTo)
|
||||||
Player.seekTo(seekTo);
|
Player.seekTo(seekTo);
|
||||||
Player.after_load = video_id;
|
Player.after_load = video_id;
|
||||||
|
|
||||||
if(!Player.loaded) setTimeout(function(){Player.loaded = true;},500);
|
if(!Player.loaded) setTimeout(function(){Player.loaded = true;},500);
|
||||||
}catch(e){
|
}catch(e){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
Player.loadVideoById(video_id);
|
Player.loadVideoById(video_id);
|
||||||
Player.seekTo(seekTo);
|
Player.seekTo(seekTo);
|
||||||
}
|
}
|
||||||
if(!durationBegun && !chromecastAvailable)
|
if(!durationBegun && !chromecastAvailable)
|
||||||
Player.durationSetter();
|
Player.durationSetter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!durationBegun)
|
if(!durationBegun)
|
||||||
Player.durationSetter();
|
Player.durationSetter();
|
||||||
duration = Player.player.getDuration();
|
duration = Player.player.getDuration();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onPlayerStateChange: function(newState) {
|
onPlayerStateChange: function(newState) {
|
||||||
Helper.log("-------onPlayerStateChange------");
|
Helper.log("-------onPlayerStateChange------");
|
||||||
Helper.log("New state\nState: ");
|
Helper.log("New state\nState: ");
|
||||||
Helper.log(newState);
|
Helper.log(newState);
|
||||||
try{
|
try{
|
||||||
Helper.log("Duration: " + Player.player.getDuration(), "Current time: " + Player.player.getCurrentTime());
|
Helper.log("Duration: " + Player.player.getDuration(), "Current time: " + Player.player.getCurrentTime());
|
||||||
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
Helper.log("video_id variable: " + video_id);
|
Helper.log("video_id variable: " + video_id);
|
||||||
Helper.log("---------------------------------");
|
Helper.log("---------------------------------");
|
||||||
switch(newState.data)
|
switch(newState.data)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
playing = false;
|
playing = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
if(!offline){
|
if(!offline) {
|
||||||
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
socket.emit("end", {id: video_id, channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
Player.playNext();
|
Player.playNext();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
playing = true;
|
||||||
|
if(beginning && Helper.mobilecheck() && !chromecastAvailable){
|
||||||
|
Player.pauseVideo();
|
||||||
|
beginning = false;
|
||||||
|
mobile_beginning = false;
|
||||||
|
setTimeout(function(){
|
||||||
|
if(Helper.mobilecheck()){
|
||||||
|
$("#playpause").css("visibility", "visible");
|
||||||
|
$("#playpause").css("pointer-events", "all");
|
||||||
|
$("#channel-load").css("display", "none");
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
if(!embed && window.location.pathname != "/" && !chromecastAvailable) Helper.addClass("#player_overlay", "hide");
|
||||||
|
if(window.location.pathname != "/"){
|
||||||
|
if(document.getElementById("play").className.split(" ").length == 1)
|
||||||
|
$("#play").toggleClass("hide");
|
||||||
|
if(document.getElementById("pause").className.split(" ").length == 2)
|
||||||
|
$("#pause").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(paused && !offline) {
|
||||||
|
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if(!chromecastAvailable){
|
||||||
|
paused = true;
|
||||||
|
if(window.location.pathname != "/") Playercontrols.play_pause_show();
|
||||||
|
mobile_beginning = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
playing = true;
|
playVideo: function(){
|
||||||
if(beginning && Helper.mobilecheck() && !chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
Player.pauseVideo();
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "playVideo"});
|
||||||
beginning = false;
|
//socket.emit('pos', {channel: chan.toLowerCase()});
|
||||||
mobile_beginning = false;
|
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||||
setTimeout(function(){
|
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||||
if(Helper.mobilecheck()){
|
if($("#pause").hasClass("hide")){
|
||||||
$("#playpause").css("visibility", "visible");
|
$("#play").toggleClass("hide");
|
||||||
$("#playpause").css("pointer-events", "all");
|
$("#pause").toggleClass("hide");
|
||||||
$("#channel-load").css("display", "none");
|
}
|
||||||
}
|
//Playercontrols.play_pause();
|
||||||
}, 100);
|
} else {
|
||||||
}
|
Player.player.playVideo();
|
||||||
if(!embed && window.location.pathname != "/" && !chromecastAvailable) Helper.addClass("#player_overlay", "hide");
|
}
|
||||||
if(window.location.pathname != "/"){
|
},
|
||||||
if(document.getElementById("play").className.split(" ").length == 1)
|
|
||||||
$("#play").toggleClass("hide");
|
|
||||||
if(document.getElementById("pause").className.split(" ").length == 2)
|
|
||||||
$("#pause").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(paused && !offline)
|
|
||||||
{
|
|
||||||
socket.emit('pos', {channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
|
||||||
paused = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
/*if(Helper.mobilecheck() || embed)
|
|
||||||
{*/
|
|
||||||
if(!chromecastAvailable){
|
|
||||||
paused = true;
|
|
||||||
if(window.location.pathname != "/") Playercontrols.play_pause_show();
|
|
||||||
mobile_beginning = true;
|
|
||||||
}
|
|
||||||
/*}
|
|
||||||
else
|
|
||||||
Player.player.playVideo();*/
|
|
||||||
//
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
playVideo: function(){
|
pauseVideo: function(){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "playVideo"});
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "pauseVideo"});
|
||||||
//socket.emit('pos', {channel: chan.toLowerCase()});
|
if($("#play").hasClass("hide")){
|
||||||
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
$("#play").toggleClass("hide");
|
||||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
$("#pause").toggleClass("hide");
|
||||||
if($("#pause").hasClass("hide")){
|
}
|
||||||
$("#play").toggleClass("hide");
|
//Playercontrols.play_pause();
|
||||||
$("#pause").toggleClass("hide");
|
} else {
|
||||||
}
|
Player.player.pauseVideo();
|
||||||
//Playercontrols.play_pause();
|
}
|
||||||
} else {
|
},
|
||||||
Player.player.playVideo();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
pauseVideo: function(){
|
seekTo: function(_seekTo){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "pauseVideo"});
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "seekTo", seekTo: _seekTo});
|
||||||
if($("#play").hasClass("hide")){
|
} else if(!offline){
|
||||||
$("#play").toggleClass("hide");
|
Player.player.seekTo(_seekTo);
|
||||||
$("#pause").toggleClass("hide");
|
} else {
|
||||||
}
|
Player.player.seekTo(0);
|
||||||
//Playercontrols.play_pause();
|
}
|
||||||
} else {
|
},
|
||||||
Player.player.pauseVideo();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
seekTo: function(_seekTo){
|
loadVideoById: function(id){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "seekTo", seekTo: _seekTo});
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: id});
|
||||||
} else if(!offline){
|
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
|
||||||
Player.player.seekTo(_seekTo);
|
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
|
||||||
} else {
|
} else {
|
||||||
Player.player.seekTo(0);
|
Player.player.loadVideoById(id, 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadVideoById: function(id){
|
stopVideo: function(){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: id});
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "stopVideo"});
|
||||||
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
|
} else {
|
||||||
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
|
try{
|
||||||
} else {
|
Player.player.stopVideo();
|
||||||
Player.player.loadVideoById(id, 0);
|
} catch(e){}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
stopVideo: function(){
|
setVolume: function(vol){
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "stopVideo"});
|
castSession.setVolume(vol/100);
|
||||||
} else {
|
} else {
|
||||||
try{
|
Player.player.setVolume(vol);
|
||||||
Player.player.stopVideo();
|
}
|
||||||
} catch(e){}
|
},
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setVolume: function(vol){
|
playNext: function(){
|
||||||
if(chromecastAvailable){
|
var next_song = full_playlist[0];
|
||||||
castSession.setVolume(vol/100);
|
video_id = next_song.id;
|
||||||
} else {
|
time = (new Date()).getTime();
|
||||||
Player.player.setVolume(vol);
|
song_title = next_song.title;
|
||||||
}
|
duration = next_song.duration;
|
||||||
},
|
Player.getTitle(song_title, viewers);
|
||||||
|
Player.setBGimage(video_id);
|
||||||
|
if(chromecastAvailable){
|
||||||
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id});
|
||||||
|
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||||
|
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||||
|
} else {
|
||||||
|
Player.loadVideoById(video_id);
|
||||||
|
}
|
||||||
|
List.channel_function({type:"song_change", time: time});
|
||||||
|
},
|
||||||
|
|
||||||
playNext: function(){
|
sendNext: function(obj){
|
||||||
var next_song = full_playlist[0];
|
if(chromecastAvailable){
|
||||||
video_id = next_song.id;
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", title: obj.title, videoId: obj.videoId});
|
||||||
time = (new Date()).getTime();
|
}
|
||||||
song_title = next_song.title;
|
},
|
||||||
duration = next_song.duration;
|
|
||||||
Player.getTitle(song_title, viewers);
|
|
||||||
Player.setBGimage(video_id);
|
|
||||||
if(chromecastAvailable){
|
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id});
|
|
||||||
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
|
||||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
|
||||||
} else {
|
|
||||||
Player.loadVideoById(video_id);
|
|
||||||
}
|
|
||||||
List.channel_function({type:"song_change", time: time});
|
|
||||||
},
|
|
||||||
|
|
||||||
sendNext: function(obj){
|
getTitle: function(titt, v)
|
||||||
if(chromecastAvailable){
|
{
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", title: obj.title, videoId: obj.videoId});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
getTitle: function(titt, v)
|
var outPutWord = "<i class='material-icons'>visibility</i>"//v > 1 ? "viewers" : "viewer";
|
||||||
{
|
var title = decodeURIComponent(titt);
|
||||||
|
if(window.location.pathname != "/"){
|
||||||
|
var elem = document.getElementById('song-title');
|
||||||
|
var getTitleViews = document.getElementById('viewers');
|
||||||
|
|
||||||
var outPutWord = "<i class='material-icons'>visibility</i>"//v > 1 ? "viewers" : "viewer";
|
elem.innerHTML = title;
|
||||||
var title = decodeURIComponent(titt);
|
getTitleViews.innerHTML = outPutWord + " " + v;
|
||||||
if(window.location.pathname != "/"){
|
elem.title = title;
|
||||||
var elem = document.getElementById('song-title');
|
if(chromecastAvailable){
|
||||||
var getTitleViews = document.getElementById('viewers');
|
$("#player_overlay").css("background", "url(https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg)");
|
||||||
|
$("#player_overlay").css("background-position", "center");
|
||||||
|
$("#player_overlay").css("background-size", "100%");
|
||||||
|
$("#player_overlay").css("background-color", "black");
|
||||||
|
$("#player_overlay").css("background-repeat", "no-repeat");
|
||||||
|
//$("#player_overlay").css("height", "calc(100% - 32px)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.title = title + " • Zoff / "+chan;
|
||||||
|
|
||||||
elem.innerHTML = title;
|
},
|
||||||
getTitleViews.innerHTML = outPutWord + " " + v;
|
|
||||||
elem.title = title;
|
|
||||||
if(chromecastAvailable){
|
|
||||||
$("#player_overlay").css("background", "url(https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg)");
|
|
||||||
$("#player_overlay").css("background-position", "center");
|
|
||||||
$("#player_overlay").css("background-size", "100%");
|
|
||||||
$("#player_overlay").css("background-color", "black");
|
|
||||||
$("#player_overlay").css("background-repeat", "no-repeat");
|
|
||||||
//$("#player_overlay").css("height", "calc(100% - 32px)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
document.title = title + " • Zoff / "+chan;
|
|
||||||
|
|
||||||
},
|
errorHandler: function(newState) {
|
||||||
|
if(!user_auth_started) {
|
||||||
|
if(newState.data == 5 || newState.data == 100 || newState.data == 101 || newState.data == 150) {
|
||||||
|
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, userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
|
|
||||||
errorHandler: function(newState)
|
}else if(video_id !== undefined) {
|
||||||
{
|
Player.loadVideoById(video_id);
|
||||||
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=", "");
|
|
||||||
|
|
||||||
|
onPlayerReady: function(event) {
|
||||||
|
try{
|
||||||
|
beginning = true;
|
||||||
|
player_ready = true;
|
||||||
|
if(!window.MSStream) {
|
||||||
|
if(Helper.mobilecheck()){
|
||||||
|
$("#playpause").css("visibility", "hidden");
|
||||||
|
$("#playpause").css("pointer-events", "none");
|
||||||
|
} else {
|
||||||
|
$("#channel-load").css("display", "none");
|
||||||
|
}
|
||||||
|
$("#player").css("opacity", "1");
|
||||||
|
$("#controls").css("opacity", "1");
|
||||||
|
$(".playlist").css("opacity", "1");
|
||||||
|
Player.loadVideoById(video_id);
|
||||||
|
if(autoplay && (!Helper.mobilecheck() || chromecastAvailable))
|
||||||
|
Player.playVideo();
|
||||||
|
if(!durationBegun)
|
||||||
|
Player.durationSetter();
|
||||||
|
if(embed){
|
||||||
|
setTimeout(function(){
|
||||||
|
Player.player.seekTo(seekTo);
|
||||||
|
if(!autoplay){
|
||||||
|
Player.player.pauseVideo();
|
||||||
|
Playercontrols.play_pause_show();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}else
|
||||||
|
Player.seekTo(seekTo);
|
||||||
|
}
|
||||||
|
Player.readyLooks();
|
||||||
|
Playercontrols.initYoutubeControls(Player.player);
|
||||||
|
Playercontrols.initSlider();
|
||||||
|
Player.player.setVolume(Crypt.get_volume());
|
||||||
|
$(".video-container").removeClass("no-opacity");
|
||||||
|
}catch(e){}
|
||||||
|
},
|
||||||
|
|
||||||
socket.emit("skip", {error: newState.data, id: video_id, pass: adminpass, channel: chan.toLowerCase, userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
readyLooks: function()
|
||||||
//Helper.log(video_id, Player.player.getVideoUrl(), Player.player.getPlayerState());
|
{
|
||||||
|
Player.setBGimage(video_id);
|
||||||
|
},
|
||||||
|
|
||||||
/*}else{
|
setBGimage: function(id){
|
||||||
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) {
|
if(id !== undefined && !embed)
|
||||||
try{
|
{
|
||||||
beginning = true;
|
var img = new Image();
|
||||||
player_ready = true;
|
img.onload = function ()
|
||||||
if(!window.MSStream)
|
{
|
||||||
{
|
|
||||||
if(Helper.mobilecheck()){
|
|
||||||
$("#playpause").css("visibility", "hidden");
|
|
||||||
$("#playpause").css("pointer-events", "none");
|
|
||||||
} else {
|
|
||||||
$("#channel-load").css("display", "none");
|
|
||||||
}
|
|
||||||
$("#player").css("opacity", "1");
|
|
||||||
$("#controls").css("opacity", "1");
|
|
||||||
$(".playlist").css("opacity", "1");
|
|
||||||
Player.loadVideoById(video_id);
|
|
||||||
if(autoplay && (!Helper.mobilecheck() || chromecastAvailable))
|
|
||||||
Player.playVideo();
|
|
||||||
if(!durationBegun)
|
|
||||||
Player.durationSetter();
|
|
||||||
if(embed){
|
|
||||||
setTimeout(function(){
|
|
||||||
Player.player.seekTo(seekTo);
|
|
||||||
if(!autoplay){
|
|
||||||
Player.player.pauseVideo();
|
|
||||||
Playercontrols.play_pause_show();
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}else
|
|
||||||
Player.seekTo(seekTo);
|
|
||||||
}
|
|
||||||
Player.readyLooks();
|
|
||||||
Playercontrols.initYoutubeControls(Player.player);
|
|
||||||
Playercontrols.initSlider();
|
|
||||||
Player.player.setVolume(Crypt.get_volume());
|
|
||||||
$(".video-container").removeClass("no-opacity");
|
|
||||||
}catch(e){}
|
|
||||||
},
|
|
||||||
|
|
||||||
readyLooks: function()
|
var colorThief = new ColorThief();
|
||||||
{
|
var color = colorThief.getColor(img);
|
||||||
Player.setBGimage(video_id);
|
|
||||||
},
|
|
||||||
|
|
||||||
setBGimage: function(id){
|
if(window.location.pathname != "/"){
|
||||||
|
document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true);
|
||||||
|
$("meta[name=theme-color]").attr("content", Helper.rgbToHex(color[0], color[1], color[2]));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(id !== undefined && !embed)
|
img.crossOrigin = 'Anonymous';
|
||||||
{
|
img.src = 'https://zoff.me:8081/https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
|
||||||
var img = new Image();
|
}
|
||||||
img.onload = function ()
|
},
|
||||||
{
|
|
||||||
|
|
||||||
var colorThief = new ColorThief();
|
set_width: function(val){
|
||||||
var color = colorThief.getColor(img);
|
$(".video-container").width(val);
|
||||||
|
if(!Helper.mobilecheck()){
|
||||||
|
if($(window).width() > 769){
|
||||||
|
var test_against_width = $(window).width() - $(".control-list").width() - $(".zbrand").outerWidth() - $(".brand-logo-navigate").outerWidth() - 66;
|
||||||
|
title_width = test_against_width;
|
||||||
|
$(".title-container").width(title_width);
|
||||||
|
} else {
|
||||||
|
$(".title-container").width("100%");
|
||||||
|
}
|
||||||
|
|
||||||
if(window.location.pathname != "/"){
|
}
|
||||||
document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true);
|
},
|
||||||
$("meta[name=theme-color]").attr("content", Helper.rgbToHex(color[0], color[1], color[2]));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
img.crossOrigin = 'Anonymous';
|
notifyUser: function(id, title) {
|
||||||
img.src = 'https://zoff.me:8081/https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
|
title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||||
}
|
if (Notification.permission === "granted" && document.hidden) {
|
||||||
},
|
var notification = new Notification("Now Playing", {body: title, icon: "https://i.ytimg.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg"});
|
||||||
|
notification.onclick = function(x) { window.focus(); this.cancel(); };
|
||||||
|
setTimeout(function(){
|
||||||
|
notification.close();
|
||||||
|
},5000);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
set_width: function(val){
|
setup_all_listeners: function()
|
||||||
$(".video-container").width(val);
|
{
|
||||||
if(!Helper.mobilecheck()){
|
get_list_listener();
|
||||||
if($(window).width() > 769){
|
setup_youtube_listener();
|
||||||
var test_against_width = $(window).width() - $(".control-list").width() - $(".zbrand").outerWidth() - $(".brand-logo-navigate").outerWidth() - 66;
|
setup_admin_listener();
|
||||||
title_width = test_against_width;
|
setup_chat_listener();
|
||||||
$(".title-container").width(title_width);
|
setup_list_listener();
|
||||||
} else {
|
},
|
||||||
$(".title-container").width("100%");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
onYouTubeIframeAPIReady: function() {
|
||||||
},
|
Player.player = new YT.Player('player', {
|
||||||
|
videoId: video_id,
|
||||||
|
playerVars: { rel:"0", wmode:"transparent", controls: "0" , fs: "0", iv_load_policy: "3", theme:"light", color:"white", showinfo: 0},
|
||||||
|
events: {
|
||||||
|
'onReady': Player.onPlayerReady,
|
||||||
|
'onStateChange': Player.onPlayerStateChange,
|
||||||
|
'onError': Player.errorHandler
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Youtube.durationSetter();
|
||||||
|
},
|
||||||
|
|
||||||
notifyUser: function(id, title) {
|
createFireplacePlayer: function() {
|
||||||
title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
Player.fireplace = new YT.Player('fireplace_player', {
|
||||||
if (Notification.permission === "granted" && document.hidden) {
|
videoId: "L_LUpnjgPso",
|
||||||
var notification = new Notification("Now Playing", {body: title, icon: "https://i.ytimg.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg"});
|
playerVars: { rel:"0", wmode:"transparent", controls: "0" , fs: "0", iv_load_policy: "3", theme:"light", color:"white", showinfo: 0},
|
||||||
notification.onclick = function(x) { window.focus(); this.cancel(); };
|
events: {
|
||||||
setTimeout(function(){
|
'onReady': Player.onFireplaceReady,
|
||||||
notification.close();
|
'onStateChange': Player.onFireplaceChange
|
||||||
},5000);
|
}
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setup_all_listeners: function()
|
onFireplaceReady: function() {
|
||||||
{
|
Player.fireplace.playVideo();
|
||||||
get_list_listener();
|
},
|
||||||
setup_youtube_listener();
|
|
||||||
setup_admin_listener();
|
|
||||||
setup_chat_listener();
|
|
||||||
setup_list_listener();
|
|
||||||
},
|
|
||||||
|
|
||||||
onYouTubeIframeAPIReady: function() {
|
onFireplaceChange: function(newState) {
|
||||||
Player.player = new YT.Player('player', {
|
switch(newState.data) {
|
||||||
videoId: video_id,
|
case 0:
|
||||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , fs: "0", iv_load_policy: "3", theme:"light", color:"white", showinfo: 0},
|
Player.fireplace.seekTo(0);
|
||||||
events: {
|
Player.fireplace.playVideo();
|
||||||
'onReady': Player.onPlayerReady,
|
break;
|
||||||
'onStateChange': Player.onPlayerStateChange,
|
case 2:
|
||||||
'onError': Player.errorHandler
|
Player.fireplace.playVideo();
|
||||||
}
|
break;
|
||||||
});
|
}
|
||||||
//Youtube.durationSetter();
|
},
|
||||||
},
|
|
||||||
|
|
||||||
createFireplacePlayer: function() {
|
durationSetter: function()
|
||||||
Player.fireplace = new YT.Player('fireplace_player', {
|
{
|
||||||
videoId: "L_LUpnjgPso",
|
try{
|
||||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , fs: "0", iv_load_policy: "3", theme:"light", color:"white", showinfo: 0},
|
if(!user_auth_avoid && duration !== undefined){
|
||||||
events: {
|
|
||||||
'onReady': Player.onFireplaceReady,
|
|
||||||
'onStateChange': Player.onFireplaceChange
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onFireplaceReady: function() {
|
if(!Player.stopInterval) durationBegun = true;
|
||||||
Player.fireplace.playVideo();
|
dMinutes = Math.floor(duration / 60);
|
||||||
},
|
dSeconds = duration - dMinutes * 60;
|
||||||
|
currDurr = Player.player.getCurrentTime() !== undefined ? Math.floor(Player.player.getCurrentTime()) : seekTo;
|
||||||
|
if(currDurr > duration)
|
||||||
|
currDurr = duration;
|
||||||
|
minutes = Math.floor(currDurr / 60);
|
||||||
|
seconds = currDurr - (minutes * 60);
|
||||||
|
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
|
||||||
|
per = (100 / duration) * currDurr;
|
||||||
|
if(per >= 100)
|
||||||
|
per = 100;
|
||||||
|
else if(duration === 0)
|
||||||
|
per = 0;
|
||||||
|
|
||||||
onFireplaceChange: function(newState) {
|
if(!dragging) $("#bar").width(per+"%");
|
||||||
switch(newState.data) {
|
|
||||||
case 0:
|
|
||||||
Player.fireplace.seekTo(0);
|
|
||||||
Player.fireplace.playVideo();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Player.fireplace.playVideo();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
durationSetter: function()
|
}
|
||||||
{
|
}catch(e){
|
||||||
/*try{
|
|
||||||
//duration = Player.player.getDuration();
|
|
||||||
}catch(e){};*/
|
|
||||||
try{
|
|
||||||
if(!user_auth_avoid && duration !== undefined){
|
|
||||||
|
|
||||||
if(!Player.stopInterval) durationBegun = true;
|
}
|
||||||
dMinutes = Math.floor(duration / 60);
|
if(!Player.stopInterval) setTimeout(Player.durationSetter, 1000);
|
||||||
dSeconds = duration - dMinutes * 60;
|
},
|
||||||
currDurr = Player.player.getCurrentTime() !== undefined ? Math.floor(Player.player.getCurrentTime()) : seekTo;
|
|
||||||
if(currDurr > duration)
|
|
||||||
currDurr = duration;
|
|
||||||
minutes = Math.floor(currDurr / 60);
|
|
||||||
seconds = currDurr - (minutes * 60);
|
|
||||||
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
|
|
||||||
per = (100 / duration) * currDurr;
|
|
||||||
if(per >= 100)
|
|
||||||
per = 100;
|
|
||||||
else if(duration === 0)
|
|
||||||
per = 0;
|
|
||||||
|
|
||||||
if(!dragging) $("#bar").width(per+"%");
|
loadPlayer: function() {
|
||||||
|
if($("script[src='https://www.youtube.com/iframe_api']").length == 1){
|
||||||
}
|
try{
|
||||||
}catch(e){
|
Player.onYouTubeIframeAPIReady();
|
||||||
|
} catch(error){
|
||||||
}
|
console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.");
|
||||||
if(!Player.stopInterval) setTimeout(Player.durationSetter, 1000);
|
}
|
||||||
},
|
} else {
|
||||||
|
tag = document.createElement('script');
|
||||||
loadPlayer: function() {
|
tag.src = "https://www.youtube.com/iframe_api";
|
||||||
if($("script[src='https://www.youtube.com/iframe_api']").length == 1){
|
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||||
try{
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||||
Player.onYouTubeIframeAPIReady();
|
}
|
||||||
} catch(error){
|
}
|
||||||
console.error("Seems YouTube iFrame script isn't correctly loaded. Please reload the page.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tag = document.createElement('script');
|
|
||||||
tag.src = "https://www.youtube.com/iframe_api";
|
|
||||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
|
||||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,252 +1,251 @@
|
|||||||
var Playercontrols = {
|
var Playercontrols = {
|
||||||
|
|
||||||
stopInterval: false,
|
stopInterval: false,
|
||||||
|
|
||||||
initYoutubeControls: function()
|
initYoutubeControls: function()
|
||||||
{
|
{
|
||||||
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
if(Helper.mobilecheck() && !window.MSStream){
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
$("#controls").appendTo("#playbar");
|
||||||
$("#controls").appendTo("#playbar");
|
}
|
||||||
}
|
Playercontrols.initControls();
|
||||||
Playercontrols.initControls();
|
},
|
||||||
},
|
|
||||||
|
|
||||||
initControls: function()
|
initControls: function()
|
||||||
{
|
{
|
||||||
document.getElementById("volume-button").addEventListener("click", Playercontrols.mute_video);
|
document.getElementById("volume-button").addEventListener("click", Playercontrols.mute_video);
|
||||||
document.getElementById("playpause").addEventListener("click", Playercontrols.play_pause);
|
document.getElementById("playpause").addEventListener("click", Playercontrols.play_pause);
|
||||||
document.getElementById("volume-button-overlay").addEventListener("click", Playercontrols.mute_video);
|
document.getElementById("volume-button-overlay").addEventListener("click", Playercontrols.mute_video);
|
||||||
document.getElementById("playpause-overlay").addEventListener("click", Playercontrols.play_pause);
|
document.getElementById("playpause-overlay").addEventListener("click", Playercontrols.play_pause);
|
||||||
document.getElementById("fullscreen").addEventListener("click", Playercontrols.fullscreen);
|
document.getElementById("fullscreen").addEventListener("click", Playercontrols.fullscreen);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initSlider: function()
|
initSlider: function()
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
vol = (Crypt.get_volume());
|
vol = (Crypt.get_volume());
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
$("#volume").slider({
|
$("#volume").slider({
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
value: vol,
|
value: vol,
|
||||||
range: "min",
|
range: "min",
|
||||||
animate: true,
|
animate: true,
|
||||||
slide: function(event, ui) {
|
slide: function(event, ui) {
|
||||||
|
|
||||||
Playercontrols.setVolume(ui.value);
|
Playercontrols.setVolume(ui.value);
|
||||||
//localStorage.setItem("volume", ui.value);
|
//localStorage.setItem("volume", ui.value);
|
||||||
try{Crypt.set_volume(ui.value);}catch(e){}
|
try{Crypt.set_volume(ui.value);}catch(e){}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Playercontrols.choose_button(vol, false);
|
Playercontrols.choose_button(vol, false);
|
||||||
//$("#volume").slider("value", player.getVolume());
|
//$("#volume").slider("value", player.getVolume());
|
||||||
},
|
},
|
||||||
|
|
||||||
fullscreen: function()
|
fullscreen: function()
|
||||||
{
|
{
|
||||||
var playerElement = document.getElementById("player");
|
var playerElement = document.getElementById("player");
|
||||||
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
||||||
if (requestFullScreen) {
|
if (requestFullScreen) {
|
||||||
requestFullScreen.bind(playerElement)();
|
requestFullScreen.bind(playerElement)();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
play_pause: function()
|
play_pause: function()
|
||||||
{
|
{
|
||||||
if(!chromecastAvailable){
|
if(!chromecastAvailable){
|
||||||
if(Player.player.getPlayerState() == 1)
|
if(Player.player.getPlayerState() == 1)
|
||||||
{
|
{
|
||||||
Player.pauseVideo();
|
Player.pauseVideo();
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
if(Helper.mobilecheck() && !window.MSStream){
|
||||||
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||||
document.getElementById("player").style.display = "none";
|
document.getElementById("player").style.display = "none";
|
||||||
$(".video-container").toggleClass("click-through");
|
$(".video-container").toggleClass("click-through");
|
||||||
$(".page-footer").toggleClass("padding-bottom-extra");
|
$(".page-footer").toggleClass("padding-bottom-extra");
|
||||||
}
|
}
|
||||||
} else if(Player.player.getPlayerState() == 2 || Player.player.getPlayerState() === 0 || (Player.player.getPlayerState() === 5 && Helper.mobilecheck())){
|
} else if(Player.player.getPlayerState() == 2 || Player.player.getPlayerState() === 0 || (Player.player.getPlayerState() === 5 && Helper.mobilecheck())){
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
if(Helper.mobilecheck() && !window.MSStream){
|
||||||
document.getElementById("player").style.display = "block";
|
document.getElementById("player").style.display = "block";
|
||||||
$(".video-container").toggleClass("click-through");
|
$(".video-container").toggleClass("click-through");
|
||||||
$(".page-footer").toggleClass("padding-bottom-extra");
|
$(".page-footer").toggleClass("padding-bottom-extra");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Playercontrols.play_pause_show();
|
Playercontrols.play_pause_show();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
play_pause_show: function()
|
play_pause_show: function()
|
||||||
{
|
{
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
if($("#play").hasClass("hide")){
|
if($("#play").hasClass("hide")){
|
||||||
Player.pauseVideo();
|
Player.pauseVideo();
|
||||||
} else if($("#pause").hasClass("hide")){
|
} else if($("#pause").hasClass("hide")){
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(document.getElementById("pause").className.split(" ").length == 1){
|
if(document.getElementById("pause").className.split(" ").length == 1){
|
||||||
$("#pause").toggleClass("hide");
|
$("#pause").toggleClass("hide");
|
||||||
$("#pause-overlay").toggleClass("hide");
|
$("#pause-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("play").className.split(" ").length == 2){
|
if(document.getElementById("play").className.split(" ").length == 2){
|
||||||
$("#play").toggleClass("hide");
|
$("#play").toggleClass("hide");
|
||||||
$("#play-overlay").toggleClass("hide");
|
$("#play-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
settings: function()
|
settings: function()
|
||||||
{
|
{
|
||||||
$("#qS").toggleClass("hide");
|
$("#qS").toggleClass("hide");
|
||||||
},
|
},
|
||||||
|
|
||||||
changeQuality: function(wantedQ)
|
changeQuality: function(wantedQ)
|
||||||
{
|
{
|
||||||
if(Player.player.getPlaybackQuality != wantedQ)
|
if(Player.player.getPlaybackQuality != wantedQ)
|
||||||
{
|
{
|
||||||
Player.player.setPlaybackQuality(wantedQ);
|
Player.player.setPlaybackQuality(wantedQ);
|
||||||
Player.player.getPlaybackQuality();
|
Player.player.getPlaybackQuality();
|
||||||
}
|
}
|
||||||
$("#qS").toggleClass("hide");
|
$("#qS").toggleClass("hide");
|
||||||
},
|
},
|
||||||
|
|
||||||
mute_video: function()
|
mute_video: function()
|
||||||
{
|
{
|
||||||
if(!Player.player.isMuted())
|
if(!Player.player.isMuted())
|
||||||
{
|
{
|
||||||
if(chromecastAvailable) castSession.sendMessage("urn:x-cast:zoff.me", {type: "mute"});
|
if(chromecastAvailable) castSession.sendMessage("urn:x-cast:zoff.me", {type: "mute"});
|
||||||
Playercontrols.choose_button(0, true);
|
Playercontrols.choose_button(0, true);
|
||||||
Player.player.mute();
|
Player.player.mute();
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if(chromecastAvailable)castSession.sendMessage("urn:x-cast:zoff.me", {type: "unMute"});
|
if(chromecastAvailable)castSession.sendMessage("urn:x-cast:zoff.me", {type: "unMute"});
|
||||||
Player.player.unMute();
|
Player.player.unMute();
|
||||||
Playercontrols.choose_button(Player.player.getVolume(), false);
|
Playercontrols.choose_button(Player.player.getVolume(), false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setVolume: function(vol)
|
setVolume: function(vol)
|
||||||
{
|
{
|
||||||
Player.setVolume(vol);
|
Player.setVolume(vol);
|
||||||
Playercontrols.choose_button(vol, false);
|
Playercontrols.choose_button(vol, false);
|
||||||
if(Player.player.isMuted())
|
if(Player.player.isMuted())
|
||||||
Player.player.unMute();
|
Player.player.unMute();
|
||||||
},
|
},
|
||||||
|
|
||||||
choose_button: function(vol, mute)
|
choose_button: function(vol, mute)
|
||||||
{
|
{
|
||||||
if(!mute){
|
if(!mute){
|
||||||
if(vol >= 0 && vol <= 33){
|
if(vol >= 0 && vol <= 33){
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
if(document.getElementById("v-full").className.split(" ").length == 1){
|
||||||
$("#v-full").toggleClass("hide");
|
$("#v-full").toggleClass("hide");
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
||||||
$("#v-medium").toggleClass("hide");
|
$("#v-medium").toggleClass("hide");
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 2){
|
if(document.getElementById("v-low").className.split(" ").length == 2){
|
||||||
$("#v-low").toggleClass("hide");
|
$("#v-low").toggleClass("hide");
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
||||||
$("#v-mute").toggleClass("hide");
|
$("#v-mute").toggleClass("hide");
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
}else if(vol >= 34 && vol <= 66){
|
}else if(vol >= 34 && vol <= 66){
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
if(document.getElementById("v-full").className.split(" ").length == 1){
|
||||||
$("#v-full").toggleClass("hide");
|
$("#v-full").toggleClass("hide");
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 2){
|
if(document.getElementById("v-medium").className.split(" ").length == 2){
|
||||||
$("#v-medium").toggleClass("hide");
|
$("#v-medium").toggleClass("hide");
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
if(document.getElementById("v-low").className.split(" ").length == 1){
|
||||||
$("#v-low").toggleClass("hide");
|
$("#v-low").toggleClass("hide");
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
||||||
$("#v-mute").toggleClass("hide");
|
$("#v-mute").toggleClass("hide");
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
}else if(vol >= 67 && vol <= 100){
|
}else if(vol >= 67 && vol <= 100){
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 2){
|
if(document.getElementById("v-full").className.split(" ").length == 2){
|
||||||
$("#v-full").toggleClass("hide");
|
$("#v-full").toggleClass("hide");
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
||||||
$("#v-medium").toggleClass("hide");
|
$("#v-medium").toggleClass("hide");
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
if(document.getElementById("v-low").className.split(" ").length == 1){
|
||||||
$("#v-low").toggleClass("hide");
|
$("#v-low").toggleClass("hide");
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
||||||
$("#v-mute").toggleClass("hide");
|
$("#v-mute").toggleClass("hide");
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
if(document.getElementById("v-full").className.split(" ").length == 1){
|
||||||
$("#v-full").toggleClass("hide");
|
$("#v-full").toggleClass("hide");
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
||||||
$("#v-medium").toggleClass("hide");
|
$("#v-medium").toggleClass("hide");
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
if(document.getElementById("v-low").className.split(" ").length == 1){
|
||||||
$("#v-low").toggleClass("hide");
|
$("#v-low").toggleClass("hide");
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 2){
|
if(document.getElementById("v-mute").className.split(" ").length == 2){
|
||||||
$("#v-mute").toggleClass("hide");
|
$("#v-mute").toggleClass("hide");
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
playPause: function()
|
playPause: function()
|
||||||
{
|
{
|
||||||
state = Player.player.getPlayerState();
|
state = Player.player.getPlayerState();
|
||||||
button = document.getElementById("playpause");
|
button = document.getElementById("playpause");
|
||||||
if(state == 1)
|
if(state == 1)
|
||||||
{
|
{
|
||||||
Player.pauseVideo();
|
Player.pauseVideo();
|
||||||
}else if(state == 2)
|
}else if(state == 2)
|
||||||
{
|
{
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
volumeOptions: function()
|
volumeOptions: function()
|
||||||
{
|
{
|
||||||
if(!chromecastAvailable){
|
if(!chromecastAvailable){
|
||||||
if(Player.player.isMuted())
|
if(Player.player.isMuted())
|
||||||
{
|
{
|
||||||
Player.player.unMute();
|
Player.player.unMute();
|
||||||
vol = Player.player.getVolume();
|
vol = Player.player.getVolume();
|
||||||
$("#volume").slider("value", Player.player.getVolume());
|
$("#volume").slider("value", Player.player.getVolume());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Player.player.mute();
|
Player.player.mute();
|
||||||
$("#volume").slider("value", 0);
|
$("#volume").slider("value", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hoverMute: function(foo)
|
hoverMute: function(foo)
|
||||||
{
|
{
|
||||||
vol = Player.player.getVolume();
|
vol = Player.player.getVolume();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,120 +1,110 @@
|
|||||||
var start = true;
|
var start = true;
|
||||||
|
|
||||||
mobilecheck = function() {
|
mobilecheck = function() {
|
||||||
var check = false;
|
var check = false;
|
||||||
(function(a){if(/(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(a)||/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(a.substr(0,4)))check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
(function(a){if(/(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(a)||/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(a.substr(0,4)))check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
||||||
return check;
|
return check;
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function (){
|
$(document).ready(function (){
|
||||||
document.title = "Zoff Remote";
|
document.title = "Zoff Remote";
|
||||||
setTimeout(function(){$("#search").focus();},500);
|
setTimeout(function(){$("#search").focus();},500);
|
||||||
var connection_options = {
|
var connection_options = {
|
||||||
'sync disconnect on unload':true,
|
'sync disconnect on unload':true,
|
||||||
'secure': true
|
'secure': true
|
||||||
};
|
};
|
||||||
|
|
||||||
$("#about").modal();
|
$("#about").modal();
|
||||||
$("#contact").modal();
|
$("#contact").modal();
|
||||||
|
|
||||||
if(window.location.hostname == "remote.zoff.me") add = "https://zoff.me";
|
if(window.location.hostname == "remote.zoff.me") add = "https://zoff.me";
|
||||||
else add = "localhost";
|
else add = "localhost";
|
||||||
socket = io.connect(add+':8080', connection_options);
|
socket = io.connect(add+':8080', connection_options);
|
||||||
socket.on('update_required', function() {
|
socket.on('update_required', function() {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
});
|
});
|
||||||
id = window.location.pathname.split("/")[1];
|
id = window.location.pathname.split("/")[1];
|
||||||
if(id)
|
if(id)
|
||||||
{
|
{
|
||||||
id = id.toLowerCase();
|
id = id.toLowerCase();
|
||||||
Remotecontroller.control();
|
Remotecontroller.control();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
git_info = $.ajax({ type: "GET",
|
git_info = $.ajax({
|
||||||
url: "https://api.github.com/users/zoff-music/received_events",
|
type: "GET",
|
||||||
async: false
|
url: "https://api.github.com/users/zoff-music/received_events",
|
||||||
}).responseText;
|
async: false
|
||||||
|
}).responseText;
|
||||||
|
|
||||||
git_info = $.parseJSON(git_info);
|
git_info = $.parseJSON(git_info);
|
||||||
$("#latest-commit").html("Latest Commit: <br>" +
|
$("#latest-commit").html("Latest Commit: <br>" +
|
||||||
git_info[0].created_at.substring(0,10) +
|
git_info[0].created_at.substring(0,10) +
|
||||||
": " + git_info[0].actor.display_login +
|
": " + 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'>" +
|
"<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].sha.substring(0,10) + "</a>: " +
|
||||||
git_info[0].payload.commits[0].message+"<br");
|
git_info[0].payload.commits[0].message+"<br");
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", "#playbutton", function()
|
$(document).on("click", "#playbutton", function()
|
||||||
{
|
{
|
||||||
socket.emit("id", {id: id, type: "play", value: "mock"});
|
socket.emit("id", {id: id, type: "play", value: "mock"});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", "#pausebutton", function()
|
$(document).on("click", "#pausebutton", function()
|
||||||
{
|
{
|
||||||
socket.emit("id", {id: id, type: "pause", value: "mock"});
|
socket.emit("id", {id: id, type: "pause", value: "mock"});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", "#skipbutton", function()
|
$(document).on("click", "#skipbutton", function()
|
||||||
{
|
{
|
||||||
socket.emit("id", {id: id, type: "skip", value: "mock"});
|
socket.emit("id", {id: id, type: "skip", value: "mock"});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("submit", "#remoteform", function(e)
|
$(document).on("submit", "#remoteform", function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
/*
|
Remotecontroller.control();
|
||||||
if(start)
|
|
||||||
window.location.href = '/remote/'+document.getElementById("remoteform").chan.value;
|
|
||||||
else
|
|
||||||
Remotecontroller.control();
|
|
||||||
*/
|
|
||||||
Remotecontroller.control();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var Remotecontroller = {
|
var Remotecontroller = {
|
||||||
|
|
||||||
control: function()
|
control: function()
|
||||||
{
|
{
|
||||||
if(start)
|
if(start)
|
||||||
{
|
{
|
||||||
if(!id)
|
if(!id)
|
||||||
{
|
{
|
||||||
id = document.getElementById("remoteform").chan.value;
|
id = document.getElementById("remoteform").chan.value;
|
||||||
window.history.pushState("object or string", "Title", "/"+id);
|
window.history.pushState("object or string", "Title", "/"+id);
|
||||||
}
|
}
|
||||||
document.getElementById("remoteform").chan.value = "";
|
document.getElementById("remoteform").chan.value = "";
|
||||||
start = false;
|
start = false;
|
||||||
|
|
||||||
$(".rc").css("display", "block");
|
$(".rc").css("display", "block");
|
||||||
|
|
||||||
//document.getElementById("base").setAttribute("onsubmit", "control(); return false;");
|
//document.getElementById("base").setAttribute("onsubmit", "control(); return false;");
|
||||||
$("#remote-text").text("Controlling "+ id.toUpperCase());
|
$("#remote-text").text("Controlling "+ id.toUpperCase());
|
||||||
document.getElementById("search").setAttribute("length", "18");
|
document.getElementById("search").setAttribute("length", "18");
|
||||||
document.getElementById("search").setAttribute("maxlength", "18");
|
document.getElementById("search").setAttribute("maxlength", "18");
|
||||||
$("#forsearch").html("Type new channel name to change to");
|
$("#forsearch").html("Type new channel name to change to");
|
||||||
|
|
||||||
$("#volume-control").slider({
|
$("#volume-control").slider({
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
value: 100,
|
value: 100,
|
||||||
range: "min",
|
range: "min",
|
||||||
animate: true,
|
animate: true,
|
||||||
/*slide: function(event, ui) {
|
stop:function(event, ui) {
|
||||||
Helper.log(ui.value);
|
socket.emit("id", {id: id, type: "volume", value: ui.value});
|
||||||
//localStorage.setItem("volume", ui.value);
|
}
|
||||||
},*/
|
});
|
||||||
stop:function(event, ui) {
|
}else
|
||||||
socket.emit("id", {id: id, type: "volume", value: ui.value});
|
{
|
||||||
}
|
socket.emit("id", {id: id, type: "channel", value: $("#search").val().toLowerCase()});
|
||||||
});
|
$("#search").val("");
|
||||||
}else
|
}
|
||||||
{
|
|
||||||
socket.emit("id", {id: id, type: "channel", value: $("#search").val().toLowerCase()});
|
|
||||||
$("#search").val("");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,421 +1,400 @@
|
|||||||
var Search = {
|
var Search = {
|
||||||
|
|
||||||
submitArray: [],
|
submitArray: [],
|
||||||
submitArrayExpected: null,
|
submitArrayExpected: null,
|
||||||
|
|
||||||
showSearch: function(){
|
showSearch: function(){
|
||||||
$("#search-wrapper").toggleClass("hide");
|
$("#search-wrapper").toggleClass("hide");
|
||||||
if(Helper.mobilecheck())
|
if(Helper.mobilecheck())
|
||||||
{
|
{
|
||||||
$(".search_input").focus();
|
$(".search_input").focus();
|
||||||
}
|
}
|
||||||
$("#song-title").toggleClass("hide");
|
$("#song-title").toggleClass("hide");
|
||||||
//$("#results").toggleClass("hide");
|
$("#results").empty();
|
||||||
$("#results").empty();
|
if($("#search-btn i").html() == "close"){
|
||||||
if($("#search-btn i").html() == "close"){
|
$("#search-btn i").html("search");
|
||||||
$("#search-btn i").html("search");
|
} else {
|
||||||
} else {
|
$("#search-btn i").html("close");
|
||||||
$("#search-btn i").html("close");
|
}
|
||||||
}
|
$("#search").focus();
|
||||||
//$("#search-btn i").html("search");
|
|
||||||
$("#search").focus();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
search: function(search_input){
|
search: function(search_input){
|
||||||
if(result_html === undefined || empty_results_html === undefined) {
|
if(result_html === undefined || empty_results_html === undefined) {
|
||||||
result_html = $("#temp-results-container");
|
result_html = $("#temp-results-container");
|
||||||
empty_results_html = $("#empty-results-container").html();
|
empty_results_html = $("#empty-results-container").html();
|
||||||
}
|
}
|
||||||
$(".search_results").html('');
|
$(".search_results").html('');
|
||||||
if(search_input !== ""){
|
if(search_input !== ""){
|
||||||
searching = true;
|
searching = true;
|
||||||
var keyword= encodeURIComponent(search_input);
|
var keyword= encodeURIComponent(search_input);
|
||||||
//response= x
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id&fields=items(id)&type=video&order=viewCount&safeSearch=none&maxResults=25";
|
yt_url+="&q="+keyword;
|
||||||
yt_url+="&q="+keyword;
|
if(music)yt_url+="&videoCategoryId=10";
|
||||||
if(music)yt_url+="&videoCategoryId=10";
|
|
||||||
|
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
|
|
||||||
if(!Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
if(!Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
||||||
$(".search_loader_spinner").addClass("active");
|
$(".search_loader_spinner").addClass("active");
|
||||||
|
|
||||||
if(Helper.contains($("#results").attr("class").split(" "), "hide"))
|
if(Helper.contains($("#results").attr("class").split(" "), "hide"))
|
||||||
$("#results").removeClass("hide");
|
$("#results").removeClass("hide");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: yt_url,
|
url: yt_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
if(response.items.length === 0)
|
if(response.items.length === 0) {
|
||||||
{
|
|
||||||
|
|
||||||
$("<div style='display:none;' id='mock-div'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
$("<div style='display:none;' id='mock-div'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
||||||
if(Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
if(Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
||||||
$(".search_loader_spinner").removeClass("active");
|
$(".search_loader_spinner").removeClass("active");
|
||||||
|
|
||||||
}else if(response.items){
|
} else if(response.items){
|
||||||
//get list of IDs and make new request for video info
|
$.each(response.items, function(i,data) {
|
||||||
$.each(response.items, function(i,data)
|
vid_url += data.id.videoId+",";
|
||||||
{
|
});
|
||||||
vid_url += data.id.videoId+",";
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: vid_url,
|
url: vid_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
|
||||||
var output = "";
|
var output = "";
|
||||||
var pre_result = $(result_html);
|
var pre_result = $(result_html);
|
||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
|
|
||||||
$.each(response.items, function(i,song)
|
$.each(response.items, function(i,song)
|
||||||
{
|
{
|
||||||
var duration=song.contentDetails.duration;
|
var duration=song.contentDetails.duration;
|
||||||
secs=Search.durationToSeconds(duration);
|
secs=Search.durationToSeconds(duration);
|
||||||
if(!longsongs || secs<720){
|
if(!longsongs || secs<720){
|
||||||
title=song.snippet.title;
|
title=song.snippet.title;
|
||||||
enc_title=title;//encodeURIComponent(title).replace(/'/g, "\\\'");
|
enc_title=title;//encodeURIComponent(title).replace(/'/g, "\\\'");
|
||||||
id=song.id;
|
id=song.id;
|
||||||
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
||||||
thumb=song.snippet.thumbnails.medium.url;
|
thumb=song.snippet.thumbnails.medium.url;
|
||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
var songs = pre_result;
|
var songs = pre_result;
|
||||||
|
|
||||||
songs.find(".search-title").text(title);
|
songs.find(".search-title").text(title);
|
||||||
songs.find(".result_info").text(duration);
|
songs.find(".result_info").text(duration);
|
||||||
songs.find(".thumb").attr("src", thumb);
|
songs.find(".thumb").attr("src", thumb);
|
||||||
//songs.find(".add-many").attr("onclick", "submit('"+id+"','"+enc_title+"',"+secs+");");
|
//songs.find(".add-many").attr("onclick", "submit('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
songs.find("#add-many").attr("data-video-id", id);
|
songs.find("#add-many").attr("data-video-id", id);
|
||||||
songs.find("#add-many").attr("data-video-title", enc_title);
|
songs.find("#add-many").attr("data-video-title", enc_title);
|
||||||
songs.find("#add-many").attr("data-video-length", secs);
|
songs.find("#add-many").attr("data-video-length", secs);
|
||||||
//$($(songs).find("div")[0]).attr("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
//$($(songs).find("div")[0]).attr("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
songs.find("#temp-results").attr("data-video-id", id);
|
songs.find("#temp-results").attr("data-video-id", id);
|
||||||
songs.find("#temp-results").attr("data-video-title", enc_title);
|
songs.find("#temp-results").attr("data-video-title", enc_title);
|
||||||
songs.find("#temp-results").attr("data-video-length", secs);
|
songs.find("#temp-results").attr("data-video-length", secs);
|
||||||
//$($(songs).find("div")[0]).attr("id", id)
|
//$($(songs).find("div")[0]).attr("id", id)
|
||||||
output += songs.html();
|
output += songs.html();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("<div style='display:none;' id='mock-div'>"+output+"</div>").appendTo($("#results")).show("blind", (response.items.length-1) * 83.33);
|
$("<div style='display:none;' id='mock-div'>"+output+"</div>").appendTo($("#results")).show("blind", (response.items.length-1) * 83.33);
|
||||||
|
|
||||||
//setTimeout(function(){$(".thumb").lazyload({container: $("#results")});}, 250);
|
//setTimeout(function(){$(".thumb").lazyload({container: $("#results")});}, 250);
|
||||||
|
|
||||||
if(Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
if(Helper.contains($(".search_loader_spinner").attr("class").split(" "), "active"))
|
||||||
$(".search_loader_spinner").removeClass("active");
|
$(".search_loader_spinner").removeClass("active");
|
||||||
|
|
||||||
$(".add-many").click(function(e) {
|
$(".add-many").click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
$(".main").removeClass("blurT");
|
||||||
|
$("#controls").removeClass("blurT");
|
||||||
|
$(".main").removeClass("clickthrough");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
}else{
|
backgroundSearch: function(title, artist, length, totalNumber, current){
|
||||||
$(".main").removeClass("blurT");
|
var keyword= encodeURIComponent(title + " " + artist);
|
||||||
$("#controls").removeClass("blurT");
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
||||||
$(".main").removeClass("clickthrough");
|
yt_url+="&q="+keyword;
|
||||||
}
|
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
},
|
artist = artist.split(" ");
|
||||||
|
var temptitle = title.split("-");
|
||||||
|
temptitle = temptitle.join(" ").split(" ");
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: yt_url,
|
||||||
|
dataType:"jsonp",
|
||||||
|
success: function(response){
|
||||||
|
//Helper.log(response);
|
||||||
|
if(response.items.length === 0){
|
||||||
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
|
Helper.log("------------------------------");
|
||||||
|
Helper.log("NO MATCH FOR:");
|
||||||
|
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
|
Helper.log("Spotify length: " + length);
|
||||||
|
Helper.log("------------------------------");
|
||||||
|
var not_added_song = $("<div>" + not_import_html + "</div>");
|
||||||
|
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
||||||
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
|
$(".not-imported").removeClass("hide");
|
||||||
|
} else if(response.items.length > 0) {
|
||||||
|
$.each(response.items, function(i,data)
|
||||||
|
{
|
||||||
|
vid_url += data.id.videoId+",";
|
||||||
|
});
|
||||||
|
|
||||||
backgroundSearch: function(title, artist, length, totalNumber, current){
|
$.ajax({
|
||||||
var keyword= encodeURIComponent(title + " " + artist);
|
type: "GET",
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?key="+api_key+"&videoEmbeddable=true&part=id,snippet&fields=items(id,snippet)&type=video&order=relevance&safeSearch=none&maxResults=10&videoCategoryId=10";
|
url: vid_url,
|
||||||
yt_url+="&q="+keyword;
|
dataType:"jsonp",
|
||||||
var vid_url = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
success: function(response){
|
||||||
artist = artist.split(" ");
|
if(response.items.length > 0) {
|
||||||
var temptitle = title.split("-");
|
var matched = false;
|
||||||
temptitle = temptitle.join(" ").split(" ");
|
$.each(response.items, function(i, data){
|
||||||
$.ajax({
|
//Helper.log(data);
|
||||||
type: "GET",
|
//var title = data.snippet.title;
|
||||||
url: yt_url,
|
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
||||||
dataType:"jsonp",
|
var not_matched = false;
|
||||||
success: function(response){
|
$.each(temptitle, function(i, data_title){
|
||||||
//Helper.log(response);
|
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
||||||
if(response.items.length === 0){
|
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
Helper.log("------------------------------");
|
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
||||||
Helper.log("NO MATCH FOR:");
|
title.toLowerCase().indexOf("remix") == -1) ||
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
(data.snippet.title.toLowerCase().indexOf("remix") != -1 &&
|
||||||
Helper.log("Spotify length: " + length);
|
title.toLowerCase().indexOf("remix") != -1) || !(data.snippet.title.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
||||||
Helper.log("------------------------------");
|
(data.snippet.channelTitle.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)))
|
||||||
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
))
|
||||||
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
not_matched = true;
|
||||||
not_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
|
||||||
$(".not-imported-container").append(not_added_song.html());
|
|
||||||
$(".not-imported").removeClass("hide");
|
|
||||||
} else if(response.items.length > 0) {
|
|
||||||
$.each(response.items, function(i,data)
|
|
||||||
{
|
|
||||||
vid_url += data.id.videoId+",";
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajax({
|
return false;
|
||||||
type: "GET",
|
});
|
||||||
url: vid_url,
|
|
||||||
dataType:"jsonp",
|
|
||||||
success: function(response){
|
|
||||||
if(response.items.length > 0) {
|
|
||||||
var matched = false;
|
|
||||||
$.each(response.items, function(i, data){
|
|
||||||
//Helper.log(data);
|
|
||||||
//var title = data.snippet.title;
|
|
||||||
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
|
||||||
var not_matched = false;
|
|
||||||
$.each(temptitle, function(i, data_title){
|
|
||||||
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
|
||||||
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
|
||||||
title.toLowerCase().indexOf("cover") == -1 &&
|
|
||||||
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
|
||||||
title.toLowerCase().indexOf("remix") == -1) ||
|
|
||||||
(data.snippet.title.toLowerCase().indexOf("remix") != -1 &&
|
|
||||||
title.toLowerCase().indexOf("remix") != -1) || !(data.snippet.title.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
|
||||||
(data.snippet.channelTitle.toLowerCase().indexOf(artist[0].toLowerCase()) == -1 &&
|
|
||||||
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)))
|
|
||||||
))
|
|
||||||
not_matched = true;
|
|
||||||
|
|
||||||
return false;
|
if((!not_matched)){
|
||||||
});
|
matched = true;
|
||||||
|
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(!matched){
|
||||||
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
|
Helper.log("------------------------------");
|
||||||
|
Helper.log("NO MATCH FOR:");
|
||||||
|
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
|
Helper.log("Spotify length: " + length);
|
||||||
|
Helper.log("------------------------------");
|
||||||
|
var not_added_song = $("<div>" + not_import_html + "</div>");
|
||||||
|
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
||||||
|
not_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
||||||
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
|
$(".not-imported").removeClass("hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if(
|
}
|
||||||
(!not_matched //&&
|
}
|
||||||
//(duration + 1 > length && duration - 1 < length)
|
});
|
||||||
)
|
},
|
||||||
){
|
|
||||||
matched = true;
|
|
||||||
/*Helper.log("------------------------------");
|
|
||||||
Helper.log("MATCH FOR:");
|
|
||||||
Helper.log("YouTube title: " + data.snippet.title);
|
|
||||||
Helper.log("YouTube Channel: " + data.snippet.channelTitle);
|
|
||||||
Helper.log("YouTube duration: " + duration);
|
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
|
||||||
Helper.log("Spotify length: " + length);
|
|
||||||
Helper.log("------------------------------");*/
|
|
||||||
//Search.submit(data.id,data.snippet.title, duration, true, current, totalNumber);
|
|
||||||
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(!matched){
|
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
|
||||||
Helper.log("------------------------------");
|
|
||||||
Helper.log("NO MATCH FOR:");
|
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
|
||||||
Helper.log("Spotify length: " + length);
|
|
||||||
Helper.log("------------------------------");
|
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
|
||||||
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
|
||||||
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
|
||||||
not_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
|
||||||
$(".not-imported-container").append(not_added_song.html());
|
|
||||||
$(".not-imported").removeClass("hide");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
readySubmit: function(found, obj){
|
||||||
}
|
if(Search.submitArrayExpected === null){
|
||||||
});
|
Search.submitArrayExpected = obj.totalLength;
|
||||||
},
|
}
|
||||||
|
if(found){
|
||||||
|
Search.submitArray.push(obj);
|
||||||
|
} else {
|
||||||
|
Search.submitArrayExpected -= 1;
|
||||||
|
}
|
||||||
|
if((Search.submitArray.length - 1) == Search.submitArrayExpected) {
|
||||||
|
$.each(Search.submitArray, function(i, data){
|
||||||
|
Search.submit(data.id, data.title, data.duration, true, i, Search.submitArray.length - 1);
|
||||||
|
});
|
||||||
|
document.getElementById("import_spotify").disabled = false;
|
||||||
|
$("#import_spotify").removeClass("hide");
|
||||||
|
$("#playlist_loader_spotify").addClass("hide");
|
||||||
|
Search.submitArray = [];
|
||||||
|
Search.submitArrayExpected = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
readySubmit: function(found, obj){
|
submitAndClose: function(id,title,duration){
|
||||||
if(Search.submitArrayExpected === null){
|
Search.submit(id,title, duration, false, 0, 1);
|
||||||
Search.submitArrayExpected = obj.totalLength;
|
$("#results").html('');
|
||||||
}
|
Search.showSearch();
|
||||||
if(found){
|
document.getElementById("search").value = "";
|
||||||
Search.submitArray.push(obj);
|
$("#results").html = "";
|
||||||
} else {
|
$(".main").removeClass("blurT");
|
||||||
Search.submitArrayExpected -= 1;
|
$("#controls").removeClass("blurT");
|
||||||
}
|
$(".main").removeClass("clickthrough");
|
||||||
if((Search.submitArray.length - 1) == Search.submitArrayExpected) {
|
},
|
||||||
$.each(Search.submitArray, function(i, data){
|
|
||||||
Search.submit(data.id, data.title, data.duration, true, i, Search.submitArray.length - 1);
|
|
||||||
});
|
|
||||||
document.getElementById("import_spotify").disabled = false;
|
|
||||||
$("#import_spotify").removeClass("hide");
|
|
||||||
$("#playlist_loader_spotify").addClass("hide");
|
|
||||||
Search.submitArray = [];
|
|
||||||
Search.submitArrayExpected = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
submitAndClose: function(id,title,duration){
|
importPlaylist: function(pId,pageToken){
|
||||||
Search.submit(id,title, duration, false, 0, 1);
|
token = "";
|
||||||
$("#results").html('');
|
var headers;
|
||||||
Search.showSearch();
|
var datatype;
|
||||||
document.getElementById("search").value = "";
|
if(pageToken !== undefined)
|
||||||
$("#results").html = "";
|
token = "&pageToken="+pageToken;
|
||||||
$(".main").removeClass("blurT");
|
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key+"&playlistId="+pId+token;
|
||||||
$("#controls").removeClass("blurT");
|
if(youtube_authenticated){
|
||||||
$(".main").removeClass("clickthrough");
|
datatype = "html";
|
||||||
},
|
headers = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + access_token_data_youtube.access_token
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
headers = {};//'Content-Type': 'application/json'};
|
||||||
|
datatype = "jsonp";
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: playlist_url,
|
||||||
|
dataType: datatype,
|
||||||
|
//dataType:"jsonp",
|
||||||
|
headers: headers,
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
if(response.error){
|
||||||
|
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
||||||
|
var nonce = randomString(29);
|
||||||
|
window.callback = function(data) {
|
||||||
|
access_token_data_youtube = data;
|
||||||
|
if(access_token_data_youtube.state == nonce){
|
||||||
|
youtube_authenticated = true;
|
||||||
|
setTimeout(function(){
|
||||||
|
youtube_authenticated = false;
|
||||||
|
access_token_data_youtube = {};
|
||||||
|
}, access_token_data_youtube.expires_in * 1000);
|
||||||
|
Search.importPlaylist(pId, pageToken);
|
||||||
|
} else {
|
||||||
|
access_token_data_youtube = "";
|
||||||
|
console.error("Nonce doesn't match");
|
||||||
|
}
|
||||||
|
youtube_window.close();
|
||||||
|
window.callback = "";
|
||||||
|
};
|
||||||
|
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
||||||
|
} else {
|
||||||
|
Helper.log(response.error);
|
||||||
|
document.getElementById("import").disabled = false;
|
||||||
|
$("#playlist_loader").addClass("hide");
|
||||||
|
$("#import").removeClass("hide");
|
||||||
|
before_toast();
|
||||||
|
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
||||||
|
}
|
||||||
|
|
||||||
importPlaylist: function(pId,pageToken){
|
} else {
|
||||||
token = "";
|
var ids="";
|
||||||
var headers;
|
if(typeof(response) == "string") response = $.parseJSON(response);
|
||||||
var datatype;
|
//Search.addVideos(response.items[0].contentDetails.videoId);
|
||||||
if(pageToken !== undefined)
|
//response.items.shift();
|
||||||
token = "&pageToken="+pageToken;
|
$.each(response.items, function(i,data)
|
||||||
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key+"&playlistId="+pId+token;
|
{
|
||||||
if(youtube_authenticated){
|
ids+=data.contentDetails.videoId+",";
|
||||||
datatype = "html";
|
});
|
||||||
headers = {
|
Search.addVideos(ids, true);
|
||||||
'Content-Type': 'application/json',
|
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
||||||
'Authorization': 'Bearer ' + access_token_data_youtube.access_token
|
document.getElementById("import").value = "";
|
||||||
};
|
}
|
||||||
} else {
|
}
|
||||||
headers = {};//'Content-Type': 'application/json'};
|
});
|
||||||
datatype = "jsonp";
|
},
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: playlist_url,
|
|
||||||
dataType: datatype,
|
|
||||||
//dataType:"jsonp",
|
|
||||||
headers: headers,
|
|
||||||
success: function(response)
|
|
||||||
{
|
|
||||||
if(response.error){
|
|
||||||
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
|
||||||
var nonce = randomString(29);
|
|
||||||
window.callback = function(data) {
|
|
||||||
access_token_data_youtube = data;
|
|
||||||
if(access_token_data_youtube.state == nonce){
|
|
||||||
youtube_authenticated = true;
|
|
||||||
setTimeout(function(){
|
|
||||||
youtube_authenticated = false;
|
|
||||||
access_token_data_youtube = {};
|
|
||||||
}, access_token_data_youtube.expires_in * 1000);
|
|
||||||
Search.importPlaylist(pId, pageToken);
|
|
||||||
} else {
|
|
||||||
access_token_data_youtube = "";
|
|
||||||
console.error("Nonce doesn't match");
|
|
||||||
}
|
|
||||||
youtube_window.close();
|
|
||||||
window.callback = "";
|
|
||||||
};
|
|
||||||
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
|
||||||
} else {
|
|
||||||
Helper.log(response.error);
|
|
||||||
document.getElementById("import").disabled = false;
|
|
||||||
$("#playlist_loader").addClass("hide");
|
|
||||||
$("#import").removeClass("hide");
|
|
||||||
before_toast();
|
|
||||||
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
importSpotifyPlaylist: function(url){
|
||||||
var ids="";
|
$.ajax({
|
||||||
if(typeof(response) == "string") response = $.parseJSON(response);
|
url: url,
|
||||||
//Search.addVideos(response.items[0].contentDetails.videoId);
|
headers: {
|
||||||
//response.items.shift();
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
$.each(response.items, function(i,data)
|
},
|
||||||
{
|
success: function(response) {
|
||||||
ids+=data.contentDetails.videoId+",";
|
$.each(response.items, function(i,data)
|
||||||
});
|
{
|
||||||
Search.addVideos(ids, true);
|
//ids+=data.contentDetails.videoId+",";
|
||||||
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
Search.backgroundSearch(data.track.name, data.track.artists.map(function(elem){return elem.name;}).join(" "), Math.floor(data.track.duration_ms/1000), response.total, i + response.offset);
|
||||||
document.getElementById("import").value = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
importSpotifyPlaylist: function(url){
|
});
|
||||||
$.ajax({
|
if(response.next){
|
||||||
url: url,
|
Search.importSpotifyPlaylist(response.next);
|
||||||
headers: {
|
}
|
||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
},
|
||||||
},
|
error: function() {
|
||||||
success: function(response) {
|
document.getElementById("import_spotify").disabled = false;
|
||||||
$.each(response.items, function(i,data)
|
$("#import_spotify").removeClass("hide");
|
||||||
{
|
$("#playlist_loader_spotify").addClass("hide");
|
||||||
//ids+=data.contentDetails.videoId+",";
|
before_toast();
|
||||||
Search.backgroundSearch(data.track.name, data.track.artists.map(function(elem){return elem.name;}).join(" "), Math.floor(data.track.duration_ms/1000), response.total, i + response.offset);
|
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
});
|
addVideos: function(ids, playlist){
|
||||||
if(response.next){
|
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
||||||
Search.importSpotifyPlaylist(response.next);
|
request_url += ids;
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
document.getElementById("import_spotify").disabled = false;
|
|
||||||
$("#import_spotify").removeClass("hide");
|
|
||||||
$("#playlist_loader_spotify").addClass("hide");
|
|
||||||
before_toast();
|
|
||||||
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
addVideos: function(ids, playlist){
|
$.ajax({
|
||||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
type: "POST",
|
||||||
request_url += ids;
|
url: request_url,
|
||||||
|
dataType:"jsonp",
|
||||||
|
success: function(response){
|
||||||
|
var x = 0;
|
||||||
|
var to_add = [];
|
||||||
|
$.each(response.items, function(i,song)
|
||||||
|
{
|
||||||
|
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
||||||
|
if(!longsongs || duration<720){
|
||||||
|
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
||||||
|
//Search.submit(song.id, enc_title, duration, playlist, i);
|
||||||
|
x += 1;
|
||||||
|
to_add.push({id: song.id, enc_title: enc_title, duration: duration, playlist: playlist});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$.each(to_add, function(i, item){
|
||||||
|
Search.submit(item.id, item.enc_title, item.duration, item.playlist, i, x);
|
||||||
|
});
|
||||||
|
|
||||||
$.ajax({
|
}
|
||||||
type: "POST",
|
});
|
||||||
url: request_url,
|
},
|
||||||
dataType:"jsonp",
|
|
||||||
success: function(response){
|
|
||||||
var x = 0;
|
|
||||||
var to_add = [];
|
|
||||||
$.each(response.items, function(i,song)
|
|
||||||
{
|
|
||||||
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
|
||||||
if(!longsongs || duration<720){
|
|
||||||
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
|
||||||
//Search.submit(song.id, enc_title, duration, playlist, i);
|
|
||||||
x += 1;
|
|
||||||
to_add.push({id: song.id, enc_title: enc_title, duration: duration, playlist: playlist});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$.each(to_add, function(i, item){
|
|
||||||
Search.submit(item.id, item.enc_title, item.duration, item.playlist, i, x);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
submit: function(id,title,duration, playlist, num, full_num){
|
||||||
});
|
if(offline && document.getElementsByName("addsongs")[0].checked && document.getElementsByName("addsongs")[0].disabled){
|
||||||
},
|
var found_array = [];
|
||||||
|
found_array = $.map(full_playlist, function(obj, index) {
|
||||||
submit: function(id,title,duration, playlist, num, full_num){
|
if(obj.id == id) {
|
||||||
if(offline && document.getElementsByName("addsongs")[0].checked && document.getElementsByName("addsongs")[0].disabled){
|
return index;
|
||||||
var found_array = [];
|
}
|
||||||
found_array = $.map(full_playlist, function(obj, index) {
|
});
|
||||||
if(obj.id == id) {
|
if(found_array.length == 0){
|
||||||
return index;
|
List.channel_function({type: "added", value: {added: (new Date).getTime()/1000, guids: [1], id: id, title: title, duration: duration, playlist: false, now_playing: false, votes: 1}});
|
||||||
}
|
} else {
|
||||||
});
|
List.vote(id, "pos");
|
||||||
if(found_array.length == 0){
|
}
|
||||||
List.channel_function({type: "added", value: {added: (new Date).getTime()/1000, guids: [1], id: id, title: title, duration: duration, playlist: false, now_playing: false, votes: 1}});
|
} else {
|
||||||
} else {
|
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
List.vote(id, "pos");
|
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||||
}
|
},
|
||||||
} else {
|
|
||||||
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
|
||||||
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
|
||||||
},
|
|
||||||
|
|
||||||
durationToSeconds: function(duration) {
|
|
||||||
var matches = duration.match(time_regex);
|
|
||||||
hours= parseInt(matches[12])||0;
|
|
||||||
minutes= parseInt(matches[14])||0;
|
|
||||||
seconds= parseInt(matches[16])||0;
|
|
||||||
return hours*60*60+minutes*60+seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
durationToSeconds: function(duration) {
|
||||||
|
var matches = duration.match(time_regex);
|
||||||
|
hours= parseInt(matches[12])||0;
|
||||||
|
minutes= parseInt(matches[14])||0;
|
||||||
|
seconds= parseInt(matches[16])||0;
|
||||||
|
return hours*60*60+minutes*60+seconds;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ var Suggestions = {
|
|||||||
}
|
}
|
||||||
var to_display = number_suggested > 9 ? "9+" : number_suggested;
|
var to_display = number_suggested > 9 ? "9+" : number_suggested;
|
||||||
if($(".suggested-link span.badge.new.white").hasClass("hide") && number_suggested > 0){
|
if($(".suggested-link span.badge.new.white").hasClass("hide") && number_suggested > 0){
|
||||||
$(".suggested-link span.badge.new.white").removeClass("hide");
|
$(".suggested-link span.badge.new.white").removeClass("hide");
|
||||||
}
|
}
|
||||||
$(".suggested-link span.badge.new.white").text(to_display);
|
$(".suggested-link span.badge.new.white").text(to_display);
|
||||||
if(single){
|
if(single){
|
||||||
@@ -25,11 +25,6 @@ var Suggestions = {
|
|||||||
var duration = Helper.secondsToOther(params.duration);
|
var duration = Helper.secondsToOther(params.duration);
|
||||||
var video_id = params.id;
|
var video_id = params.id;
|
||||||
var video_title = params.title;
|
var video_title = params.title;
|
||||||
/*var minutes = Math.floor(secs / 60);
|
|
||||||
var seconds = secs - minutes * 60;
|
|
||||||
|
|
||||||
duration = Helper.pad(minutes) + ":" + Helper.pad(seconds);*/
|
|
||||||
|
|
||||||
var song = List.generateSong({id: video_id, title: video_title, length: params.duration, duration: duration}, false, false, false, true);
|
var song = List.generateSong({id: video_id, title: video_title, length: params.duration, duration: duration}, false, false, false, true);
|
||||||
$("#user-suggest-html").append(song);
|
$("#user-suggest-html").append(song);
|
||||||
},
|
},
|
||||||
@@ -40,48 +35,46 @@ var Suggestions = {
|
|||||||
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: get_url,
|
url: get_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
$.each(response.items.slice(0,5), function(i,data){
|
$.each(response.items.slice(0,5), function(i,data){
|
||||||
video_urls += data.id.videoId+",";
|
video_urls += data.id.videoId+",";
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: video_urls,
|
url: video_urls,
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
$("#suggest-song-html").empty();
|
$("#suggest-song-html").empty();
|
||||||
|
|
||||||
$.each(response.items, function(i,song)
|
$.each(response.items, function(i,song)
|
||||||
{
|
{
|
||||||
var duration = song.contentDetails.duration;
|
var duration = song.contentDetails.duration;
|
||||||
var length = Search.durationToSeconds(duration);
|
var length = Search.durationToSeconds(duration);
|
||||||
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
||||||
var video_id = song.id;
|
var video_id = song.id;
|
||||||
var video_title = song.snippet.title;
|
var video_title = song.snippet.title;
|
||||||
|
|
||||||
//duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
|
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
||||||
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
checkUserEmpty: function(){
|
checkUserEmpty: function(){
|
||||||
var length = $("#user-suggest-html").children().length;
|
var length = $("#user-suggest-html").children().length;
|
||||||
if(length === 0){
|
if(length === 0){
|
||||||
if(!Helper.contains($("#user_suggests").attr("class").split(" "), "hide"))
|
if(!Helper.contains($("#user_suggests").attr("class").split(" "), "hide"))
|
||||||
$("#user_suggests").addClass("hide");
|
$("#user_suggests").addClass("hide");
|
||||||
}else{
|
}else{
|
||||||
$("#user_suggests").removeClass("hide");
|
$("#user_suggests").removeClass("hide");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user