mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Removed some old functions and indented code
This commit is contained in:
2
server/public/assets/dist/embed.min.js
vendored
2
server/public/assets/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/main.min.js
vendored
2
server/public/assets/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/remote.min.js
vendored
2
server/public/assets/dist/remote.min.js
vendored
@@ -1 +1 @@
|
|||||||
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(o){(/(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(o)||/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(o.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),socket.on("update_required",function(){window.location.reload(!0)}),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),o.control())}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),o.control()});var o={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,o){socket.emit("id",{id:id,type:"volume",value:o.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();
|
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),socket.on("update_required",function(){window.location.reload(!0)}),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),t.control())}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),t.control()});var t={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){socket.emit("id",{id:id,type:"volume",value:t.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();
|
||||||
@@ -2,8 +2,7 @@ var Admin = {
|
|||||||
|
|
||||||
beginning:true,
|
beginning:true,
|
||||||
|
|
||||||
toast: function(msg)
|
toast: function(msg) {
|
||||||
{
|
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
case "suggested_thumbnail":
|
case "suggested_thumbnail":
|
||||||
msg = "The thumbnail has been suggested!";
|
msg = "The thumbnail has been suggested!";
|
||||||
@@ -158,8 +157,7 @@ var Admin = {
|
|||||||
$('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));
|
||||||
},
|
},
|
||||||
|
|
||||||
conf: function(msg)
|
conf: function(msg) {
|
||||||
{
|
|
||||||
if(msg[0].adminpass == ""){
|
if(msg[0].adminpass == ""){
|
||||||
Crypt.remove_pass(chan.toLowerCase());
|
Crypt.remove_pass(chan.toLowerCase());
|
||||||
}
|
}
|
||||||
@@ -170,31 +168,26 @@ var Admin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pass_save: function()
|
pass_save: function() {
|
||||||
{
|
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",
|
||||||
@@ -207,10 +200,10 @@ var Admin = {
|
|||||||
$("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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,18 +224,13 @@ var Admin = {
|
|||||||
$(".change_user_pass").addClass("hide");
|
$(".change_user_pass").addClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Helper.contains($(".playlist-tabs-loggedIn").attr("class").split(" "), "hide")){
|
if(!Helper.contains($(".playlist-tabs-loggedIn").attr("class").split(" "), "hide")) {
|
||||||
$(".playlist-tabs-loggedIn").addClass("hide");
|
$(".playlist-tabs-loggedIn").addClass("hide");
|
||||||
$(".playlist-tabs").removeClass("hide");
|
$(".playlist-tabs").removeClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
List.dragging(false);
|
List.dragging(false);
|
||||||
|
|
||||||
/*if($(".card-action").length !== 0 &&
|
|
||||||
!Helper.contains($(".card-action").attr("class").split(" "), "hide") && !offline){
|
|
||||||
$(".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');
|
||||||
@@ -254,12 +242,11 @@ var Admin = {
|
|||||||
$("#password").attr("placeholder", "Enter admin password");
|
$("#password").attr("placeholder", "Enter admin password");
|
||||||
},
|
},
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
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",
|
||||||
@@ -268,22 +255,21 @@ var Admin = {
|
|||||||
|
|
||||||
if(conf_array.adminpass === "" || !w_p){
|
if(conf_array.adminpass === "" || !w_p){
|
||||||
hasadmin = false;
|
hasadmin = false;
|
||||||
if(!Helper.mobilecheck()){
|
if(!Helper.mobilecheck()) {
|
||||||
//$(".playlist-tabs").removeClass("hide");
|
//$(".playlist-tabs").removeClass("hide");
|
||||||
//$("#wrapper").toggleClass("tabs_height");
|
//$("#wrapper").toggleClass("tabs_height");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else hasadmin = true;
|
else hasadmin = true;
|
||||||
|
|
||||||
for (var i = 0; i < names.length; i++)
|
for (var i = 0; i < names.length; i++) {
|
||||||
{
|
|
||||||
document.getElementsByName(names[i])[0].checked = (conf_array[names[i]] === true);
|
document.getElementsByName(names[i])[0].checked = (conf_array[names[i]] === true);
|
||||||
$("input[name="+names[i]+"]").attr("disabled", hasadmin);
|
$("input[name="+names[i]+"]").attr("disabled", hasadmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((hasadmin)){
|
if((hasadmin)) {
|
||||||
if($("#admin-lock").html() != "lock") Admin.display_logged_out();
|
if($("#admin-lock").html() != "lock") Admin.display_logged_out();
|
||||||
}else if(!hasadmin && Crypt.get_pass(chan.toLowerCase()) === undefined){
|
} else if(!hasadmin && Crypt.get_pass(chan.toLowerCase()) === undefined) {
|
||||||
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");
|
||||||
@@ -300,18 +286,17 @@ var Admin = {
|
|||||||
Crypt.remove_userpass(chan.toLowerCase());
|
Crypt.remove_userpass(chan.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conf_array.thumbnail != undefined && conf_array.thumbnail != ""){
|
if(conf_array.thumbnail != undefined && conf_array.thumbnail != "") {
|
||||||
$("#thumbnail_image").html("<img id='thumbnail_image_channel' src='" + conf_array.thumbnail + "' alt='thumbnail' />");
|
$("#thumbnail_image").html("<img id='thumbnail_image_channel' src='" + conf_array.thumbnail + "' alt='thumbnail' />");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conf_array.description != undefined && conf_array.description != ""){
|
if(conf_array.description != undefined && conf_array.description != "") {
|
||||||
$("#description_area").html(conf_array.description);
|
$("#description_area").html(conf_array.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
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;
|
||||||
@@ -321,7 +306,7 @@ var Admin = {
|
|||||||
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(),
|
channel: chan.toLowerCase(),
|
||||||
voting: voting,
|
voting: voting,
|
||||||
addsongs: addsongs,
|
addsongs: addsongs,
|
||||||
@@ -340,13 +325,12 @@ var Admin = {
|
|||||||
socket.emit("conf", configs);
|
socket.emit("conf", configs);
|
||||||
},
|
},
|
||||||
|
|
||||||
hide_settings: function(){
|
hide_settings: function() {
|
||||||
$('#settings').sideNav('hide');
|
$('#settings').sideNav('hide');
|
||||||
},
|
},
|
||||||
|
|
||||||
shuffle: function()
|
shuffle: function() {
|
||||||
{
|
if(!offline) {
|
||||||
if(!offline){
|
|
||||||
socket.emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
socket.emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
for(var x = 0; x < full_playlist.length; x++){
|
for(var x = 0; x < full_playlist.length; x++){
|
||||||
@@ -358,8 +342,7 @@ var Admin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_admin:function()
|
get_admin:function() {
|
||||||
{
|
|
||||||
return [w_p, hasadmin];
|
return [w_p, hasadmin];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
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";
|
||||||
@@ -26,7 +26,7 @@ window.addEventListener("load", function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -4,33 +4,31 @@ var Chat = {
|
|||||||
all_received: 0,
|
all_received: 0,
|
||||||
chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "There are no commands.. As of now!"],
|
chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "There are no commands.. As of now!"],
|
||||||
|
|
||||||
namechange: function(newName)
|
namechange: function(newName) {
|
||||||
{
|
|
||||||
socket.emit("namechange", {name: newName, channel: chan.toLowerCase()});
|
socket.emit("namechange", {name: newName, channel: chan.toLowerCase()});
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,14 +40,14 @@ var Chat = {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,26 +58,20 @@ var Chat = {
|
|||||||
$("#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", {channel: chan.toLowerCase(), data: data.value});
|
socket.emit("all,chat", {channel: chan.toLowerCase(), data: 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;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
allchat: function(inp)
|
allchat: function(inp) {
|
||||||
{
|
if(inp.msg.substring(0,1) == ":" && !chat_active) {
|
||||||
//$("#chat-btn").css("color", "grey");
|
|
||||||
|
|
||||||
if(inp.msg.substring(0,1) == ":" && !chat_active)
|
|
||||||
{
|
|
||||||
Chat.all_received += 1;
|
Chat.all_received += 1;
|
||||||
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
||||||
unseen = true;
|
unseen = true;
|
||||||
@@ -89,16 +81,13 @@ var Chat = {
|
|||||||
}
|
}
|
||||||
var to_display = Chat.channel_received + Chat.all_received > 9 ? "9+" : Chat.channel_received + Chat.all_received;
|
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);
|
$(".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(document.hidden) {
|
||||||
{
|
|
||||||
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#chatall").children().length > 100){
|
if($("#chatall").children().length > 100) {
|
||||||
$("#chatall").children()[0].remove()
|
$("#chatall").children()[0].remove()
|
||||||
}
|
}
|
||||||
var color = Helper.intToARGB(Helper.hashCode(inp.from));
|
var color = Helper.intToARGB(Helper.hashCode(inp.from));
|
||||||
@@ -115,29 +104,27 @@ var Chat = {
|
|||||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
},
|
},
|
||||||
|
|
||||||
channelchat: function(data)
|
channelchat: function(data) {
|
||||||
{
|
if(data.msg.substring(0,1) == ":" && !chat_active) {
|
||||||
if(data.msg.substring(0,1) == ":" && !chat_active)
|
|
||||||
{
|
|
||||||
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
$("#favicon").attr("href", "/assets/images/highlogo.png");
|
||||||
unseen = true;
|
unseen = true;
|
||||||
chat_unseen = true;
|
chat_unseen = true;
|
||||||
Chat.channel_received += 1;
|
Chat.channel_received += 1;
|
||||||
//blink_interval = setTimeout(Chat.chat_blink, 1000);
|
//blink_interval = setTimeout(Chat.chat_blink, 1000);
|
||||||
if($(".chat-link span.badge.new.white").hasClass("hide")){
|
if($(".chat-link span.badge.new.white").hasClass("hide")) {
|
||||||
$(".chat-link span.badge.new.white").removeClass("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;
|
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);
|
$(".chat-link span.badge.new.white").html(to_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#chatchannel").children().length > 100){
|
if($("#chatchannel").children().length > 100) {
|
||||||
$("#chatchannel").children()[0].remove()
|
$("#chatchannel").children()[0].remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
var color = Helper.intToARGB(Helper.hashCode(data.from));
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,5 +146,4 @@ var Chat = {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,26 +4,26 @@ var Crypt = {
|
|||||||
user_pass: undefined,
|
user_pass: undefined,
|
||||||
tmp_pass: "",
|
tmp_pass: "",
|
||||||
|
|
||||||
init: function(){
|
init: function() {
|
||||||
|
|
||||||
if(window.location.pathname != "/"){
|
if(window.location.pathname != "/") {
|
||||||
if (location.protocol != "https:"){
|
if (location.protocol != "https:") {
|
||||||
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';expires=' + new Date(0).toUTCString();
|
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';expires=' + new Date(0).toUTCString();
|
||||||
} else {
|
} else {
|
||||||
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';secure;expires=' + new Date(0).toUTCString();
|
document.cookie = chan.toLowerCase() + '=;path=/' + chan.toLowerCase() + ';secure;expires=' + new Date(0).toUTCString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
decrypt: function(cookie, name){
|
decrypt: function(cookie, name) {
|
||||||
if(Crypt.getCookie(name) === undefined) {
|
if(Crypt.getCookie(name) === undefined) {
|
||||||
cookie = Crypt.create_cookie(name);
|
cookie = Crypt.create_cookie(name);
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ var Crypt = {
|
|||||||
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
||||||
},
|
},
|
||||||
|
|
||||||
decrypt_pass: function(pass){
|
decrypt_pass: function(pass) {
|
||||||
var key = btoa(socket.id) + btoa(socket.id);
|
var key = btoa(socket.id) + btoa(socket.id);
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
key = btoa(key);
|
key = btoa(key);
|
||||||
@@ -62,11 +62,10 @@ var Crypt = {
|
|||||||
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 key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
@@ -89,12 +88,12 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_volume: function(){
|
get_volume: function() {
|
||||||
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").volume;
|
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").volume;
|
||||||
//return conf_arr.volume;
|
//return conf_arr.volume;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_offline: function(){
|
get_offline: function() {
|
||||||
var temp_offline = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
|
var temp_offline = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
|
||||||
if(temp_offline != undefined){
|
if(temp_offline != undefined){
|
||||||
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
|
return Crypt.decrypt(Crypt.getCookie("_opt"), "_opt").offline;
|
||||||
@@ -104,12 +103,12 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_volume: function(val){
|
set_volume: function(val) {
|
||||||
conf_arr.volume = val;
|
conf_arr.volume = val;
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|
||||||
create_cookie: function(name){
|
create_cookie: function(name) {
|
||||||
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: {}};
|
||||||
|
|
||||||
@@ -139,12 +138,12 @@ var Crypt = {
|
|||||||
return Crypt.getCookie(name);
|
return Crypt.getCookie(name);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_pass: function(chan, pass){
|
set_pass: function(chan, pass) {
|
||||||
Crypt.conf_pass.passwords[chan] = pass;
|
Crypt.conf_pass.passwords[chan] = pass;
|
||||||
Crypt.encrypt(Crypt.conf_pass, chan);
|
Crypt.encrypt(Crypt.conf_pass, chan);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove_pass:function(chan){
|
remove_pass:function(chan) {
|
||||||
delete Crypt.conf_pass.passwords[chan];
|
delete Crypt.conf_pass.passwords[chan];
|
||||||
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
|
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
|
||||||
},
|
},
|
||||||
@@ -154,27 +153,27 @@ var Crypt = {
|
|||||||
Crypt.encrypt(Crypt.conf_pass, chan);
|
Crypt.encrypt(Crypt.conf_pass, chan);
|
||||||
},
|
},
|
||||||
|
|
||||||
remove_userpass:function(chan){
|
remove_userpass:function(chan) {
|
||||||
delete Crypt.conf_pass.passwords["userpass"];
|
delete Crypt.conf_pass.passwords["userpass"];
|
||||||
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
|
Crypt.encrypt(Crypt.conf_pass, chan.toLowerCase());
|
||||||
},
|
},
|
||||||
|
|
||||||
set_name:function(name){
|
set_name:function(name) {
|
||||||
conf_arr.name = encodeURIComponent(name).replace(/\W/g, '');
|
conf_arr.name = encodeURIComponent(name).replace(/\W/g, '');
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|
||||||
set_offline: function(enabled){
|
set_offline: function(enabled) {
|
||||||
conf_arr.offline = enabled;
|
conf_arr.offline = enabled;
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|
||||||
remove_name:function(){
|
remove_name:function() {
|
||||||
conf_arr.name = "";
|
conf_arr.name = "";
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|
||||||
get_pass: function(chan){
|
get_pass: function(chan) {
|
||||||
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords[chan];
|
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords[chan];
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
@@ -184,16 +183,16 @@ var Crypt = {
|
|||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
set_remote: function(val){
|
set_remote: function(val) {
|
||||||
conf_arr.remote = val;
|
conf_arr.remote = val;
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|
||||||
get_remote: function(val){
|
get_remote: function(val) {
|
||||||
return conf_arr.remote;
|
return conf_arr.remote;
|
||||||
},
|
},
|
||||||
|
|
||||||
crypt_pass: function(pass){
|
crypt_pass: function(pass) {
|
||||||
Crypt.tmp_pass = pass;
|
Crypt.tmp_pass = pass;
|
||||||
var key = btoa(socket.id) + btoa(socket.id);
|
var key = btoa(socket.id) + btoa(socket.id);
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
@@ -212,7 +211,7 @@ var Crypt = {
|
|||||||
return encrypted.toString() + "$" + iv;
|
return encrypted.toString() + "$" + iv;
|
||||||
},
|
},
|
||||||
|
|
||||||
makeiv: function(){
|
makeiv: function() {
|
||||||
var text = "";
|
var text = "";
|
||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
@@ -222,11 +221,11 @@ var Crypt = {
|
|||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_width: function(){
|
get_width: function() {
|
||||||
return conf_arr.width;
|
return conf_arr.width;
|
||||||
},
|
},
|
||||||
|
|
||||||
set_width: function(val){
|
set_width: function(val) {
|
||||||
conf_arr.width = val;
|
conf_arr.width = val;
|
||||||
Crypt.encrypt(conf_arr, "_opt");
|
Crypt.encrypt(conf_arr, "_opt");
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ var Crypt = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function receiveMessage(event)
|
function receiveMessage(event) {
|
||||||
{
|
|
||||||
if(event.data == "parent") {
|
if(event.data == "parent") {
|
||||||
//console.log(event);
|
//console.log(event);
|
||||||
window.parentWindow = event.source;
|
window.parentWindow = event.source;
|
||||||
@@ -61,11 +60,11 @@ function receiveMessage(event)
|
|||||||
|
|
||||||
window.addEventListener("message", receiveMessage, false);
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function() {
|
||||||
|
|
||||||
if(hash.length >= 3 && hash[2] == "autoplay"){
|
if(hash.length >= 3 && hash[2] == "autoplay"){
|
||||||
autoplay = true;
|
autoplay = true;
|
||||||
}else{
|
} else {
|
||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +85,7 @@ $(document).ready(function(){
|
|||||||
$("#locked_channel").modal('open');
|
$("#locked_channel").modal('open');
|
||||||
});
|
});
|
||||||
|
|
||||||
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,8 +95,7 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("viewers", function(view)
|
socket.on("viewers", function(view) {
|
||||||
{
|
|
||||||
viewers = view;
|
viewers = view;
|
||||||
|
|
||||||
if(song_title !== undefined)
|
if(song_title !== undefined)
|
||||||
@@ -124,19 +122,19 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function setup_host_listener(id){
|
function setup_host_listener(id) {
|
||||||
socket.on(id, Hostcontroller.host_on_action);
|
socket.on(id, Hostcontroller.host_on_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_host_initialization(){
|
function setup_host_initialization() {
|
||||||
socket.on("id", Hostcontroller.host_listener);
|
socket.on("id", Hostcontroller.host_listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_youtube_listener(){
|
function setup_youtube_listener() {
|
||||||
socket.on("np", Player.youtube_listener);
|
socket.on("np", Player.youtube_listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_list_listener(){
|
function setup_list_listener() {
|
||||||
socket.on("channel", List.channel_function);
|
socket.on("channel", List.channel_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,21 +143,21 @@ function setVolume(val) {
|
|||||||
Playercontrols.setVolume(val);
|
Playercontrols.setVolume(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on( "click", "#zoffbutton", function(e){
|
$(document).on( "click", "#zoffbutton", function(e) {
|
||||||
window.open("https://zoff.me/" + chan.toLowerCase() + "/", '_blank');
|
window.open("https://zoff.me/" + chan.toLowerCase() + "/", '_blank');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".vote-container", function(e){
|
$(document).on( "click", ".vote-container", function(e) {
|
||||||
var id = $(this).attr("data-video-id");
|
var id = $(this).attr("data-video-id");
|
||||||
List.vote(id, "pos");
|
List.vote(id, "pos");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,31 +27,10 @@ var Frontpage = {
|
|||||||
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;
|
|
||||||
|
|
||||||
for(var i = 0; i < lists.length; i++) {
|
|
||||||
/*if(!lists[i].hasOwnProperty("viewers")){
|
|
||||||
lists[i].viewers = 0;
|
|
||||||
}
|
|
||||||
if(!lists[i].hasOwnProperty("accessed")) {
|
|
||||||
lists[i].accessed = 0;
|
|
||||||
}
|
|
||||||
if(!lists[i].hasOwnProperty("pinned")){
|
|
||||||
lists[i].pinned = 0;
|
|
||||||
} else if(lists[i].pinned == 1) {
|
|
||||||
pinned = lists[i];
|
|
||||||
delete lists[i];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if(lists[i].count == 0) {
|
|
||||||
delete lists[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(popular) {
|
if(popular) {
|
||||||
lists = lists.sort(Helper.predicate({
|
lists = lists.sort(Helper.predicate({
|
||||||
@@ -77,8 +56,6 @@ var Frontpage = {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
//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);
|
||||||
@@ -90,30 +67,24 @@ var Frontpage = {
|
|||||||
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]._id;
|
var chan = lists[x]._id;
|
||||||
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;
|
||||||
|
|
||||||
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", "");
|
||||||
}
|
}
|
||||||
@@ -124,7 +95,7 @@ var Frontpage = {
|
|||||||
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 != "" && description != undefined && !Helper.mobilecheck()){
|
if(description != "" && description != undefined && !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 = "";
|
||||||
@@ -134,24 +105,16 @@ var Frontpage = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#channels").append(card.html());
|
$("#channels").append(card.html());
|
||||||
|
|
||||||
//$("#channels").append(card);
|
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
//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;
|
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){
|
|
||||||
/*var chan = options_list[x].channel;
|
|
||||||
output+="<option value='"+chan+"'> ";*/
|
|
||||||
data[options_list[x]._id] = null;
|
data[options_list[x]._id] = null;
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var to_autocomplete = "input.desktop-search";
|
var to_autocomplete = "input.desktop-search";
|
||||||
@@ -165,8 +128,6 @@ var Frontpage = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
//$(".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);
|
||||||
@@ -269,7 +230,7 @@ var Frontpage = {
|
|||||||
},6000);
|
},6000);
|
||||||
},
|
},
|
||||||
|
|
||||||
get_frontpage_lists: function(){
|
get_frontpage_lists: function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/frontpages",
|
url: "/api/frontpages",
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -285,7 +246,7 @@ var Frontpage = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
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");
|
||||||
@@ -301,7 +262,7 @@ var Frontpage = {
|
|||||||
}, 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(){
|
||||||
@@ -312,12 +273,11 @@ var Frontpage = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_viewers: function(viewers){
|
set_viewers: function(viewers) {
|
||||||
$("#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;
|
||||||
@@ -396,7 +356,7 @@ 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");
|
||||||
@@ -405,7 +365,7 @@ function share_link_modifier_frontpage(){
|
|||||||
$("#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 = [];
|
||||||
|
|||||||
@@ -1,354 +1,331 @@
|
|||||||
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 == undefined) a = 0;
|
if(a == undefined) a = 0;
|
||||||
if(b == undefined) b = 0;
|
if(b == undefined) b = 0;
|
||||||
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;
|
||||||
},
|
},
|
||||||
|
|
||||||
hslToRgb: function(h, s, l) {
|
hslToRgb: function(h, s, l) {
|
||||||
var r, g, b;
|
var r, g, b;
|
||||||
|
|
||||||
if (s == 0) {
|
if (s == 0) {
|
||||||
r = g = b = l; // achromatic
|
r = g = b = l; // achromatic
|
||||||
} else {
|
} else {
|
||||||
function hue2rgb(p, q, t) {
|
function hue2rgb(p, q, t) {
|
||||||
if (t < 0) t += 1;
|
if (t < 0) t += 1;
|
||||||
if (t > 1) t -= 1;
|
if (t > 1) t -= 1;
|
||||||
if (t < 1/6) return p + (q - p) * 6 * t;
|
if (t < 1/6) return p + (q - p) * 6 * t;
|
||||||
if (t < 1/2) return q;
|
if (t < 1/2) return q;
|
||||||
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
||||||
var p = 2 * l - q;
|
var p = 2 * l - q;
|
||||||
|
|
||||||
r = hue2rgb(p, q, h + 1/3);
|
r = hue2rgb(p, q, h + 1/3);
|
||||||
g = hue2rgb(p, q, h);
|
g = hue2rgb(p, q, h);
|
||||||
b = hue2rgb(p, q, h - 1/3);
|
b = hue2rgb(p, q, h - 1/3);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [ r * 255, g * 255, b * 255 ];
|
return [ r * 255, g * 255, b * 255 ];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
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)
|
msieversion: function() {
|
||||||
{
|
var ua = window.navigator.userAgent;
|
||||||
if (filesadded.indexOf("["+filename+"]")==-1){
|
var msie = ua.indexOf("MSIE ");
|
||||||
var fileref=document.createElement('script');
|
|
||||||
fileref.setAttribute("type","text/javascript");
|
|
||||||
fileref.setAttribute("src", filename);
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(fileref);
|
|
||||||
filesadded+="["+filename+"]";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
msieversion: function() {
|
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
|
||||||
|
return true;
|
||||||
|
else // If another browser, return 0
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
var ua = window.navigator.userAgent;
|
getRandomInt: function(min, max) {
|
||||||
var msie = ua.indexOf("MSIE ");
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
},
|
||||||
|
|
||||||
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer, return version number
|
secondsToOther: function(seconds) {
|
||||||
return true;
|
var time = seconds;
|
||||||
else // If another browser, return 0
|
var minutes = Math.floor(time/60);
|
||||||
return false;
|
time = time - (minutes * 60);
|
||||||
},
|
return [minutes, time];
|
||||||
|
},
|
||||||
|
|
||||||
getRandomInt: function(min, max) {
|
rgbToHsl: function(arr, light) {
|
||||||
return Math.floor(Math.random() * (max - min)) + min;
|
r = arr[0];
|
||||||
},
|
g = arr[1];
|
||||||
|
b = arr[2];
|
||||||
|
r /= 255;
|
||||||
|
g /= 255;
|
||||||
|
b /= 255;
|
||||||
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
||||||
|
var h, s, l = (max + min) / 2;
|
||||||
|
|
||||||
secondsToOther: function(seconds){
|
if(max == min){
|
||||||
var time = seconds;
|
h = s = 0; // achromatic
|
||||||
var minutes = Math.floor(time/60);
|
}else{
|
||||||
time = time - (minutes * 60);
|
var d = max - min;
|
||||||
return [minutes, time];
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
||||||
},
|
switch(max){
|
||||||
|
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||||
|
case g: h = (b - r) / d + 2; break;
|
||||||
|
case b: h = (r - g) / d + 4; break;
|
||||||
|
}
|
||||||
|
h /= 6;
|
||||||
|
}
|
||||||
|
|
||||||
rgbToHsl: function(arr, light){
|
if(l>0.5 && light)l=0.4; //make sure it isnt too light
|
||||||
r = arr[0];
|
else if(l<0.65 && !light)l=0.65;
|
||||||
g = arr[1];
|
|
||||||
b = arr[2];
|
|
||||||
r /= 255;
|
|
||||||
g /= 255;
|
|
||||||
b /= 255;
|
|
||||||
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
||||||
var h, s, l = (max + min) / 2;
|
|
||||||
|
|
||||||
if(max == min){
|
return "hsl("+Math.floor(h*360)+", "+Math.floor(s*100)+"%, "+Math.floor(l*100)+"%)";
|
||||||
h = s = 0; // achromatic
|
},
|
||||||
}else{
|
|
||||||
var d = max - min;
|
|
||||||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
||||||
switch(max){
|
|
||||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
|
||||||
case g: h = (b - r) / d + 2; break;
|
|
||||||
case b: h = (r - g) / d + 4; break;
|
|
||||||
}
|
|
||||||
h /= 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l>0.5 && light)l=0.4; //make sure it isnt too light
|
componentToHex: function(c) {
|
||||||
else if(l<0.65 && !light)l=0.65;
|
var hex = c.toString(16);
|
||||||
|
return hex.length == 1 ? "0" + hex : hex;
|
||||||
|
},
|
||||||
|
|
||||||
return "hsl("+Math.floor(h*360)+", "+Math.floor(s*100)+"%, "+Math.floor(l*100)+"%)";
|
rgbToHex: function(r, g, b) {
|
||||||
},
|
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
|
||||||
|
},
|
||||||
|
|
||||||
componentToHex: function(c) {
|
upperFirst: function(string){
|
||||||
var hex = c.toString(16);
|
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
||||||
return hex.length == 1 ? "0" + hex : hex;
|
},
|
||||||
},
|
|
||||||
|
|
||||||
rgbToHex: function(r, g, b) {
|
addClass: function(object, toAdd){
|
||||||
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
|
if(!Helper.contains($(object).attr("class").split(" "), toAdd)){
|
||||||
},
|
$(object).addClass(toAdd);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
upperFirst: function(string){
|
send_mail: function(from, message){
|
||||||
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
if(from !== "" && message !== ""){
|
||||||
},
|
|
||||||
|
|
||||||
addClass: function(object, toAdd){
|
$("#submit-contact-form").addClass("hide");
|
||||||
if(!Helper.contains($(object).attr("class").split(" "), toAdd)){
|
$("#send-loader").removeClass("hide");
|
||||||
$(object).addClass(toAdd);
|
$("#contact-form-from").attr("disabled", "true");
|
||||||
}
|
$("#contact-form-message").attr("disabled", "true");
|
||||||
},
|
|
||||||
|
|
||||||
send_mail: function(from, message){
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
data: {from: from, message: message},
|
||||||
|
url: "/api/mail",
|
||||||
|
success: function(data){
|
||||||
|
if(data == "success"){
|
||||||
|
$("#contact-container").empty();
|
||||||
|
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
||||||
|
}else{
|
||||||
|
$("#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>")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
firstY: null,
|
||||||
|
lastY: null,
|
||||||
|
currentY: null,
|
||||||
|
vertScroll: false,
|
||||||
|
initAdjustment: 0,
|
||||||
|
|
||||||
if(from !== "" && message !== ""){
|
touchstart: function(event) {
|
||||||
|
Helper.lastY = Helper.currentY = Helper.firstY = event.originalEvent.touches[0].pageY;
|
||||||
|
},
|
||||||
|
|
||||||
$("#submit-contact-form").addClass("hide");
|
touchmove: function(event) {
|
||||||
$("#send-loader").removeClass("hide");
|
Helper.currentY = event.originalEvent.touches[0].pageY;
|
||||||
$("#contact-form-from").attr("disabled", "true");
|
var adjustment = Helper.lastY-Helper.currentY;
|
||||||
$("#contact-form-message").attr("disabled", "true");
|
|
||||||
|
|
||||||
$.ajax({
|
// Mimic native vertical scrolling where scrolling only starts after the
|
||||||
type: "POST",
|
// cursor has moved up or down from its original position by ~30 pixels.
|
||||||
data: {from: from, message: message},
|
if (!Helper.vertScroll && Math.abs(Helper.currentY-Helper.firstY) > 30) {
|
||||||
url: "/api/mail",
|
Helper.vertScroll = true;
|
||||||
success: function(data){
|
Helper.initAdjustment = Helper.currentY-Helper.firstY;
|
||||||
if(data == "success"){
|
}
|
||||||
$("#contact-container").empty();
|
|
||||||
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
|
||||||
}else{
|
|
||||||
$("#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>")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/*from = $("#contact-form-from").val();
|
|
||||||
message = $("#contact-form-message").val();
|
|
||||||
$("#contact-container").empty();
|
|
||||||
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>");
|
|
||||||
setTimeout(function(){newWindow.close();},500);*/
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
firstY: null,
|
// only apply the adjustment if the user has met the threshold for vertical scrolling
|
||||||
lastY: null,
|
if (Helper.vertScroll) {
|
||||||
currentY: null,
|
window.scrollBy(0,adjustment + Helper.initAdjustment);
|
||||||
vertScroll: false,
|
Helper.lastY = Helper.currentY + adjustment;
|
||||||
initAdjustment: 0,
|
}
|
||||||
|
|
||||||
touchstart: function(event) {
|
},
|
||||||
Helper.lastY = Helper.currentY = Helper.firstY = event.originalEvent.touches[0].pageY;
|
|
||||||
},
|
|
||||||
|
|
||||||
touchmove: function(event) {
|
touchend: function(event) {
|
||||||
Helper.currentY = event.originalEvent.touches[0].pageY;
|
Helper.vertScroll = false;
|
||||||
var adjustment = Helper.lastY-Helper.currentY;
|
Helper.firstY = null;
|
||||||
|
Helper.currentY = null;
|
||||||
|
Helper.vertScroll = false;
|
||||||
|
Helper.initAdjustment = 0;
|
||||||
|
Helper.currentY = null;
|
||||||
|
},
|
||||||
|
|
||||||
// Mimic native vertical scrolling where scrolling only starts after the
|
invertColor: function(hex) {
|
||||||
// cursor has moved up or down from its original position by ~30 pixels.
|
if (hex.indexOf('#') === 0) {
|
||||||
if (!Helper.vertScroll && Math.abs(Helper.currentY-Helper.firstY) > 30) {
|
hex = hex.slice(1);
|
||||||
Helper.vertScroll = true;
|
}
|
||||||
Helper.initAdjustment = Helper.currentY-Helper.firstY;
|
// convert 3-digit hex to 6-digits.
|
||||||
}
|
if (hex.length === 3) {
|
||||||
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
||||||
// only apply the adjustment if the user has met the threshold for vertical scrolling
|
}
|
||||||
if (Helper.vertScroll) {
|
if (hex.length !== 6) {
|
||||||
window.scrollBy(0,adjustment + Helper.initAdjustment);
|
throw new Error('Invalid HEX color.');
|
||||||
Helper.lastY = Helper.currentY + adjustment;
|
}
|
||||||
}
|
// invert color components
|
||||||
|
var r = (255 - parseInt(hex.slice(0, 2), 16)).toString(16),
|
||||||
},
|
|
||||||
|
|
||||||
touchend: function(event) {
|
|
||||||
Helper.vertScroll = false;
|
|
||||||
Helper.firstY = null;
|
|
||||||
Helper.currentY = null;
|
|
||||||
Helper.vertScroll = false;
|
|
||||||
Helper.initAdjustment = 0;
|
|
||||||
Helper.currentY = null;
|
|
||||||
},
|
|
||||||
|
|
||||||
invertColor: function(hex) {
|
|
||||||
if (hex.indexOf('#') === 0) {
|
|
||||||
hex = hex.slice(1);
|
|
||||||
}
|
|
||||||
// convert 3-digit hex to 6-digits.
|
|
||||||
if (hex.length === 3) {
|
|
||||||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
||||||
}
|
|
||||||
if (hex.length !== 6) {
|
|
||||||
throw new Error('Invalid HEX color.');
|
|
||||||
}
|
|
||||||
// invert color components
|
|
||||||
var r = (255 - parseInt(hex.slice(0, 2), 16)).toString(16),
|
|
||||||
g = (255 - parseInt(hex.slice(2, 4), 16)).toString(16),
|
g = (255 - parseInt(hex.slice(2, 4), 16)).toString(16),
|
||||||
b = (255 - parseInt(hex.slice(4, 6), 16)).toString(16);
|
b = (255 - parseInt(hex.slice(4, 6), 16)).toString(16);
|
||||||
// pad each with zeros and return
|
// pad each with zeros and return
|
||||||
return '#' + padZero(r) + padZero(g) + padZero(b);
|
return '#' + padZero(r) + padZero(g) + padZero(b);
|
||||||
},
|
},
|
||||||
|
|
||||||
padZero: function(str, len) {
|
padZero: function(str, len) {
|
||||||
len = len || 2;
|
len = len || 2;
|
||||||
var zeros = new Array(len).join('0');
|
var zeros = new Array(len).join('0');
|
||||||
return (zeros + str).slice(-len);
|
return (zeros + str).slice(-len);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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,63 +1,63 @@
|
|||||||
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;
|
||||||
}
|
}
|
||||||
if(embed) {
|
if(embed) {
|
||||||
if(window.parentWindow && window.parentOrigin) {
|
if(window.parentWindow && window.parentOrigin) {
|
||||||
window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin);
|
window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
began = true;
|
||||||
setup_host_listener(id);
|
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()))});
|
||||||
|
|
||||||
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
|
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
|
||||||
} else if(arr.type == "pause") {
|
} else if(arr.type == "pause") {
|
||||||
Player.pauseVideo();
|
Player.pauseVideo();
|
||||||
} else if(arr.type == "play") {
|
} else if(arr.type == "play") {
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
} else if(arr.type == "skip") {
|
} else if(arr.type == "skip") {
|
||||||
List.skip();
|
List.skip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
change_enabled:function(val){
|
change_enabled:function(val){
|
||||||
enabled = val;
|
enabled = val;
|
||||||
$(".remote_switch_class").prop("checked", enabled);
|
$(".remote_switch_class").prop("checked", enabled);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,251 +1,225 @@
|
|||||||
var Playercontrols = {
|
var Playercontrols = {
|
||||||
|
|
||||||
stopInterval: false,
|
stopInterval: false,
|
||||||
|
|
||||||
initYoutubeControls: function()
|
initYoutubeControls: function() {
|
||||||
{
|
if(Helper.mobilecheck() && !window.MSStream) {
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
$("#controls").appendTo("#playbar");
|
||||||
$("#controls").appendTo("#playbar");
|
}
|
||||||
}
|
Playercontrols.initControls();
|
||||||
Playercontrols.initControls();
|
},
|
||||||
},
|
|
||||||
|
|
||||||
initControls: function()
|
initControls: function() {
|
||||||
{
|
$("#volume-button").on("click", Playercontrols.mute_video);
|
||||||
document.getElementById("volume-button").addEventListener("click", Playercontrols.mute_video);
|
$("#playpause").on("click", Playercontrols.play_pause);
|
||||||
document.getElementById("playpause").addEventListener("click", Playercontrols.play_pause);
|
$("#volume-button-overlay").on("click", Playercontrols.mute_video);
|
||||||
document.getElementById("volume-button-overlay").addEventListener("click", Playercontrols.mute_video);
|
$("#playpause-overlay").on("click", Playercontrols.play_pause);
|
||||||
document.getElementById("playpause-overlay").addEventListener("click", Playercontrols.play_pause);
|
$("#fullscreen").on("click", Playercontrols.fullscreen);
|
||||||
document.getElementById("fullscreen").addEventListener("click", Playercontrols.fullscreen);
|
},
|
||||||
|
|
||||||
},
|
initSlider: function() {
|
||||||
|
try {
|
||||||
|
vol = (Crypt.get_volume());
|
||||||
|
} catch(e){}
|
||||||
|
$("#volume").slider({
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
value: vol,
|
||||||
|
range: "min",
|
||||||
|
animate: true,
|
||||||
|
slide: function(event, ui) {
|
||||||
|
|
||||||
initSlider: function()
|
Playercontrols.setVolume(ui.value);
|
||||||
{
|
try{Crypt.set_volume(ui.value);}catch(e){}
|
||||||
try{
|
}
|
||||||
vol = (Crypt.get_volume());
|
});
|
||||||
}catch(e){}
|
Playercontrols.choose_button(vol, false);
|
||||||
$("#volume").slider({
|
},
|
||||||
min: 0,
|
|
||||||
max: 100,
|
|
||||||
value: vol,
|
|
||||||
range: "min",
|
|
||||||
animate: true,
|
|
||||||
slide: function(event, ui) {
|
|
||||||
|
|
||||||
Playercontrols.setVolume(ui.value);
|
fullscreen: function() {
|
||||||
//localStorage.setItem("volume", ui.value);
|
var playerElement = $("#player");
|
||||||
try{Crypt.set_volume(ui.value);}catch(e){}
|
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
||||||
}
|
if (requestFullScreen) {
|
||||||
});
|
requestFullScreen.bind(playerElement)();
|
||||||
Playercontrols.choose_button(vol, false);
|
}
|
||||||
//$("#volume").slider("value", player.getVolume());
|
},
|
||||||
},
|
|
||||||
|
|
||||||
fullscreen: function()
|
play_pause: function() {
|
||||||
{
|
if(!chromecastAvailable){
|
||||||
var playerElement = document.getElementById("player");
|
if(Player.player.getPlayerState() == YT.PlayerState.PLAYING)
|
||||||
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
{
|
||||||
if (requestFullScreen) {
|
Player.pauseVideo();
|
||||||
requestFullScreen.bind(playerElement)();
|
if(Helper.mobilecheck() && !window.MSStream){
|
||||||
}
|
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||||
},
|
//document.getElementById("player").style.display = "none";
|
||||||
|
$("#player").css("display", "none");
|
||||||
|
$(".video-container").toggleClass("click-through");
|
||||||
|
$(".page-footer").toggleClass("padding-bottom-extra");
|
||||||
|
}
|
||||||
|
} else if(Player.player.getPlayerState() == YT.PlayerState.PAUSED || Player.player.getPlayerState() === YT.PlayerState.ENDED || (Player.player.getPlayerState() === YT.PlayerState.CUED)){
|
||||||
|
Player.playVideo();
|
||||||
|
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||||
|
if(Helper.mobilecheck() && !window.MSStream){
|
||||||
|
//document.getElementById("player").style.display = "block";
|
||||||
|
$("#player").css("display", "block");
|
||||||
|
$(".video-container").toggleClass("click-through");
|
||||||
|
$(".page-footer").toggleClass("padding-bottom-extra");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Playercontrols.play_pause_show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
play_pause: function()
|
play_pause_show: function() {
|
||||||
{
|
if(chromecastAvailable){
|
||||||
if(!chromecastAvailable){
|
if($("#play").hasClass("hide")){
|
||||||
if(Player.player.getPlayerState() == YT.PlayerState.PLAYING)
|
Player.pauseVideo();
|
||||||
{
|
} else if($("#pause").hasClass("hide")){
|
||||||
Player.pauseVideo();
|
Player.playVideo();
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
}
|
||||||
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
} else {
|
||||||
document.getElementById("player").style.display = "none";
|
|
||||||
$(".video-container").toggleClass("click-through");
|
|
||||||
$(".page-footer").toggleClass("padding-bottom-extra");
|
|
||||||
}
|
|
||||||
} else if(Player.player.getPlayerState() == YT.PlayerState.PAUSED || Player.player.getPlayerState() === YT.PlayerState.ENDED || (Player.player.getPlayerState() === YT.PlayerState.CUED)){
|
|
||||||
Player.playVideo();
|
|
||||||
//if(Helper.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
|
||||||
if(Helper.mobilecheck() && !window.MSStream){
|
|
||||||
document.getElementById("player").style.display = "block";
|
|
||||||
$(".video-container").toggleClass("click-through");
|
|
||||||
$(".page-footer").toggleClass("padding-bottom-extra");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Playercontrols.play_pause_show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
play_pause_show: function()
|
if(!$("#pause").hasClass("hide")) {
|
||||||
{
|
$("#pause").toggleClass("hide");
|
||||||
if(chromecastAvailable){
|
$("#pause-overlay").toggleClass("hide");
|
||||||
if($("#play").hasClass("hide")){
|
}
|
||||||
Player.pauseVideo();
|
if($("#play").hasClass("hide")) {
|
||||||
} else if($("#pause").hasClass("hide")){
|
$("#play").toggleClass("hide");
|
||||||
Player.playVideo();
|
$("#play-overlay").toggleClass("hide");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
},
|
||||||
|
|
||||||
if(document.getElementById("pause").className.split(" ").length == 1){
|
settings: function() {
|
||||||
$("#pause").toggleClass("hide");
|
$("#qS").toggleClass("hide");
|
||||||
$("#pause-overlay").toggleClass("hide");
|
},
|
||||||
}
|
|
||||||
if(document.getElementById("play").className.split(" ").length == 2){
|
|
||||||
$("#play").toggleClass("hide");
|
|
||||||
$("#play-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
settings: function()
|
changeQuality: function(wantedQ) {
|
||||||
{
|
if(Player.player.getPlaybackQuality != wantedQ) {
|
||||||
$("#qS").toggleClass("hide");
|
Player.player.setPlaybackQuality(wantedQ);
|
||||||
},
|
Player.player.getPlaybackQuality();
|
||||||
|
}
|
||||||
|
$("#qS").toggleClass("hide");
|
||||||
|
},
|
||||||
|
|
||||||
changeQuality: function(wantedQ)
|
mute_video: function() {
|
||||||
{
|
if(!Player.player.isMuted()) {
|
||||||
if(Player.player.getPlaybackQuality != wantedQ)
|
if(chromecastAvailable) castSession.sendMessage("urn:x-cast:zoff.me", {type: "mute"});
|
||||||
{
|
Playercontrols.choose_button(0, true);
|
||||||
Player.player.setPlaybackQuality(wantedQ);
|
Player.player.mute();
|
||||||
Player.player.getPlaybackQuality();
|
} else {
|
||||||
}
|
if(chromecastAvailable)castSession.sendMessage("urn:x-cast:zoff.me", {type: "unMute"});
|
||||||
$("#qS").toggleClass("hide");
|
Player.player.unMute();
|
||||||
},
|
Playercontrols.choose_button(Player.player.getVolume(), false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
mute_video: function()
|
setVolume: function(vol) {
|
||||||
{
|
Player.setVolume(vol);
|
||||||
if(!Player.player.isMuted())
|
Playercontrols.choose_button(vol, false);
|
||||||
{
|
if(Player.player.isMuted())
|
||||||
if(chromecastAvailable) castSession.sendMessage("urn:x-cast:zoff.me", {type: "mute"});
|
Player.player.unMute();
|
||||||
Playercontrols.choose_button(0, true);
|
},
|
||||||
Player.player.mute();
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
if(chromecastAvailable)castSession.sendMessage("urn:x-cast:zoff.me", {type: "unMute"});
|
|
||||||
Player.player.unMute();
|
|
||||||
Playercontrols.choose_button(Player.player.getVolume(), false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setVolume: function(vol)
|
choose_button: function(vol, mute) {
|
||||||
{
|
if(!mute){
|
||||||
Player.setVolume(vol);
|
if(vol >= 0 && vol <= 33) {
|
||||||
Playercontrols.choose_button(vol, false);
|
if(!$("#v-full").hasClass("hide")) {
|
||||||
if(Player.player.isMuted())
|
$("#v-full").toggleClass("hide");
|
||||||
Player.player.unMute();
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
},
|
}
|
||||||
|
if(!$("#v-medium").hasClass("hide")) {
|
||||||
|
$("#v-medium").toggleClass("hide");
|
||||||
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if($("#v-low").hasClass("hide")) {
|
||||||
|
$("#v-low").toggleClass("hide");
|
||||||
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-mute").hasClass("hide")) {
|
||||||
|
$("#v-mute").toggleClass("hide");
|
||||||
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
} else if(vol >= 34 && vol <= 66) {
|
||||||
|
if(!$("#v-full").hasClass("hide")) {
|
||||||
|
$("#v-full").toggleClass("hide");
|
||||||
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if($("#v-medium").hasClass("hide")) {
|
||||||
|
$("#v-medium").toggleClass("hide");
|
||||||
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-low").hasClass("hide")) {
|
||||||
|
$("#v-low").toggleClass("hide");
|
||||||
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-mute").hasClass("hide")) {
|
||||||
|
$("#v-mute").toggleClass("hide");
|
||||||
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
} else if(vol >= 67 && vol <= 100) {
|
||||||
|
if($("#v-full").hasClass("hide")) {
|
||||||
|
$("#v-full").toggleClass("hide");
|
||||||
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-medium").hasClass("hide")) {
|
||||||
|
$("#v-medium").toggleClass("hide");
|
||||||
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-low").hasClass("hide")) {
|
||||||
|
$("#v-low").toggleClass("hide");
|
||||||
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-mute").hasClass("hide")) {
|
||||||
|
$("#v-mute").toggleClass("hide");
|
||||||
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!$("#v-full").hasClass("hide")) {
|
||||||
|
$("#v-full").toggleClass("hide");
|
||||||
|
$("#v-full-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-medium").hasClass("hide")) {
|
||||||
|
$("#v-medium").toggleClass("hide");
|
||||||
|
$("#v-medium-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if(!$("#v-low").hasClass("hide")) {
|
||||||
|
$("#v-low").toggleClass("hide");
|
||||||
|
$("#v-low-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
if($("#v-mute").hasClass("hide")) {
|
||||||
|
$("#v-mute").toggleClass("hide");
|
||||||
|
$("#v-mute-overlay").toggleClass("hide");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
choose_button: function(vol, mute)
|
playPause: function() {
|
||||||
{
|
state = Player.player.getPlayerState();
|
||||||
if(!mute){
|
button = document.getElementById("playpause");
|
||||||
if(vol >= 0 && vol <= 33){
|
if(state == YT.PlayerState.PLAYING) {
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
Player.pauseVideo();
|
||||||
$("#v-full").toggleClass("hide");
|
} else if(state == YT.PlayerState.PAUSED) {
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
Player.playVideo();
|
||||||
}
|
}
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
},
|
||||||
$("#v-medium").toggleClass("hide");
|
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 2){
|
|
||||||
$("#v-low").toggleClass("hide");
|
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
|
||||||
$("#v-mute").toggleClass("hide");
|
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
}else if(vol >= 34 && vol <= 66){
|
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
|
||||||
$("#v-full").toggleClass("hide");
|
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 2){
|
|
||||||
$("#v-medium").toggleClass("hide");
|
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
|
||||||
$("#v-low").toggleClass("hide");
|
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
|
||||||
$("#v-mute").toggleClass("hide");
|
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
}else if(vol >= 67 && vol <= 100){
|
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 2){
|
|
||||||
$("#v-full").toggleClass("hide");
|
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
|
||||||
$("#v-medium").toggleClass("hide");
|
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
|
||||||
$("#v-low").toggleClass("hide");
|
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 1){
|
|
||||||
$("#v-mute").toggleClass("hide");
|
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
if(document.getElementById("v-full").className.split(" ").length == 1){
|
|
||||||
$("#v-full").toggleClass("hide");
|
|
||||||
$("#v-full-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-medium").className.split(" ").length == 1){
|
|
||||||
$("#v-medium").toggleClass("hide");
|
|
||||||
$("#v-medium-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-low").className.split(" ").length == 1){
|
|
||||||
$("#v-low").toggleClass("hide");
|
|
||||||
$("#v-low-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
if(document.getElementById("v-mute").className.split(" ").length == 2){
|
|
||||||
$("#v-mute").toggleClass("hide");
|
|
||||||
$("#v-mute-overlay").toggleClass("hide");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
playPause: function()
|
volumeOptions: function() {
|
||||||
{
|
if(!chromecastAvailable) {
|
||||||
state = Player.player.getPlayerState();
|
if(Player.player.isMuted()) {
|
||||||
button = document.getElementById("playpause");
|
Player.player.unMute();
|
||||||
if(state == YT.PlayerState.PLAYING)
|
vol = Player.player.getVolume();
|
||||||
{
|
$("#volume").slider("value", Player.player.getVolume());
|
||||||
Player.pauseVideo();
|
} else {
|
||||||
}else if(state == YT.PlayerState.PAUSED)
|
Player.player.mute();
|
||||||
{
|
$("#volume").slider("value", 0);
|
||||||
Player.playVideo();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
volumeOptions: function()
|
|
||||||
{
|
|
||||||
if(!chromecastAvailable){
|
|
||||||
if(Player.player.isMuted())
|
|
||||||
{
|
|
||||||
Player.player.unMute();
|
|
||||||
vol = Player.player.getVolume();
|
|
||||||
$("#volume").slider("value", Player.player.getVolume());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Player.player.mute();
|
|
||||||
$("#volume").slider("value", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
hoverMute: function(foo)
|
|
||||||
{
|
|
||||||
vol = Player.player.getVolume();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
hoverMute: function(foo) {
|
||||||
|
vol = Player.player.getVolume();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,116 +1,86 @@
|
|||||||
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{
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "https://api.github.com/users/zoff-music/received_events",
|
|
||||||
success: function(git_info){
|
|
||||||
for(var i = 0; i < git_info.length; i++) {
|
|
||||||
if(git_info[i].type == "PushEvent") {
|
|
||||||
$("#latest-commit").html("Latest Commit: <br>" +
|
|
||||||
git_info[0].created_at.substring(0,10) +
|
|
||||||
": " + git_info[0].actor.display_login +
|
|
||||||
"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/" + git_info[0].payload.commits[0].sha + "' target='_blank'>" +
|
|
||||||
git_info[0].payload.commits[0].sha.substring(0,10) + "</a>: " +
|
|
||||||
git_info[0].payload.commits[0].message+"<br");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch(error){
|
|
||||||
Helper.log("Error with fetching GitHub commit info");
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(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();
|
||||||
Remotecontroller.control();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var Remotecontroller = {
|
var Remotecontroller = {
|
||||||
|
|
||||||
control: function()
|
control: function() {
|
||||||
{
|
if(start) {
|
||||||
if(start)
|
if(!id) {
|
||||||
{
|
id = document.getElementById("remoteform").chan.value;
|
||||||
if(!id)
|
window.history.pushState("object or string", "Title", "/"+id);
|
||||||
{
|
}
|
||||||
id = document.getElementById("remoteform").chan.value;
|
document.getElementById("remoteform").chan.value = "";
|
||||||
window.history.pushState("object or string", "Title", "/"+id);
|
start = false;
|
||||||
}
|
|
||||||
document.getElementById("remoteform").chan.value = "";
|
|
||||||
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,
|
||||||
stop:function(event, ui) {
|
stop:function(event, ui) {
|
||||||
socket.emit("id", {id: id, type: "volume", value: ui.value});
|
socket.emit("id", {id: id, type: "volume", value: ui.value});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else
|
} else {
|
||||||
{
|
socket.emit("id", {id: id, type: "channel", value: $("#search").val().toLowerCase()});
|
||||||
socket.emit("id", {id: id, type: "channel", value: $("#search").val().toLowerCase()});
|
$("#search").val("");
|
||||||
$("#search").val("");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,415 +1,415 @@
|
|||||||
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").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").focus();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
search: function(search_input, retried, related){
|
search: function(search_input, retried, related){
|
||||||
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);
|
||||||
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(related) {
|
if(related) {
|
||||||
var yt_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&relatedToVideoId="+keyword+"&type=video&key="+api_key;
|
var yt_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&relatedToVideoId="+keyword+"&type=video&key="+api_key;
|
||||||
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){
|
||||||
$.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(".open-externally").attr("href", "https://www.youtube.com/watch?v=" + id);
|
songs.find(".open-externally").attr("href", "https://www.youtube.com/watch?v=" + id);
|
||||||
//$($(songs).find("div")[0]).attr("id", id)
|
//$($(songs).find("div")[0]).attr("id", id)
|
||||||
//output += undefined;
|
//output += undefined;
|
||||||
if(songs.html() != undefined) {
|
if(songs.html() != undefined) {
|
||||||
output += songs.html();
|
output += songs.html();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(output.length > 0) {
|
if(output.length > 0) {
|
||||||
|
|
||||||
$("<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 if(!retried){
|
} else if(!retried){
|
||||||
Search.search(search_input, true);
|
Search.search(search_input, true);
|
||||||
} else {
|
} else {
|
||||||
$("<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 {
|
} else {
|
||||||
$(".main").removeClass("blurT");
|
$(".main").removeClass("blurT");
|
||||||
$("#controls").removeClass("blurT");
|
$("#controls").removeClass("blurT");
|
||||||
$(".main").removeClass("clickthrough");
|
$(".main").removeClass("clickthrough");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
backgroundSearch: function(title, artist, length, totalNumber, current){
|
backgroundSearch: function(title, artist, length, totalNumber, current){
|
||||||
var keyword= encodeURIComponent(title + " " + artist);
|
var keyword= encodeURIComponent(title + " " + artist);
|
||||||
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";
|
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";
|
||||||
yt_url+="&q="+keyword;
|
yt_url+="&q="+keyword;
|
||||||
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=";
|
||||||
artist = artist.split(" ");
|
artist = artist.split(" ");
|
||||||
var temptitle = title.split("-");
|
var temptitle = title.split("-");
|
||||||
temptitle = temptitle.join(" ").split(" ");
|
temptitle = temptitle.join(" ").split(" ");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: yt_url,
|
url: yt_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
//Helper.log(response);
|
//Helper.log(response);
|
||||||
if(response.items.length === 0){
|
if(response.items.length === 0){
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
Helper.log("------------------------------");
|
Helper.log("------------------------------");
|
||||||
Helper.log("NO MATCH FOR:");
|
Helper.log("NO MATCH FOR:");
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
Helper.log("Spotify length: " + length);
|
Helper.log("Spotify length: " + length);
|
||||||
Helper.log("------------------------------");
|
Helper.log("------------------------------");
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
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").text(title + " - " + artist.join(" "));
|
||||||
not_added_song.find(".extra-add-text").attr("title", 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_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
||||||
$(".not-imported-container").append(not_added_song.html());
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
$(".not-imported").removeClass("hide");
|
$(".not-imported").removeClass("hide");
|
||||||
} else if(response.items.length > 0) {
|
} else if(response.items.length > 0) {
|
||||||
$.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){
|
||||||
if(response.items.length > 0) {
|
if(response.items.length > 0) {
|
||||||
var matched = false;
|
var matched = false;
|
||||||
$.each(response.items, function(i, data){
|
$.each(response.items, function(i, data){
|
||||||
//Helper.log(data);
|
//Helper.log(data);
|
||||||
//var title = data.snippet.title;
|
//var title = data.snippet.title;
|
||||||
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
||||||
var not_matched = false;
|
var not_matched = false;
|
||||||
$.each(temptitle, function(i, data_title){
|
$.each(temptitle, function(i, data_title){
|
||||||
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
||||||
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
title.toLowerCase().indexOf("cover") == -1 &&
|
title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
((data.snippet.title.toLowerCase().indexOf("remix") == -1 &&
|
||||||
title.toLowerCase().indexOf("remix") == -1) ||
|
title.toLowerCase().indexOf("remix") == -1) ||
|
||||||
(data.snippet.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 &&
|
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(artist[0].toLowerCase()) == -1 &&
|
||||||
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)))
|
data.snippet.channelTitle.toLowerCase().indexOf("vevo") == -1)))
|
||||||
))
|
))
|
||||||
not_matched = true;
|
not_matched = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if((!not_matched)){
|
if((!not_matched)){
|
||||||
matched = true;
|
matched = true;
|
||||||
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!matched){
|
if(!matched){
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
Helper.log("------------------------------");
|
Helper.log("------------------------------");
|
||||||
Helper.log("NO MATCH FOR:");
|
Helper.log("NO MATCH FOR:");
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
||||||
Helper.log("Spotify length: " + length);
|
Helper.log("Spotify length: " + length);
|
||||||
Helper.log("------------------------------");
|
Helper.log("------------------------------");
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
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").text(title + " - " + artist.join(" "));
|
||||||
not_added_song.find(".extra-add-text").attr("title", 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_added_song.find(".extra-button-search").attr("data-text", title + " - " + artist.join(" "));
|
||||||
$(".not-imported-container").append(not_added_song.html());
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
$(".not-imported").removeClass("hide");
|
$(".not-imported").removeClass("hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
readySubmit: function(found, obj){
|
readySubmit: function(found, obj){
|
||||||
if(Search.submitArrayExpected === null){
|
if(Search.submitArrayExpected === null){
|
||||||
Search.submitArrayExpected = obj.totalLength;
|
Search.submitArrayExpected = obj.totalLength;
|
||||||
}
|
}
|
||||||
if(found){
|
if(found){
|
||||||
Search.submitArray.push(obj);
|
Search.submitArray.push(obj);
|
||||||
} else {
|
} else {
|
||||||
Search.submitArrayExpected -= 1;
|
Search.submitArrayExpected -= 1;
|
||||||
}
|
}
|
||||||
if((Search.submitArray.length - 1) == Search.submitArrayExpected) {
|
if((Search.submitArray.length - 1) == Search.submitArrayExpected) {
|
||||||
$.each(Search.submitArray, function(i, data){
|
$.each(Search.submitArray, function(i, data){
|
||||||
Search.submit(data.id, data.title, data.duration, true, i, Search.submitArray.length - 1);
|
Search.submit(data.id, data.title, data.duration, true, i, Search.submitArray.length - 1);
|
||||||
});
|
});
|
||||||
document.getElementById("import_spotify").disabled = false;
|
document.getElementById("import_spotify").disabled = false;
|
||||||
$("#import_spotify").removeClass("hide");
|
$("#import_spotify").removeClass("hide");
|
||||||
$("#playlist_loader_spotify").addClass("hide");
|
$("#playlist_loader_spotify").addClass("hide");
|
||||||
Search.submitArray = [];
|
Search.submitArray = [];
|
||||||
Search.submitArrayExpected = null;
|
Search.submitArrayExpected = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
submitAndClose: function(id,title,duration){
|
submitAndClose: function(id,title,duration){
|
||||||
Search.submit(id,title, duration, false, 0, 1);
|
Search.submit(id,title, duration, false, 0, 1);
|
||||||
$("#results").html('');
|
$("#results").html('');
|
||||||
Search.showSearch();
|
Search.showSearch();
|
||||||
document.getElementById("search").value = "";
|
document.getElementById("search").value = "";
|
||||||
$("#results").html = "";
|
$("#results").html = "";
|
||||||
$(".main").removeClass("blurT");
|
$(".main").removeClass("blurT");
|
||||||
$("#controls").removeClass("blurT");
|
$("#controls").removeClass("blurT");
|
||||||
$(".main").removeClass("clickthrough");
|
$(".main").removeClass("clickthrough");
|
||||||
},
|
},
|
||||||
|
|
||||||
importPlaylist: function(pId,pageToken){
|
importPlaylist: function(pId,pageToken){
|
||||||
token = "";
|
token = "";
|
||||||
var headers;
|
var headers;
|
||||||
var datatype;
|
var datatype;
|
||||||
if(pageToken !== undefined)
|
if(pageToken !== undefined)
|
||||||
token = "&pageToken="+pageToken;
|
token = "&pageToken="+pageToken;
|
||||||
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key+"&playlistId="+pId+token;
|
playlist_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=49&key="+api_key+"&playlistId="+pId+token;
|
||||||
if(youtube_authenticated){
|
if(youtube_authenticated){
|
||||||
datatype = "html";
|
datatype = "html";
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer ' + access_token_data_youtube.access_token
|
'Authorization': 'Bearer ' + access_token_data_youtube.access_token
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
headers = {};//'Content-Type': 'application/json'};
|
headers = {};//'Content-Type': 'application/json'};
|
||||||
datatype = "jsonp";
|
datatype = "jsonp";
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: playlist_url,
|
url: playlist_url,
|
||||||
dataType: datatype,
|
dataType: datatype,
|
||||||
//dataType:"jsonp",
|
//dataType:"jsonp",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
if(response.error){
|
if(response.error){
|
||||||
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
||||||
var nonce = randomString(29);
|
var nonce = randomString(29);
|
||||||
window.callback = function(data) {
|
window.callback = function(data) {
|
||||||
access_token_data_youtube = data;
|
access_token_data_youtube = data;
|
||||||
if(access_token_data_youtube.state == nonce){
|
if(access_token_data_youtube.state == nonce){
|
||||||
youtube_authenticated = true;
|
youtube_authenticated = true;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
youtube_authenticated = false;
|
youtube_authenticated = false;
|
||||||
access_token_data_youtube = {};
|
access_token_data_youtube = {};
|
||||||
}, access_token_data_youtube.expires_in * 1000);
|
}, access_token_data_youtube.expires_in * 1000);
|
||||||
Search.importPlaylist(pId, pageToken);
|
Search.importPlaylist(pId, pageToken);
|
||||||
} else {
|
} else {
|
||||||
access_token_data_youtube = "";
|
access_token_data_youtube = "";
|
||||||
console.error("Nonce doesn't match");
|
console.error("Nonce doesn't match");
|
||||||
}
|
}
|
||||||
youtube_window.close();
|
youtube_window.close();
|
||||||
window.callback = "";
|
window.callback = "";
|
||||||
};
|
};
|
||||||
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
||||||
} else {
|
} else {
|
||||||
Helper.log(response.error);
|
Helper.log(response.error);
|
||||||
document.getElementById("import").disabled = false;
|
document.getElementById("import").disabled = false;
|
||||||
$("#playlist_loader").addClass("hide");
|
$("#playlist_loader").addClass("hide");
|
||||||
$("#import").removeClass("hide");
|
$("#import").removeClass("hide");
|
||||||
before_toast();
|
before_toast();
|
||||||
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var ids="";
|
var ids="";
|
||||||
if(typeof(response) == "string") response = $.parseJSON(response);
|
if(typeof(response) == "string") response = $.parseJSON(response);
|
||||||
//Search.addVideos(response.items[0].contentDetails.videoId);
|
//Search.addVideos(response.items[0].contentDetails.videoId);
|
||||||
//response.items.shift();
|
//response.items.shift();
|
||||||
$.each(response.items, function(i,data)
|
$.each(response.items, function(i,data)
|
||||||
{
|
{
|
||||||
ids+=data.contentDetails.videoId+",";
|
ids+=data.contentDetails.videoId+",";
|
||||||
});
|
});
|
||||||
Search.addVideos(ids, true);
|
Search.addVideos(ids, true);
|
||||||
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
if(response.nextPageToken) Search.importPlaylist(pId, response.nextPageToken);
|
||||||
document.getElementById("import").value = "";
|
document.getElementById("import").value = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
importSpotifyPlaylist: function(url){
|
importSpotifyPlaylist: function(url){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$.each(response.items, function(i,data)
|
$.each(response.items, function(i,data)
|
||||||
{
|
{
|
||||||
//ids+=data.contentDetails.videoId+",";
|
//ids+=data.contentDetails.videoId+",";
|
||||||
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);
|
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);
|
||||||
|
|
||||||
});
|
});
|
||||||
if(response.next){
|
if(response.next){
|
||||||
Search.importSpotifyPlaylist(response.next);
|
Search.importSpotifyPlaylist(response.next);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
document.getElementById("import_spotify").disabled = false;
|
document.getElementById("import_spotify").disabled = false;
|
||||||
$("#import_spotify").removeClass("hide");
|
$("#import_spotify").removeClass("hide");
|
||||||
$("#playlist_loader_spotify").addClass("hide");
|
$("#playlist_loader_spotify").addClass("hide");
|
||||||
before_toast();
|
before_toast();
|
||||||
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
Materialize.toast("It seems you've entered a invalid url.", 4000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
addVideos: function(ids, playlist){
|
addVideos: function(ids, playlist){
|
||||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
||||||
request_url += ids;
|
request_url += ids;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: request_url,
|
url: request_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var to_add = [];
|
var to_add = [];
|
||||||
$.each(response.items, function(i,song)
|
$.each(response.items, function(i,song)
|
||||||
{
|
{
|
||||||
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
||||||
if(!longsongs || duration<720){
|
if(!longsongs || duration<720){
|
||||||
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
||||||
//Search.submit(song.id, enc_title, duration, playlist, i);
|
//Search.submit(song.id, enc_title, duration, playlist, i);
|
||||||
x += 1;
|
x += 1;
|
||||||
to_add.push({id: song.id, enc_title: enc_title, duration: duration, playlist: playlist});
|
to_add.push({id: song.id, enc_title: enc_title, duration: duration, playlist: playlist});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.each(to_add, function(i, item){
|
$.each(to_add, function(i, item){
|
||||||
Search.submit(item.id, item.enc_title, item.duration, item.playlist, i, x);
|
Search.submit(item.id, item.enc_title, item.duration, item.playlist, i, x);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
submit: function(id,title,duration, playlist, num, full_num){
|
submit: function(id,title,duration, playlist, num, full_num){
|
||||||
if(offline && document.getElementsByName("addsongs")[0].checked && document.getElementsByName("addsongs")[0].disabled){
|
if(offline && document.getElementsByName("addsongs")[0].checked && document.getElementsByName("addsongs")[0].disabled){
|
||||||
var found_array = [];
|
var found_array = [];
|
||||||
found_array = $.map(full_playlist, function(obj, index) {
|
found_array = $.map(full_playlist, function(obj, index) {
|
||||||
if(obj.id == id) {
|
if(obj.id == id) {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(found_array.length == 0){
|
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}});
|
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 {
|
||||||
List.vote(id, "pos");
|
List.vote(id, "pos");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
socket.emit("add", {id: id, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
socket.emit("add", {id: id, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(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]);
|
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||||
},
|
},
|
||||||
|
|
||||||
durationToSeconds: function(duration) {
|
durationToSeconds: function(duration) {
|
||||||
var matches = duration.match(time_regex);
|
var matches = duration.match(time_regex);
|
||||||
hours= parseInt(matches[12])||0;
|
hours= parseInt(matches[12])||0;
|
||||||
minutes= parseInt(matches[14])||0;
|
minutes= parseInt(matches[14])||0;
|
||||||
seconds= parseInt(matches[16])||0;
|
seconds= parseInt(matches[16])||0;
|
||||||
return hours*60*60+minutes*60+seconds;
|
return hours*60*60+minutes*60+seconds;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,80 +1,79 @@
|
|||||||
var Suggestions = {
|
var Suggestions = {
|
||||||
|
|
||||||
catchUserSuggests: function(params, single){
|
catchUserSuggests: function(params, single){
|
||||||
if(single) {
|
if(single) {
|
||||||
number_suggested = number_suggested + 1;
|
number_suggested = number_suggested + 1;
|
||||||
} else {
|
} else {
|
||||||
number_suggested = number_suggested + params.length;
|
number_suggested = number_suggested + params.length;
|
||||||
}
|
}
|
||||||
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){
|
||||||
Suggestions.createSuggested(params);
|
Suggestions.createSuggested(params);
|
||||||
}else{
|
}else{
|
||||||
for(var x in params){
|
for(var x in params){
|
||||||
Suggestions.createSuggested(params[x]);
|
Suggestions.createSuggested(params[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Suggestions.checkUserEmpty();
|
Suggestions.checkUserEmpty();
|
||||||
},
|
},
|
||||||
|
|
||||||
createSuggested: function(params){
|
createSuggested: function(params){
|
||||||
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 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);
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchYoutubeSuggests: function(id){
|
fetchYoutubeSuggests: function(id){
|
||||||
|
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key;
|
||||||
|
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
|
|
||||||
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key;
|
$.ajax({
|
||||||
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
type: "GET",
|
||||||
|
url: get_url,
|
||||||
|
dataType:"jsonp",
|
||||||
|
success: function(response)
|
||||||
|
{
|
||||||
|
$.each(response.items.slice(0,5), function(i,data){
|
||||||
|
video_urls += data.id.videoId+",";
|
||||||
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: get_url,
|
url: video_urls,
|
||||||
dataType:"jsonp",
|
dataType: "jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
$.each(response.items.slice(0,5), function(i,data){
|
$("#suggest-song-html").empty();
|
||||||
video_urls += data.id.videoId+",";
|
|
||||||
});
|
|
||||||
|
|
||||||
$.ajax({
|
$.each(response.items, function(i,song)
|
||||||
type: "GET",
|
{
|
||||||
url: video_urls,
|
var duration = song.contentDetails.duration;
|
||||||
dataType: "jsonp",
|
var length = Search.durationToSeconds(duration);
|
||||||
success: function(response)
|
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
||||||
{
|
var video_id = song.id;
|
||||||
$("#suggest-song-html").empty();
|
var video_title = song.snippet.title;
|
||||||
|
|
||||||
$.each(response.items, function(i,song)
|
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
||||||
{
|
});
|
||||||
var duration = song.contentDetails.duration;
|
}
|
||||||
var length = Search.durationToSeconds(duration);
|
});
|
||||||
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
}
|
||||||
var video_id = song.id;
|
});
|
||||||
var video_title = song.snippet.title;
|
},
|
||||||
|
|
||||||
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
checkUserEmpty: function(){
|
||||||
});
|
var length = $("#user-suggest-html").children().length;
|
||||||
}
|
if(length === 0){
|
||||||
});
|
if(!Helper.contains($("#user_suggests").attr("class").split(" "), "hide"))
|
||||||
}
|
$("#user_suggests").addClass("hide");
|
||||||
});
|
}else{
|
||||||
},
|
$("#user_suggests").removeClass("hide");
|
||||||
|
}
|
||||||
checkUserEmpty: function(){
|
},
|
||||||
var length = $("#user-suggest-html").children().length;
|
|
||||||
if(length === 0){
|
|
||||||
if(!Helper.contains($("#user_suggests").attr("class").split(" "), "hide"))
|
|
||||||
$("#user_suggests").addClass("hide");
|
|
||||||
}else{
|
|
||||||
$("#user_suggests").removeClass("hide");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user