mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
More indentation
This commit is contained in:
@@ -1,125 +1,125 @@
|
|||||||
|
|
||||||
function chat(msg, guid, offline, socket) {
|
function chat(msg, guid, offline, socket) {
|
||||||
if(typeof(msg) !== 'object' && !msg.hasOwnProperty('data') && !msg.hasOwnProperty('channel') && !msg.hasOwnProperty('pass')) {
|
if(typeof(msg) !== 'object' && !msg.hasOwnProperty('data') && !msg.hasOwnProperty('channel') && !msg.hasOwnProperty('pass')) {
|
||||||
socket.emit('update_required');
|
socket.emit('update_required');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
var coll = msg.channel;
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
|
||||||
var data = msg.data;
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
if(data !== "" && data !== undefined && data !== null &&
|
|
||||||
data.length < 151 && data.replace(/\s/g, '').length){
|
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
|
||||||
if(docs.length == 1) {
|
|
||||||
io.to(coll).emit('chat', {from: docs[0].name, msg: ": " + data});
|
|
||||||
} else if(docs.length == 0){
|
|
||||||
get_name(guid, {announce: false, channel: coll, message: data, all: false});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
socket.emit('auth_required');
|
|
||||||
}
|
}
|
||||||
});
|
var coll = msg.channel;
|
||||||
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
||||||
|
var data = msg.data;
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
if(data !== "" && data !== undefined && data !== null &&
|
||||||
|
data.length < 151 && data.replace(/\s/g, '').length){
|
||||||
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
|
if(docs.length == 1) {
|
||||||
|
io.to(coll).emit('chat', {from: docs[0].name, msg: ": " + data});
|
||||||
|
} else if(docs.length == 0){
|
||||||
|
get_name(guid, {announce: false, channel: coll, message: data, all: false});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
socket.emit('auth_required');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function all_chat(msg, guid, offline, socket) {
|
function all_chat(msg, guid, offline, socket) {
|
||||||
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") || !msg.hasOwnProperty("data")) {
|
if(typeof(msg) !== 'object' || !msg.hasOwnProperty("channel") || !msg.hasOwnProperty("data")) {
|
||||||
socket.emit('update_required');
|
socket.emit('update_required');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var coll = msg.channel;
|
var coll = msg.channel;
|
||||||
var data = msg.data;
|
var data = msg.data;
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
if(data !== "" && data !== undefined && data !== null &&
|
if(data !== "" && data !== undefined && data !== null &&
|
||||||
data.length < 151 && data.replace(/\s/g, '').length){
|
data.length < 151 && data.replace(/\s/g, '').length){
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
io.sockets.emit('chat.all', {from: docs[0].name, msg: ": " + data, channel: coll});
|
io.sockets.emit('chat.all', {from: docs[0].name, msg: ": " + data, channel: coll});
|
||||||
} else if(docs.length == 0) {
|
} else if(docs.length == 0) {
|
||||||
get_name(guid, {announce: false, channel: coll, message: data, all: true});
|
get_name(guid, {announce: false, channel: coll, message: data, all: true});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function namechange(data, guid, coll) {
|
function namechange(data, guid, coll) {
|
||||||
if(typeof(data) !== "string" || coll == undefined) return;
|
if(typeof(data) !== "string" || coll == undefined) return;
|
||||||
data = encodeURIComponent(data).replace(/\W/g, '').replace(/[^\x00-\x7F]/g, "");
|
data = encodeURIComponent(data).replace(/\W/g, '').replace(/[^\x00-\x7F]/g, "");
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
if(docs[0].name == data) return;
|
if(docs[0].name == data) return;
|
||||||
var change_name = function(new_name, guid, old_name) {
|
var change_name = function(new_name, guid, old_name) {
|
||||||
if(new_name.length > 9) {
|
if(new_name.length > 9) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: new_name}}, function(err, updated) {
|
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: new_name}}, function(err, updated) {
|
||||||
if(updated.nModified == 1) {
|
if(updated.nModified == 1) {
|
||||||
db.collection("user_names").update({"guid": guid}, {$set: {name: new_name}}, function(err, updated) {
|
db.collection("user_names").update({"guid": guid}, {$set: {name: new_name}}, function(err, updated) {
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function(err, updated) {});
|
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function(err, updated) {});
|
||||||
name = new_name;
|
name = new_name;
|
||||||
io.to(coll).emit('chat', {from: old_name, msg: " changed name to " + name});
|
io.to(coll).emit('chat', {from: old_name, msg: " changed name to " + name});
|
||||||
io.sockets.emit('chat.all', {from: old_name , msg: " changed name to " + name, channel: coll});
|
io.sockets.emit('chat.all', {from: old_name , msg: " changed name to " + name, channel: coll});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
change_name(new_name + "_", guid, old_name);
|
change_name(new_name + "_", guid, old_name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
var old_name = docs[0].name;
|
||||||
|
change_name(data, guid, old_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
var old_name = docs[0].name;
|
|
||||||
change_name(data, guid, old_name);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removename(guid, coll) {
|
function removename(guid, coll) {
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
var old_name = docs[0].name;
|
var old_name = docs[0].name;
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function(err, updated) {
|
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: old_name}}, function(err, updated) {
|
||||||
db.collection("user_names").remove({"guid": guid}, function(err, removed) {
|
db.collection("user_names").remove({"guid": guid}, function(err, removed) {
|
||||||
get_name(guid, {announce: true, old_name: old_name, channel: coll});
|
get_name(guid, {announce: true, old_name: old_name, channel: coll});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_name(guid, announce_payload) {
|
function generate_name(guid, announce_payload) {
|
||||||
var tmp_name = Functions.rndName(guid, 8);
|
var tmp_name = Functions.rndName(guid, 8);
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: tmp_name}}, {upsert: true}, function(err, updated) {
|
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: tmp_name}}, {upsert: true}, function(err, updated) {
|
||||||
if(updated.nModified == 1 || (updated.hasOwnProperty("upserted") && n == 1)) {
|
if(updated.nModified == 1 || (updated.hasOwnProperty("upserted") && n == 1)) {
|
||||||
db.collection("user_names").update({"guid": guid}, {$set: {name: tmp_name}}, {upsert: true}, function(err, update){
|
db.collection("user_names").update({"guid": guid}, {$set: {name: tmp_name}}, {upsert: true}, function(err, update){
|
||||||
name = tmp_name;
|
name = tmp_name;
|
||||||
if(announce_payload.announce) {
|
if(announce_payload.announce) {
|
||||||
io.to(announce_payload.channel).emit('chat', {from: announce_payload.old_name, msg: " changed name to " + name});
|
io.to(announce_payload.channel).emit('chat', {from: announce_payload.old_name, msg: " changed name to " + name});
|
||||||
io.sockets.emit('chat.all', {from: announce_payload.old_name , msg: " changed name to " + name, channel: announce_payload.channel});
|
io.sockets.emit('chat.all', {from: announce_payload.old_name , msg: " changed name to " + name, channel: announce_payload.channel});
|
||||||
} else if(announce_payload.message && !announce_payload.all) {
|
} else if(announce_payload.message && !announce_payload.all) {
|
||||||
io.to(announce_payload.channel).emit('chat', {from: name, msg: ": " + announce_payload.message});
|
io.to(announce_payload.channel).emit('chat', {from: name, msg: ": " + announce_payload.message});
|
||||||
} else if(announce_payload.message && announce_payload.all) {
|
} else if(announce_payload.message && announce_payload.all) {
|
||||||
io.sockets.emit('chat.all', {from: name, msg: ": " + announce_payload.message, channel: announce_payload.channel});
|
io.sockets.emit('chat.all', {from: name, msg: ": " + announce_payload.message, channel: announce_payload.channel});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Chat.generate_name(tmp_name, announce_payload);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} else {
|
|
||||||
Chat.generate_name(tmp_name, announce_payload);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_name(guid, announce_payload) {
|
function get_name(guid, announce_payload) {
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 0) {
|
if(docs.length == 0) {
|
||||||
Chat.generate_name(guid, announce_payload);
|
Chat.generate_name(guid, announce_payload);
|
||||||
} else {
|
} else {
|
||||||
name = docs[0].name;
|
name = docs[0].name;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.chat = chat;
|
module.exports.chat = chat;
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ var mongojs = require('mongojs');
|
|||||||
var db = mongojs(mongo_db_cred.config);
|
var db = mongojs(mongo_db_cred.config);
|
||||||
|
|
||||||
db.on('connected', function(err) {
|
db.on('connected', function(err) {
|
||||||
console.log("connected");
|
console.log("connected");
|
||||||
})
|
})
|
||||||
|
|
||||||
db.on('error',function(err) {
|
db.on('error',function(err) {
|
||||||
console.log("\n" + new Date().toString() + "\n Database error: ", err);
|
console.log("\n" + new Date().toString() + "\n Database error: ", err);
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = db;
|
module.exports = db;
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
function frontpage_lists(msg, socket) {
|
function frontpage_lists(msg, socket) {
|
||||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
}
|
}
|
||||||
|
|
||||||
db.collection("frontpage_lists").find({frontpage:true}, function(err, docs){
|
db.collection("frontpage_lists").find({frontpage:true}, function(err, docs){
|
||||||
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
|
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot){
|
||||||
socket.compress(true).emit("playlists", {channels: docs, viewers: tot[0].total_users});
|
socket.compress(true).emit("playlists", {channels: docs, viewers: tot[0].total_users});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_frontpage(coll, id, title) {
|
function update_frontpage(coll, id, title) {
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
||||||
id: id,
|
id: id,
|
||||||
title: title,
|
title: title,
|
||||||
accessed: Functions.get_time()}
|
accessed: Functions.get_time()}
|
||||||
},{upsert: true}, function(err, returnDocs){});
|
},{upsert: true}, function(err, returnDocs){});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.frontpage_lists = frontpage_lists;
|
module.exports.frontpage_lists = frontpage_lists;
|
||||||
|
|||||||
@@ -1,124 +1,122 @@
|
|||||||
|
|
||||||
function remove_unique_id(short_id) {
|
function remove_unique_id(short_id) {
|
||||||
db.collection("unique_ids").update({"_id": "unique_ids"}, {$pull: {unique_ids: short_id}}, function(err, docs) {});
|
db.collection("unique_ids").update({"_id": "unique_ids"}, {$pull: {unique_ids: short_id}}, function(err, docs) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_name_from_db(guid, name) {
|
function remove_name_from_db(guid, name) {
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: name}}, function(err, updated) {
|
db.collection("user_names").update({"_id": "all_names"}, {$pull: {names: name}}, function(err, updated) {
|
||||||
db.collection("user_names").remove({"guid": guid}, function(err, removed) { });
|
db.collection("user_names").remove({"guid": guid}, function(err, removed) { });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_from_array(array, element){
|
function remove_from_array(array, element){
|
||||||
if(Functions.contains(array, element)){
|
if(Functions.contains(array, element)){
|
||||||
var index = array.indexOf(element);
|
var index = array.indexOf(element);
|
||||||
if(index != -1)
|
if(index != -1)
|
||||||
array.splice(index, 1);
|
array.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_short_id(socket) {
|
function get_short_id(socket) {
|
||||||
var new_short_id = uniqid.time().toLowerCase();
|
var new_short_id = uniqid.time().toLowerCase();
|
||||||
|
|
||||||
socket.join(new_short_id);
|
socket.join(new_short_id);
|
||||||
socket.emit("id", new_short_id);
|
socket.emit("id", new_short_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_inlist(coll, guid, socket, offline)
|
function check_inlist(coll, guid, socket, offline)
|
||||||
{
|
{
|
||||||
if(!offline && coll != undefined){
|
if(!offline && coll != undefined){
|
||||||
db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) {
|
db.collection("connected_users").update({"_id": coll}, {$addToSet:{users: guid}}, {upsert: true}, function(err, updated) {
|
||||||
if(updated.nModified > 0) {
|
if(updated.nModified > 0) {
|
||||||
db.collection("connected_users").find({"_id": coll}, function(err, new_doc) {
|
db.collection("connected_users").find({"_id": coll}, function(err, new_doc) {
|
||||||
db.collection("frontpage_lists").update({"_id": coll}, {$set: {"viewers": new_doc[0].users.length}}, function(){
|
db.collection("frontpage_lists").update({"_id": coll}, {$set: {"viewers": new_doc[0].users.length}}, function(){
|
||||||
if(new_doc[0].users == undefined || new_doc[0].users.length == undefined) {
|
if(new_doc[0].users == undefined || new_doc[0].users.length == undefined) {
|
||||||
io.to(coll).emit("viewers", 1);
|
io.to(coll).emit("viewers", 1);
|
||||||
} else {
|
} else {
|
||||||
io.to(coll).emit("viewers", new_doc[0].users.length);
|
io.to(coll).emit("viewers", new_doc[0].users.length);
|
||||||
}
|
}
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
socket.broadcast.to(coll).emit('chat', {from: docs[0].name, msg: " joined"});
|
socket.broadcast.to(coll).emit('chat', {from: docs[0].name, msg: " joined"});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs){});
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs){});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
db.collection("connected_users").update({"_id": coll}, {$addToSet: {users: guid}}, function(err, docs){});
|
db.collection("connected_users").update({"_id": coll}, {$addToSet: {users: guid}}, function(err, docs){});
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function rndName(seed, len) {
|
function rndName(seed, len) {
|
||||||
var vowels = ['a', 'e', 'i', 'o', 'u'];
|
var vowels = ['a', 'e', 'i', 'o', 'u'];
|
||||||
consts = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y'];
|
consts = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y'];
|
||||||
len = Math.floor(len);
|
len = Math.floor(len);
|
||||||
word = '';
|
word = '';
|
||||||
is_vowel = false;
|
is_vowel = false;
|
||||||
var arr;
|
var arr;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
if (is_vowel) arr = vowels;
|
if (is_vowel) arr = vowels;
|
||||||
else arr = consts;
|
else arr = consts;
|
||||||
is_vowel = !is_vowel;
|
is_vowel = !is_vowel;
|
||||||
word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)];
|
word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)];
|
||||||
}
|
}
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
function decrypt_string(socket_id, pw){
|
function decrypt_string(socket_id, pw){
|
||||||
try {
|
try {
|
||||||
var input = pw.split("$");
|
var input = pw.split("$");
|
||||||
pw = input[0];
|
pw = input[0];
|
||||||
var testKey = ((new Buffer(socket_id).toString('base64')) + (new Buffer(socket_id).toString('base64'))).substring(0,32);
|
var testKey = ((new Buffer(socket_id).toString('base64')) + (new Buffer(socket_id).toString('base64'))).substring(0,32);
|
||||||
var keyNew = (new Buffer(testKey)).toString('base64');
|
var keyNew = (new Buffer(testKey)).toString('base64');
|
||||||
var encrypted = CryptoJS.enc.Base64.parse(pw);
|
var encrypted = CryptoJS.enc.Base64.parse(pw);
|
||||||
var key = CryptoJS.enc.Base64.parse(keyNew);
|
var key = CryptoJS.enc.Base64.parse(keyNew);
|
||||||
var iv = CryptoJS.enc.Base64.parse(input[1]);
|
var iv = CryptoJS.enc.Base64.parse(input[1]);
|
||||||
var decrypted = CryptoJS.enc.Utf8.stringify(
|
var decrypted = CryptoJS.enc.Utf8.stringify(
|
||||||
CryptoJS.AES.decrypt({
|
CryptoJS.AES.decrypt({
|
||||||
ciphertext: encrypted
|
ciphertext: encrypted
|
||||||
},
|
}, key, {
|
||||||
key,
|
mode: CryptoJS.mode.CBC,
|
||||||
// edit: changed to Pkcs5
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
{
|
iv: iv,
|
||||||
mode: CryptoJS.mode.CBC,
|
})
|
||||||
padding: CryptoJS.pad.Pkcs7,
|
);
|
||||||
iv: iv,
|
return decrypted;
|
||||||
}));
|
} catch(e) {
|
||||||
return decrypted;
|
return "";
|
||||||
} catch(e) {
|
}
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_time()
|
function get_time()
|
||||||
{
|
{
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var time = Math.floor(d.getTime() / 1000);
|
var time = Math.floor(d.getTime() / 1000);
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
function contains(a, obj) {
|
function contains(a, obj) {
|
||||||
try{
|
try{
|
||||||
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;
|
||||||
}catch(e){
|
}catch(e){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hash_pass(adminpass) {
|
function hash_pass(adminpass) {
|
||||||
return crypto.createHash('sha256').update(adminpass).digest('base64');
|
return crypto.createHash('sha256').update(adminpass).digest('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.remove_unique_id = remove_unique_id;
|
module.exports.remove_unique_id = remove_unique_id;
|
||||||
|
|||||||
@@ -1,381 +1,359 @@
|
|||||||
module.exports = function() {
|
module.exports = function() {
|
||||||
io.on('connection', function(socket){
|
io.on('connection', function(socket){
|
||||||
socket.zoff_id = socket.id;
|
socket.zoff_id = socket.id;
|
||||||
socket.emit("get_list");
|
socket.emit("get_list");
|
||||||
|
|
||||||
var guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
|
var guid = Functions.hash_pass(socket.handshake.headers["user-agent"] + socket.handshake.address + socket.handshake.headers["accept-language"]);
|
||||||
|
|
||||||
socket.on('close', function() {
|
socket.on('close', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('pinging', function() {
|
socket.on('pinging', function() {
|
||||||
socket.emit("ok");
|
socket.emit("ok");
|
||||||
});
|
});
|
||||||
|
|
||||||
var ping_timeout;
|
var ping_timeout;
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
var coll;
|
var coll;
|
||||||
var in_list = false;
|
var in_list = false;
|
||||||
var name = "";
|
var name = "";
|
||||||
var short_id;
|
var short_id;
|
||||||
Chat.get_name(guid, {announce: false});
|
Chat.get_name(guid, {announce: false});
|
||||||
var offline = false;
|
var offline = false;
|
||||||
var chromecast_object = false;
|
var chromecast_object = false;
|
||||||
|
|
||||||
socket.emit("guid", guid);
|
socket.emit("guid", guid);
|
||||||
|
|
||||||
socket.on('self_ping', function(msg) {
|
socket.on('self_ping', function(msg) {
|
||||||
var channel = msg.channel;
|
var channel = msg.channel;
|
||||||
if(offline) {
|
if(offline) {
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
|
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){});
|
||||||
} else {
|
} else {
|
||||||
db.collection("connected_users").update({"_id": channel}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){
|
db.collection("connected_users").update({"_id": channel}, {$addToSet: {users: guid}}, {upsert: true}, function(err, docs){
|
||||||
db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){});
|
db.collection("frontpage_lists").update({"_id": channel}, {$inc: {viewers: 1}}, {upsert: true}, function(){});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*if(name != "") {
|
|
||||||
db.collection("user_names").update({"_id": "all_names"}, {$addToSet: {names: name}}, {upsert: true}, function(err, updated) {
|
|
||||||
if(updated.nModified == 1) {
|
|
||||||
db.collection("user_names").update({"guid": guid}, {$set: {name: name}}, {upsert:true}, function(err, update){});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, {upsert: true}, function(err, docs){});
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('chromecast', function(msg) {
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, {upsert: true}, function(err, docs){});
|
||||||
try {
|
});
|
||||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel")) {
|
|
||||||
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
|
|
||||||
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
|
|
||||||
guid = msg.guid;
|
|
||||||
socketid = msg.socket_id;
|
|
||||||
socket.zoff_id = socketid;
|
|
||||||
coll = msg.channel;
|
|
||||||
in_list = true;
|
|
||||||
chromecast_object = true;
|
|
||||||
socket.join(coll);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on("get_spread", function(){
|
socket.on('chromecast', function(msg) {
|
||||||
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot) {
|
try {
|
||||||
db.collection("connected_users").find({"_id": "offline_users"}, function(err, off) {
|
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel")) {
|
||||||
db.collection("connected_users").find({"_id": {$ne: "total_users"}, "_id": {$ne: "offline_users"}}, function(err, users_list) {
|
db.collection("connected_users").find({"_id": msg.channel}, function(err, connected_users_channel) {
|
||||||
if(tot.length > 0 && off.length == 0) {
|
if(connected_users_channel.length > 0 && connected_users_channel[0].users.indexOf(msg.guid) > -1) {
|
||||||
socket.emit("spread_listeners", {offline: 0, total: tot[0].total_users, online_users: users_list});
|
guid = msg.guid;
|
||||||
} else if(tot.length > 0 && off.length > 0){
|
socketid = msg.socket_id;
|
||||||
socket.emit("spread_listeners", {offline: off[0].users.length, total: tot[0].total_users, online_users: users_list});
|
socket.zoff_id = socketid;
|
||||||
}
|
coll = msg.channel;
|
||||||
});
|
in_list = true;
|
||||||
});
|
chromecast_object = true;
|
||||||
});
|
socket.join(coll);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('suggest_thumbnail', function(msg){
|
socket.on("get_spread", function(){
|
||||||
Suggestions.thumbnail(msg, coll, guid, offline, socket);
|
db.collection("connected_users").find({"_id": "total_users"}, function(err, tot) {
|
||||||
});
|
db.collection("connected_users").find({"_id": "offline_users"}, function(err, off) {
|
||||||
|
db.collection("connected_users").find({"_id": {$ne: "total_users"}, "_id": {$ne: "offline_users"}}, function(err, users_list) {
|
||||||
|
if(tot.length > 0 && off.length == 0) {
|
||||||
|
socket.emit("spread_listeners", {offline: 0, total: tot[0].total_users, online_users: users_list});
|
||||||
|
} else if(tot.length > 0 && off.length > 0){
|
||||||
|
socket.emit("spread_listeners", {offline: off[0].users.length, total: tot[0].total_users, online_users: users_list});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('suggest_description', function(msg){
|
socket.on('suggest_thumbnail', function(msg){
|
||||||
Suggestions.description(msg, coll, guid, offline, socket);
|
Suggestions.thumbnail(msg, coll, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("offline", function(msg){
|
socket.on('suggest_description', function(msg){
|
||||||
if(!msg.hasOwnProperty('status') && !msg.hasOwnProperty('channel')) {
|
Suggestions.description(msg, coll, guid, offline, socket);
|
||||||
socket.emit("update_required");
|
});
|
||||||
return;
|
|
||||||
}
|
|
||||||
var status = msg.status;
|
|
||||||
var channel = msg.channel;
|
|
||||||
if(status){
|
|
||||||
in_list = false;
|
|
||||||
offline = true;
|
|
||||||
if(channel != "") coll = channel;
|
|
||||||
if(coll !== undefined) {
|
|
||||||
db.collection("connected_users").findAndModify({
|
|
||||||
query: {"_id": coll},
|
|
||||||
update: {$pull: {users: guid}},
|
|
||||||
upsert: true,
|
|
||||||
}, function(err, updated) {
|
|
||||||
if(updated.nModified > 0) {
|
|
||||||
io.to(coll).emit("viewers", updated.users);
|
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs){});
|
|
||||||
}
|
|
||||||
Functions.remove_name_from_db(guid, name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Functions.remove_unique_id(short_id);
|
socket.on("offline", function(msg){
|
||||||
|
if(!msg.hasOwnProperty('status') && !msg.hasOwnProperty('channel')) {
|
||||||
|
socket.emit("update_required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var status = msg.status;
|
||||||
|
var channel = msg.channel;
|
||||||
|
if(status){
|
||||||
|
in_list = false;
|
||||||
|
offline = true;
|
||||||
|
if(channel != "") coll = channel;
|
||||||
|
if(coll !== undefined) {
|
||||||
|
db.collection("connected_users").findAndModify({
|
||||||
|
query: {"_id": coll},
|
||||||
|
update: {$pull: {users: guid}},
|
||||||
|
upsert: true,
|
||||||
|
}, function(err, updated) {
|
||||||
|
if(updated.nModified > 0) {
|
||||||
|
io.to(coll).emit("viewers", updated.users);
|
||||||
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, docs){});
|
||||||
|
}
|
||||||
|
Functions.remove_name_from_db(guid, name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {});
|
Functions.remove_unique_id(short_id);
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
|
||||||
} else {
|
|
||||||
offline = false;
|
|
||||||
db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) {
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*socket.on('namechange', function(msg)
|
db.collection("connected_users").update({"_id": "offline_users"}, {$addToSet: {users: guid}}, function(err, docs) {});
|
||||||
{
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: 1}}, function(err, docs) {});
|
||||||
if(coll == undefined) {
|
} else {
|
||||||
coll = msg.channel;
|
offline = false;
|
||||||
}
|
db.collection("connected_users").update({"_id": "offline_users"}, {$pull: {users: guid}}, function(err, docs) {
|
||||||
Chat.namechange(msg.name, guid, coll, function(new_name) {
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
name = new_name;
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('removename', function()
|
socket.on('chat', function (msg) {
|
||||||
{
|
Chat.chat(msg, guid, offline, socket);
|
||||||
Chat.removename(guid, coll);
|
});
|
||||||
name = "";
|
|
||||||
});*/
|
|
||||||
|
|
||||||
socket.on('chat', function (msg) {
|
socket.on("all,chat", function(data)
|
||||||
Chat.chat(msg, guid, offline, socket);
|
{
|
||||||
});
|
Chat.all_chat(data, guid, offline, socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on("all,chat", function(data)
|
socket.on('frontpage_lists', function(msg)
|
||||||
{
|
{
|
||||||
Chat.all_chat(data, guid, offline, socket);
|
Frontpage.frontpage_lists(msg, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('frontpage_lists', function(msg)
|
socket.on('now_playing', function(list, fn)
|
||||||
{
|
{
|
||||||
Frontpage.frontpage_lists(msg, socket);
|
List.now_playing(list, fn, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('now_playing', function(list, fn)
|
socket.on('id', function(arr)
|
||||||
{
|
{
|
||||||
List.now_playing(list, fn, socket);
|
if(typeof(arr) == 'object')
|
||||||
});
|
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('id', function(arr)
|
socket.on('list', function(msg)
|
||||||
{
|
{
|
||||||
if(typeof(arr) == 'object')
|
try {
|
||||||
io.to(arr.id).emit(arr.id.toLowerCase(), {type: arr.type, value: arr.value});
|
var _list = msg.channel;
|
||||||
});
|
if(_list.length == 0) return;
|
||||||
|
coll = emojiStrip(_list).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List.list(msg, guid, coll, offline, socket);
|
||||||
|
Functions.get_short_id(socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('list', function(msg)
|
socket.on('end', function(obj)
|
||||||
{
|
{
|
||||||
try {
|
if(coll === undefined) {
|
||||||
var _list = msg.channel;
|
try {
|
||||||
if(_list.length == 0) return;
|
coll = obj.channel;
|
||||||
coll = emojiStrip(_list).toLowerCase();
|
if(coll.length == 0) return;
|
||||||
coll = coll.replace("_", "");
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = coll.replace("_", "");
|
||||||
coll = filter.clean(coll);
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
} catch(e) {
|
coll = filter.clean(coll);
|
||||||
return;
|
} catch(e) {
|
||||||
}
|
return;
|
||||||
List.list(msg, guid, coll, offline, socket);
|
}
|
||||||
Functions.get_short_id(socket);
|
}
|
||||||
});
|
List.end(obj, coll, guid, offline, socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('end', function(obj)
|
socket.on('add', function(arr)
|
||||||
{
|
{
|
||||||
if(coll === undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = obj.channel;
|
coll = arr.list;
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List.end(obj, coll, guid, offline, socket);
|
ListChange.add_function(arr, coll, guid, offline, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('add', function(arr)
|
socket.on('delete_all', function(msg) {
|
||||||
{
|
if(coll !== undefined) {
|
||||||
if(coll !== undefined) {
|
try {
|
||||||
try {
|
coll = msg.channel;
|
||||||
coll = arr.list;
|
if(coll.length == 0) return;
|
||||||
if(coll.length == 0) return;
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = coll.replace("_", "");
|
||||||
coll = coll.replace("_", "");
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = filter.clean(coll);
|
||||||
coll = filter.clean(coll);
|
} catch(e) {
|
||||||
} catch(e) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ListChange.add_function(arr, coll, guid, offline, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('delete_all', function(msg) {
|
ListChange.delete_all(msg, coll, guid, offline, socket);
|
||||||
if(coll !== undefined) {
|
});
|
||||||
try {
|
|
||||||
coll = msg.channel;
|
|
||||||
if(coll.length == 0) return;
|
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListChange.delete_all(msg, coll, guid, offline, socket);
|
socket.on('vote', function(msg)
|
||||||
});
|
{
|
||||||
|
if(coll !== undefined) {
|
||||||
|
try {
|
||||||
|
coll = msg.channel;
|
||||||
|
if(coll.length == 0) return;
|
||||||
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListChange.voteUndecided(msg, coll, guid, offline, socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('vote', function(msg)
|
socket.on('password', function(inp)
|
||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
ListSettings.password(inp, coll, guid, offline, socket);
|
||||||
try {
|
});
|
||||||
coll = msg.channel;
|
|
||||||
if(coll.length == 0) return;
|
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListChange.voteUndecided(msg, coll, guid, offline, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('password', function(inp)
|
socket.on('skip', function(list)
|
||||||
{
|
{
|
||||||
ListSettings.password(inp, coll, guid, offline, socket);
|
if(coll !== undefined) {
|
||||||
});
|
try {
|
||||||
|
coll = list.channel;
|
||||||
|
if(coll.length == 0) return;
|
||||||
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List.skip(list, guid, coll, offline, socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('skip', function(list)
|
socket.on('conf', function(params)
|
||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
ListSettings.conf_function(params, coll, guid, offline, socket);
|
||||||
try {
|
});
|
||||||
coll = list.channel;
|
|
||||||
if(coll.length == 0) return;
|
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List.skip(list, guid, coll, offline, socket);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('conf', function(params)
|
socket.on('shuffle', function(msg)
|
||||||
{
|
{
|
||||||
ListSettings.conf_function(params, coll, guid, offline, socket);
|
if(coll !== undefined) {
|
||||||
});
|
try {
|
||||||
|
coll = msg.channel;
|
||||||
|
if(coll.length == 0) return;
|
||||||
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ListChange.shuffle(msg, coll, guid, offline, socket);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('shuffle', function(msg)
|
socket.on('change_channel', function(obj)
|
||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
||||||
try {
|
try {
|
||||||
coll = msg.channel;
|
coll = obj.channel;
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListChange.shuffle(msg, coll, guid, offline, socket);
|
List.left_channel(coll, guid, short_id, in_list, socket, true);
|
||||||
});
|
in_list = false;
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('change_channel', function(obj)
|
socket.on('disconnect', function()
|
||||||
{
|
{
|
||||||
if(coll === undefined && obj !== undefined && obj.channel !== undefined){
|
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
||||||
try {
|
});
|
||||||
coll = obj.channel;
|
|
||||||
if(coll.length == 0) return;
|
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, true);
|
|
||||||
in_list = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('disconnect', function()
|
socket.on('disconnected', function()
|
||||||
{
|
{
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnected', function()
|
socket.on('reconnect_failed', function()
|
||||||
{
|
{
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('reconnect_failed', function()
|
socket.on('connect_timeout', function()
|
||||||
{
|
{
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('connect_timeout', function()
|
socket.on('error', function()
|
||||||
{
|
{
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('error', function()
|
socket.on('pos', function(obj)
|
||||||
{
|
{
|
||||||
List.left_channel(coll, guid, short_id, in_list, socket, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('pos', function(obj)
|
if(coll !== undefined) {
|
||||||
{
|
try {
|
||||||
|
coll = obj.channel;
|
||||||
|
if(coll.length == 0) return;
|
||||||
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(coll !== undefined) {
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
try {
|
socket.emit("update_required");
|
||||||
coll = obj.channel;
|
return;
|
||||||
if(coll.length == 0) return;
|
}
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
||||||
socket.emit("update_required");
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
||||||
return;
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
}
|
List.send_play(coll, socket);
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
send_ping();
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
List.send_play(coll, socket);
|
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
send_ping();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_ping() {
|
function send_ping() {
|
||||||
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true}, function(err, docs){
|
db.collection("connected_users").update({users: {$exists: true}}, {$set: {users: []}}, {multi: true}, function(err, docs){
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$set: {total_users: 0}}, {multi: true}, function(err, docs){
|
db.collection("connected_users").update({"_id": "total_users"}, {$set: {total_users: 0}}, {multi: true}, function(err, docs){
|
||||||
db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true}, function(err, docs) {
|
db.collection("frontpage_lists").update({viewers: {$ne: 0}}, {$set: {"viewers": 0}}, {multi: true}, function(err, docs) {
|
||||||
io.emit("self_ping");
|
io.emit("self_ping");
|
||||||
setTimeout(send_ping, 25000);
|
setTimeout(send_ping, 25000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,499 +1,499 @@
|
|||||||
|
|
||||||
function now_playing(list, fn, socket) {
|
function now_playing(list, fn, socket) {
|
||||||
if(typeof(list) !== 'string' || typeof(fn) !== 'function') {
|
if(typeof(list) !== 'string' || typeof(fn) !== 'function') {
|
||||||
socket.emit('update_required');
|
socket.emit('update_required');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
db.collection(list).find({now_playing:true}, function(err, docs){
|
|
||||||
if(docs.length === 0){
|
|
||||||
fn("No song currently playing");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var title = docs[0].title;
|
db.collection(list).find({now_playing:true}, function(err, docs){
|
||||||
if(title === undefined) fn("No song currently playing");
|
if(docs.length === 0){
|
||||||
else fn(title);
|
fn("No song currently playing");
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
var title = docs[0].title;
|
||||||
|
if(title === undefined) fn("No song currently playing");
|
||||||
|
else fn(title);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function list(msg, guid, coll, offline, socket) {
|
function list(msg, guid, coll, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
|
|
||||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
|
if(typeof(msg) === 'object' && msg !== undefined && msg !== null && msg.hasOwnProperty("channel") && msg.hasOwnProperty('pass'))
|
||||||
{
|
{
|
||||||
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
if(!msg.hasOwnProperty('version') || msg.version != VERSION || msg.version == undefined) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var pass = Functions.decrypt_string(socketid, msg.pass);
|
var pass = Functions.decrypt_string(socketid, msg.pass);
|
||||||
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
||||||
if(frontpage_lists.length == 1)
|
if(frontpage_lists.length == 1)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
||||||
if(docs.length == 0 || (docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
|
if(docs.length == 0 || (docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
|
||||||
if(docs.length > 0 && docs[0].hasOwnProperty('userpass') && docs[0].userpass != "" && docs[0].userpass == pass) {
|
if(docs.length > 0 && docs[0].hasOwnProperty('userpass') && docs[0].userpass != "" && docs[0].userpass == pass) {
|
||||||
socket.emit("auth_accepted", {value: true});
|
socket.emit("auth_accepted", {value: true});
|
||||||
|
}
|
||||||
|
in_list = true;
|
||||||
|
socket.join(coll);
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
|
if(frontpage_lists.viewers != undefined){
|
||||||
|
io.to(coll).emit("viewers", frontpage_lists.viewers);
|
||||||
|
} else {
|
||||||
|
io.to(coll).emit("viewers", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
List.send_list(coll, socket, true, false, true);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else{
|
||||||
|
db.createCollection(coll, function(err, docs){
|
||||||
|
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs){
|
||||||
|
List.send_list(coll, socket, true, false, true);
|
||||||
|
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time()});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
in_list = true;
|
|
||||||
socket.join(coll);
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
if(frontpage_lists.viewers != undefined){
|
|
||||||
io.to(coll).emit("viewers", frontpage_lists.viewers);
|
|
||||||
} else {
|
|
||||||
io.to(coll).emit("viewers", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
List.send_list(coll, socket, true, false, true);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else{
|
} else {
|
||||||
db.createCollection(coll, function(err, docs){
|
socket.emit('update_required');
|
||||||
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": ""}, function(err, docs){
|
}
|
||||||
List.send_list(coll, socket, true, false, true);
|
|
||||||
db.collection("frontpage_lists").insert({"_id": coll, "count" : 0, "frontpage": true, "accessed": Functions.get_time()});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip(list, guid, coll, offline, socket) {
|
function skip(list, guid, coll, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(list !== undefined && list !== null && list !== "")
|
if(list !== undefined && list !== null && list !== "")
|
||||||
{
|
{
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == Functions.decrypt_string(socketid, list.userpass)))) {
|
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
adminpass = "";
|
|
||||||
video_id = list.id;
|
|
||||||
err = list.error;
|
|
||||||
var error = false;
|
|
||||||
var video_id;
|
|
||||||
if(err != "5" && err != "100" && err != "101" && err != "150")
|
|
||||||
{
|
|
||||||
adminpass = list.pass;
|
|
||||||
}else if(err == "5" || err == "100" || err == "101" || err == "150"){
|
|
||||||
error = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(adminpass !== undefined && adminpass !== null && adminpass !== "")
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
hash = Functions.hash_pass(Functions.decrypt_string(socketid, adminpass));
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == Functions.decrypt_string(socketid, list.userpass)))) {
|
||||||
else
|
|
||||||
hash = "";
|
|
||||||
|
|
||||||
db.collection(coll).find({views: {$exists:true}}, function(err, docs){
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
if(docs !== null && docs.length !== 0)
|
adminpass = "";
|
||||||
{
|
video_id = list.id;
|
||||||
if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error)
|
err = list.error;
|
||||||
{
|
var error = false;
|
||||||
db.collection("frontpage_lists").find({"_id": coll}, function(err, frontpage_viewers){
|
var video_id;
|
||||||
if((frontpage_viewers[0].viewers/2 <= docs[0].skips.length+1 && !Functions.contains(docs[0].skips, guid) && frontpage_viewers[0].viewers != 2) ||
|
if(err != "5" && err != "100" && err != "101" && err != "150")
|
||||||
(frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) ||
|
|
||||||
(docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip))
|
|
||||||
{
|
{
|
||||||
List.change_song(coll, error, video_id);
|
adminpass = list.pass;
|
||||||
socket.emit("toast", "skip");
|
}else if(err == "5" || err == "100" || err == "101" || err == "150"){
|
||||||
io.to(coll).emit('chat', {from: name, msg: " skipped"});
|
error = true;
|
||||||
}else if(!Functions.contains(docs[0].skips, guid)){
|
|
||||||
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
|
||||||
if(frontpage_viewers[0].viewers == 2)
|
|
||||||
to_skip = 1;
|
|
||||||
else
|
|
||||||
to_skip = (Math.ceil(frontpage_viewers[0].viewers/2) - docs[0].skips.length-1);
|
|
||||||
socket.emit("toast", to_skip + " more are needed to skip!");
|
|
||||||
socket.broadcast.to(coll).emit('chat', {from: name, msg: " voted to skip"});
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
socket.emit("toast", "alreadyskip");
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}else
|
if(adminpass !== undefined && adminpass !== null && adminpass !== "")
|
||||||
socket.emit("toast", "noskip");
|
hash = Functions.hash_pass(Functions.decrypt_string(socketid, adminpass));
|
||||||
}
|
else
|
||||||
|
hash = "";
|
||||||
|
|
||||||
|
db.collection(coll).find({views: {$exists:true}}, function(err, docs){
|
||||||
|
|
||||||
|
if(docs !== null && docs.length !== 0)
|
||||||
|
{
|
||||||
|
if(!docs[0].skip || (docs[0].adminpass == hash && docs[0].adminpass !== "") || error)
|
||||||
|
{
|
||||||
|
db.collection("frontpage_lists").find({"_id": coll}, function(err, frontpage_viewers){
|
||||||
|
if((frontpage_viewers[0].viewers/2 <= docs[0].skips.length+1 && !Functions.contains(docs[0].skips, guid) && frontpage_viewers[0].viewers != 2) ||
|
||||||
|
(frontpage_viewers[0].viewers == 2 && docs[0].skips.length+1 == 2 && !Functions.contains(docs[0].skips, guid)) ||
|
||||||
|
(docs[0].adminpass == hash && docs[0].adminpass !== "" && docs[0].skip))
|
||||||
|
{
|
||||||
|
List.change_song(coll, error, video_id);
|
||||||
|
socket.emit("toast", "skip");
|
||||||
|
io.to(coll).emit('chat', {from: name, msg: " skipped"});
|
||||||
|
}else if(!Functions.contains(docs[0].skips, guid)){
|
||||||
|
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
||||||
|
if(frontpage_viewers[0].viewers == 2)
|
||||||
|
to_skip = 1;
|
||||||
|
else
|
||||||
|
to_skip = (Math.ceil(frontpage_viewers[0].viewers/2) - docs[0].skips.length-1);
|
||||||
|
socket.emit("toast", to_skip + " more are needed to skip!");
|
||||||
|
socket.broadcast.to(coll).emit('chat', {from: name, msg: " voted to skip"});
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
socket.emit("toast", "alreadyskip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
socket.emit("toast", "noskip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit('update_required');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_song(coll, error, id) {
|
function change_song(coll, error, id) {
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
var startTime = docs[0].startTime;
|
var startTime = docs[0].startTime;
|
||||||
if(docs !== null && docs.length !== 0)
|
if(docs !== null && docs.length !== 0)
|
||||||
{
|
{
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
views:{
|
views:{
|
||||||
$exists: false
|
$exists: false
|
||||||
},
|
},
|
||||||
type:{
|
type:{
|
||||||
$ne: "suggested"
|
$ne: "suggested"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$sort:{
|
$sort:{
|
||||||
now_playing: -1,
|
now_playing: -1,
|
||||||
votes:-1,
|
votes:-1,
|
||||||
added:1,
|
added:1,
|
||||||
title: 1
|
title: 1
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$limit:2
|
$limit:2
|
||||||
}], function(err, now_playing_doc){
|
}], function(err, now_playing_doc){
|
||||||
if((id && id == now_playing_doc[0].id) || !id) {
|
if((id && id == now_playing_doc[0].id) || !id) {
|
||||||
if(error){
|
if(error){
|
||||||
request('http://img.youtube.com/vi/'+now_playing_doc[0].id+'/mqdefault.jpg', function (err, response, body) {
|
request('http://img.youtube.com/vi/'+now_playing_doc[0].id+'/mqdefault.jpg', function (err, response, body) {
|
||||||
if (err || response.statusCode == 404) {
|
if (err || response.statusCode == 404) {
|
||||||
db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
|
db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
|
||||||
var next_song;
|
var next_song;
|
||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
List.change_song_post(coll, next_song);
|
List.change_song_post(coll, next_song);
|
||||||
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
||||||
db.collection(coll).update({views: {$exists: true}}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
db.collection(coll).update({views: {$exists: true}}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
||||||
db.collection(coll).update({now_playing:true, id:id}, {
|
db.collection(coll).update({now_playing:true, id:id}, {
|
||||||
$set:{
|
$set:{
|
||||||
now_playing:false,
|
now_playing:false,
|
||||||
votes:0,
|
votes:0,
|
||||||
guids:[]
|
guids:[]
|
||||||
}
|
}
|
||||||
},{multi:true}, function(err, docs){
|
},{multi:true}, function(err, docs){
|
||||||
var next_song;
|
var next_song;
|
||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
if(docs.n >= 1) List.change_song_post(coll, next_song);
|
if(docs.n >= 1) List.change_song_post(coll, next_song);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if(docs[0].removeplay === true){
|
} else if(docs[0].removeplay === true){
|
||||||
db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
|
db.collection(coll).remove({now_playing:true, id:id}, function(err, docs){
|
||||||
var next_song;
|
var next_song;
|
||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
List.change_song_post(coll, next_song);
|
List.change_song_post(coll, next_song);
|
||||||
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
io.to(coll).emit("channel", {type: "deleted", value: now_playing_doc[0].id, removed: true});
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
||||||
db.collection(coll).update({now_playing:true, id:id}, {
|
db.collection(coll).update({now_playing:true, id:id}, {
|
||||||
$set:{
|
$set:{
|
||||||
now_playing:false,
|
now_playing:false,
|
||||||
votes:0,
|
votes:0,
|
||||||
guids:[]
|
guids:[]
|
||||||
}
|
}
|
||||||
},{multi:true}, function(err, docs){
|
},{multi:true}, function(err, docs){
|
||||||
var next_song;
|
var next_song;
|
||||||
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
if(now_playing_doc.length == 2) next_song = now_playing_doc[1].id;
|
||||||
List.change_song_post(coll, next_song);
|
List.change_song_post(coll, next_song);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_song_post(coll, next_song)
|
function change_song_post(coll, next_song)
|
||||||
{
|
{
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
now_playing:false,
|
now_playing:false,
|
||||||
type:{
|
type:{
|
||||||
$ne: "suggested"
|
$ne: "suggested"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$sort:{
|
$sort:{
|
||||||
votes:-1,
|
votes:-1,
|
||||||
added:1,
|
added:1,
|
||||||
title: 1
|
title: 1
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$limit:2
|
$limit:2
|
||||||
}], function(err, docs){
|
}], function(err, docs){
|
||||||
if(docs !== null && docs.length > 0){
|
if(docs !== null && docs.length > 0){
|
||||||
var id = docs[0].id;
|
var id = docs[0].id;
|
||||||
if(next_song && next_song != id) {
|
if(next_song && next_song != id) {
|
||||||
if((docs.length == 2 && next_song == docs[1].id)) {
|
if((docs.length == 2 && next_song == docs[1].id)) {
|
||||||
id = docs[1].id;
|
id = docs[1].id;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.collection(coll).update({id:id},{
|
db.collection(coll).update({id:id},{
|
||||||
$set:{
|
$set:{
|
||||||
now_playing:true,
|
now_playing:true,
|
||||||
votes:0,
|
votes:0,
|
||||||
guids:[],
|
guids:[],
|
||||||
added:Functions.get_time()
|
added:Functions.get_time()
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
db.collection(coll).update({views:{$exists:true}},{
|
db.collection(coll).update({views:{$exists:true}},{
|
||||||
$set:{
|
$set:{
|
||||||
startTime:Functions.get_time(),
|
startTime:Functions.get_time(),
|
||||||
skips:[]
|
skips:[]
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||||
io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay});
|
io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay});
|
||||||
List.send_play(coll);
|
List.send_play(coll);
|
||||||
Frontpage.update_frontpage(coll, docs[0].id, docs[0].title);
|
Frontpage.update_frontpage(coll, docs[0].id, docs[0].title);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_list(coll, socket, send, list_send, configs, shuffled)
|
function send_list(coll, socket, send, list_send, configs, shuffled)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||||
db.collection(coll).find({views:{$exists:false}, type: {$ne: "suggested"}}, function(err, docs)
|
db.collection(coll).find({views:{$exists:false}, type: {$ne: "suggested"}}, function(err, docs)
|
||||||
{
|
{
|
||||||
if(docs.length > 0) {
|
if(docs.length > 0) {
|
||||||
db.collection(coll).find({now_playing: true}, function(err, np_docs) {
|
db.collection(coll).find({now_playing: true}, function(err, np_docs) {
|
||||||
if(np_docs.length == 0) {
|
if(np_docs.length == 0) {
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
views:{
|
views:{
|
||||||
$exists: false
|
$exists: false
|
||||||
},
|
},
|
||||||
type:{
|
type:{
|
||||||
$ne: "suggested"
|
$ne: "suggested"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$sort:{
|
$sort:{
|
||||||
now_playing: -1,
|
now_playing: -1,
|
||||||
votes:-1,
|
votes:-1,
|
||||||
added:1,
|
added:1,
|
||||||
title: 1
|
title: 1
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$limit:1
|
$limit:1
|
||||||
}], function(err, now_playing_doc){
|
}], function(err, now_playing_doc){
|
||||||
if(now_playing_doc[0].now_playing == false) {
|
if(now_playing_doc[0].now_playing == false) {
|
||||||
db.collection(coll).update({id:now_playing_doc[0].id}, {
|
db.collection(coll).update({id:now_playing_doc[0].id}, {
|
||||||
$set:{
|
$set:{
|
||||||
now_playing:true,
|
now_playing:true,
|
||||||
votes:0,
|
votes:0,
|
||||||
guids:[],
|
guids:[],
|
||||||
added:Functions.get_time()
|
added:Functions.get_time()
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
db.collection(coll).update({views:{$exists:true}}, {
|
db.collection(coll).update({views:{$exists:true}}, {
|
||||||
$set:{
|
$set:{
|
||||||
startTime: Functions.get_time(),
|
startTime: Functions.get_time(),
|
||||||
skips:[]
|
skips:[]
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
Frontpage.update_frontpage(coll, now_playing_doc[0].id, now_playing_doc[0].title);
|
Frontpage.update_frontpage(coll, now_playing_doc[0].id, now_playing_doc[0].title);
|
||||||
List.send_list(coll, socket, send, list_send, configs, shuffled);
|
List.send_list(coll, socket, send, list_send, configs, shuffled);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(list_send) {
|
if(list_send) {
|
||||||
io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
||||||
} else if(!list_send) {
|
} else if(!list_send) {
|
||||||
socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
||||||
}
|
}
|
||||||
if(socket === undefined && send) {
|
if(socket === undefined && send) {
|
||||||
List.send_play(coll);
|
List.send_play(coll);
|
||||||
} else if(send) {
|
} else if(send) {
|
||||||
List.send_play(coll, socket);
|
List.send_play(coll, socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(list_send) {
|
if(list_send) {
|
||||||
io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
io.to(coll).emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
||||||
} else if(!list_send) {
|
} else if(!list_send) {
|
||||||
socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
socket.emit("channel", {type: "list", playlist: docs, shuffled: shuffled});
|
||||||
}
|
}
|
||||||
if(socket === undefined && send) {
|
if(socket === undefined && send) {
|
||||||
List.send_play(coll);
|
List.send_play(coll);
|
||||||
} else if(send) {
|
} else if(send) {
|
||||||
List.send_play(coll, socket);
|
List.send_play(coll, socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if(configs)
|
if(configs)
|
||||||
{
|
{
|
||||||
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
||||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||||
else conf[0].userpass = false;
|
else conf[0].userpass = false;
|
||||||
io.to(coll).emit("conf", conf);
|
io.to(coll).emit("conf", conf);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(socket){
|
if(socket){
|
||||||
db.collection(coll).find({type:"suggested"}).sort({added: 1}, function(err, sugg){
|
db.collection(coll).find({type:"suggested"}).sort({added: 1}, function(err, sugg){
|
||||||
socket.emit("suggested", sugg);
|
socket.emit("suggested", sugg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function end(obj, coll, guid, offline, socket) {
|
function end(obj, coll, guid, offline, socket) {
|
||||||
if(typeof(obj) !== 'object') {
|
if(typeof(obj) !== 'object') {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
id = obj.id;
|
|
||||||
if(id !== undefined && id !== null && id !== "") {
|
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
id = obj.id;
|
||||||
|
if(id !== undefined && id !== null && id !== "") {
|
||||||
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
socket.emit("update_required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
db.collection(coll).find({now_playing:true}, function(err, np){
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
||||||
if(err !== null) console.log(err);
|
|
||||||
if(np !== null && np !== undefined && np.length == 1 && np[0].id == id){
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||||
var startTime = docs[0].startTime;
|
if(err !== null) console.log(err);
|
||||||
if(docs[0].removeplay === true && startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
if(np !== null && np !== undefined && np.length == 1 && np[0].id == id){
|
||||||
{
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
var startTime = docs[0].startTime;
|
||||||
List.change_song_post(coll);
|
if(docs[0].removeplay === true && startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:-1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
{
|
||||||
|
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
||||||
|
List.change_song_post(coll);
|
||||||
|
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:-1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
if(startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
||||||
|
{
|
||||||
|
List.change_song(coll, false, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
if(startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
socket.emit("auth_required");
|
||||||
{
|
}
|
||||||
List.change_song(coll, false, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit('update_required');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_play(coll, socket)
|
function send_play(coll, socket)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({now_playing:true}, function(err, np){
|
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||||
if(err !== null) console.log(err);
|
if(err !== null) console.log(err);
|
||||||
try{
|
try{
|
||||||
if(Functions.get_time()-conf[0].startTime > np[0].duration){
|
if(Functions.get_time()-conf[0].startTime > np[0].duration){
|
||||||
List.change_song(coll, false, np[0].id);
|
List.change_song(coll, false, np[0].id);
|
||||||
}else if(conf !== null && conf !== undefined && conf.length !== 0)
|
}else if(conf !== null && conf !== undefined && conf.length !== 0)
|
||||||
{
|
{
|
||||||
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
||||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||||
else conf[0].userpass = false;
|
else conf[0].userpass = false;
|
||||||
toSend = {np: np, conf: conf, time: Functions.get_time()};
|
toSend = {np: np, conf: conf, time: Functions.get_time()};
|
||||||
if(socket === undefined) {
|
if(socket === undefined) {
|
||||||
io.to(coll).emit("np", toSend);
|
io.to(coll).emit("np", toSend);
|
||||||
List.getNextSong(coll)
|
List.getNextSong(coll)
|
||||||
} else {
|
} else {
|
||||||
socket.emit("np", toSend);
|
socket.emit("np", toSend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e){
|
} catch(e){
|
||||||
if(socket) {
|
if(socket) {
|
||||||
socket.emit("np", {});
|
socket.emit("np", {});
|
||||||
} else {
|
} else {
|
||||||
io.to(coll).emit("np", {});
|
io.to(coll).emit("np", {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNextSong(coll) {
|
function getNextSong(coll) {
|
||||||
db.collection(coll).aggregate([{
|
db.collection(coll).aggregate([{
|
||||||
$match:{
|
$match:{
|
||||||
views:{
|
views:{
|
||||||
$exists: false
|
$exists: false
|
||||||
},
|
},
|
||||||
type:{
|
type:{
|
||||||
$ne: "suggested"
|
$ne: "suggested"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$sort:{
|
$sort:{
|
||||||
now_playing: 1,
|
now_playing: 1,
|
||||||
votes:-1,
|
votes:-1,
|
||||||
added:1,
|
added:1,
|
||||||
title: 1
|
title: 1
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
$limit:1
|
$limit:1
|
||||||
}], function(err, doc) {
|
}], function(err, doc) {
|
||||||
if(doc.length == 1) {
|
if(doc.length == 1) {
|
||||||
io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title});
|
io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function left_channel(coll, guid, short_id, in_list, socket, change)
|
function left_channel(coll, guid, short_id, in_list, socket, change)
|
||||||
{
|
{
|
||||||
if(!coll) return;
|
if(!coll) return;
|
||||||
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
|
db.collection("connected_users").update({"_id": coll}, {$pull: {users: guid}}, function(err, updated) {
|
||||||
if(updated.nModified > 0) {
|
if(updated.nModified > 0) {
|
||||||
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){
|
db.collection("connected_users").find({"_id": coll}, function(err, new_doc){
|
||||||
db.collection("frontpage_lists").update({"_id": coll, viewers: {$gt: 0}}, {$inc: {viewers: -1}}, function(err, doc) {
|
db.collection("frontpage_lists").update({"_id": coll, viewers: {$gt: 0}}, {$inc: {viewers: -1}}, function(err, doc) {
|
||||||
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
db.collection("user_names").find({"guid": guid}, function(err, docs) {
|
||||||
if(docs.length == 1) {
|
if(docs.length == 1) {
|
||||||
io.to(coll).emit('chat', {from: docs[0].name, msg: " left"});
|
io.to(coll).emit('chat', {from: docs[0].name, msg: " left"});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
io.to(coll).emit("viewers", new_doc[0].users.length);
|
io.to(coll).emit("viewers", new_doc[0].users.length);
|
||||||
socket.leave(coll);
|
socket.leave(coll);
|
||||||
});
|
});
|
||||||
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, updated){});
|
db.collection("connected_users").update({"_id": "total_users"}, {$inc: {total_users: -1}}, function(err, updated){});
|
||||||
|
|
||||||
if(!change) {
|
if(!change) {
|
||||||
Functions.remove_name_from_db(guid, name);
|
Functions.remove_name_from_db(guid, name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Functions.remove_unique_id(short_id);
|
Functions.remove_unique_id(short_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.now_playing = now_playing;
|
module.exports.now_playing = now_playing;
|
||||||
|
|||||||
@@ -1,307 +1,307 @@
|
|||||||
function add_function(arr, coll, guid, offline, socket) {
|
function add_function(arr, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
|
if(typeof(arr) === 'object' && arr !== undefined && arr !== null && arr !== "" && !isNaN(parseInt(arr.duration)))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (arr.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, arr.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (arr.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, arr.pass)))) {
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
var id = arr.id;
|
var id = arr.id;
|
||||||
var title = arr.title;
|
var title = arr.title;
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, arr.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, arr.adminpass));
|
||||||
var duration = parseInt(arr.duration);
|
var duration = parseInt(arr.duration);
|
||||||
var full_list = arr.playlist;
|
var full_list = arr.playlist;
|
||||||
var last = arr.num == arr.total - 1;
|
var last = arr.num == arr.total - 1;
|
||||||
var num = arr.num;
|
var num = arr.num;
|
||||||
var total = arr.total;
|
var total = arr.total;
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs)
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs)
|
||||||
{
|
{
|
||||||
conf = docs;
|
conf = docs;
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||||
docs[0].addsongs === false))
|
docs[0].addsongs === false))
|
||||||
{
|
|
||||||
db.collection(coll).find({id:id, type:{$ne:"suggested"}}, function(err, docs){
|
|
||||||
if(docs !== null && docs.length === 0)
|
|
||||||
{
|
|
||||||
var guids = full_list === true ? [] : [guid];
|
|
||||||
var votes;
|
|
||||||
var added;
|
|
||||||
if(full_list) {
|
|
||||||
var time = Functions.get_time()-total;
|
|
||||||
time = time.toString();
|
|
||||||
var total_len = total.toString().length;
|
|
||||||
var now_len = num.toString().length;
|
|
||||||
var to_add = num.toString();
|
|
||||||
while(now_len < total_len) {
|
|
||||||
to_add = "0" + to_add;
|
|
||||||
now_len = to_add.length;
|
|
||||||
}
|
|
||||||
time = time.substring(0, time.length - total_len);
|
|
||||||
time = time + to_add;
|
|
||||||
time = parseInt(time);
|
|
||||||
added = time;
|
|
||||||
votes = 0;
|
|
||||||
} else {
|
|
||||||
added = Functions.get_time();
|
|
||||||
votes = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll).find({now_playing:true}, function(err, docs){
|
|
||||||
if((docs !== null && docs.length === 0)){
|
|
||||||
np = true;
|
|
||||||
if(full_list && num === 0){
|
|
||||||
np = true;
|
|
||||||
time = time.toString();
|
|
||||||
total += 1;
|
|
||||||
var total_len = total.toString().length;
|
|
||||||
var now_len = total.toString().length;
|
|
||||||
var to_add = total.toString();
|
|
||||||
while(now_len < total_len) {
|
|
||||||
to_add = "0" + to_add;
|
|
||||||
now_len = to_add.length;
|
|
||||||
}
|
|
||||||
time = time.substring(0, time.length - total_len);
|
|
||||||
time = parseInt(time).toString() + to_add;
|
|
||||||
time = parseInt(time);
|
|
||||||
added = time;
|
|
||||||
votes = 0;
|
|
||||||
} else if(full_list) {
|
|
||||||
np = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
np = false;
|
|
||||||
}
|
|
||||||
db.collection(coll).update({id: id}, {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}, {upsert: true}, function(err, docs){
|
|
||||||
if(np)
|
|
||||||
{
|
{
|
||||||
List.send_list(coll, undefined, false, true, false);
|
db.collection(coll).find({id:id, type:{$ne:"suggested"}}, function(err, docs){
|
||||||
db.collection(coll).update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
if(docs !== null && docs.length === 0)
|
||||||
List.send_play(coll, undefined);
|
{
|
||||||
Frontpage.update_frontpage(coll, id, title);
|
var guids = full_list === true ? [] : [guid];
|
||||||
} else {
|
var votes;
|
||||||
io.to(coll).emit("channel", {type: "added", value: {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}});
|
var added;
|
||||||
|
if(full_list) {
|
||||||
|
var time = Functions.get_time()-total;
|
||||||
|
time = time.toString();
|
||||||
|
var total_len = total.toString().length;
|
||||||
|
var now_len = num.toString().length;
|
||||||
|
var to_add = num.toString();
|
||||||
|
while(now_len < total_len) {
|
||||||
|
to_add = "0" + to_add;
|
||||||
|
now_len = to_add.length;
|
||||||
|
}
|
||||||
|
time = time.substring(0, time.length - total_len);
|
||||||
|
time = time + to_add;
|
||||||
|
time = parseInt(time);
|
||||||
|
added = time;
|
||||||
|
votes = 0;
|
||||||
|
} else {
|
||||||
|
added = Functions.get_time();
|
||||||
|
votes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.collection(coll).find({now_playing:true}, function(err, docs){
|
||||||
|
if((docs !== null && docs.length === 0)){
|
||||||
|
np = true;
|
||||||
|
if(full_list && num === 0){
|
||||||
|
np = true;
|
||||||
|
time = time.toString();
|
||||||
|
total += 1;
|
||||||
|
var total_len = total.toString().length;
|
||||||
|
var now_len = total.toString().length;
|
||||||
|
var to_add = total.toString();
|
||||||
|
while(now_len < total_len) {
|
||||||
|
to_add = "0" + to_add;
|
||||||
|
now_len = to_add.length;
|
||||||
|
}
|
||||||
|
time = time.substring(0, time.length - total_len);
|
||||||
|
time = parseInt(time).toString() + to_add;
|
||||||
|
time = parseInt(time);
|
||||||
|
added = time;
|
||||||
|
votes = 0;
|
||||||
|
} else if(full_list) {
|
||||||
|
np = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
np = false;
|
||||||
|
}
|
||||||
|
db.collection(coll).update({id: id}, {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}, {upsert: true}, function(err, docs){
|
||||||
|
if(np)
|
||||||
|
{
|
||||||
|
List.send_list(coll, undefined, false, true, false);
|
||||||
|
db.collection(coll).update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
||||||
|
List.send_play(coll, undefined);
|
||||||
|
Frontpage.update_frontpage(coll, id, title);
|
||||||
|
} else {
|
||||||
|
io.to(coll).emit("channel", {type: "added", value: {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}});
|
||||||
|
}
|
||||||
|
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
||||||
|
List.getNextSong(coll);
|
||||||
|
});
|
||||||
|
if(!full_list) {
|
||||||
|
socket.emit("toast", "addedsong");
|
||||||
|
} else if(full_list && last) {
|
||||||
|
socket.emit("toast", "addedplaylist");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(!full_list) {
|
||||||
|
ListChange.vote(coll, id, guid, socket, full_list, last);
|
||||||
|
if(full_list && last) {
|
||||||
|
socket.emit("toast", "addedplaylist");
|
||||||
|
}
|
||||||
|
} else if(full_list && last) {
|
||||||
|
socket.emit("toast", "addedplaylist");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(!full_list) {
|
||||||
|
db.collection(coll).find({id: id}, function(err, docs) {
|
||||||
|
if(docs.length === 0) {
|
||||||
|
db.collection(coll).update({id: id}, {$set:{
|
||||||
|
"added":Functions.get_time(),
|
||||||
|
"guids": [guid],
|
||||||
|
"id":id,
|
||||||
|
"now_playing": false,
|
||||||
|
"title":title,
|
||||||
|
"votes":1,
|
||||||
|
"duration":duration,
|
||||||
|
"type":"suggested"}
|
||||||
|
},
|
||||||
|
{upsert:true}, function(err, docs){
|
||||||
|
socket.emit("toast", "suggested");
|
||||||
|
io.to(coll).emit("suggested", {id: id, title: title, duration: duration});
|
||||||
|
});
|
||||||
|
} else if(docs[0].now_playing === true){
|
||||||
|
socket.emit("toast", "alreadyplay");
|
||||||
|
} else{
|
||||||
|
if(conf[0].vote === false) ListChange.vote(coll, id, guid, socket, full_list, last);
|
||||||
|
else socket.emit("toast", "listhaspass");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (full_list){
|
||||||
|
if(arr.num == 0) {
|
||||||
|
socket.emit("toast", "listhaspass");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: Functions.get_time()}}, {upsert:true}, function(err, docs){});
|
|
||||||
List.getNextSong(coll);
|
|
||||||
});
|
|
||||||
if(!full_list) {
|
|
||||||
socket.emit("toast", "addedsong");
|
|
||||||
} else if(full_list && last) {
|
|
||||||
socket.emit("toast", "addedplaylist");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else if(!full_list) {
|
} else {
|
||||||
ListChange.vote(coll, id, guid, socket, full_list, last);
|
socket.emit("auth_required");
|
||||||
if(full_list && last) {
|
|
||||||
socket.emit("toast", "addedplaylist");
|
|
||||||
}
|
|
||||||
} else if(full_list && last) {
|
|
||||||
socket.emit("toast", "addedplaylist");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if(!full_list) {
|
|
||||||
db.collection(coll).find({id: id}, function(err, docs) {
|
|
||||||
if(docs.length === 0) {
|
|
||||||
db.collection(coll).update({id: id}, {$set:{
|
|
||||||
"added":Functions.get_time(),
|
|
||||||
"guids": [guid],
|
|
||||||
"id":id,
|
|
||||||
"now_playing": false,
|
|
||||||
"title":title,
|
|
||||||
"votes":1,
|
|
||||||
"duration":duration,
|
|
||||||
"type":"suggested"}
|
|
||||||
},
|
|
||||||
{upsert:true}, function(err, docs){
|
|
||||||
socket.emit("toast", "suggested");
|
|
||||||
io.to(coll).emit("suggested", {id: id, title: title, duration: duration});
|
|
||||||
});
|
|
||||||
} else if(docs[0].now_playing === true){
|
|
||||||
socket.emit("toast", "alreadyplay");
|
|
||||||
} else{
|
|
||||||
if(conf[0].vote === false) ListChange.vote(coll, id, guid, socket, full_list, last);
|
|
||||||
else socket.emit("toast", "listhaspass");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (full_list){
|
|
||||||
if(arr.num == 0) {
|
|
||||||
socket.emit("toast", "listhaspass");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit('update_required');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function voteUndecided(msg, coll, guid, offline, socket) {
|
function voteUndecided(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
if(typeof(msg) === 'object' && msg !== undefined && msg !== null){
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) {
|
if(coll == "" || coll == undefined || coll == null || !msg.hasOwnProperty("adminpass") || !msg.hasOwnProperty("pass") || !msg.hasOwnProperty("id")) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
if(msg.type == "del")
|
|
||||||
ListChange.del(msg, socket, socketid);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var id = msg.id;
|
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].vote === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
|
||||||
docs[0].vote === false))
|
|
||||||
{
|
|
||||||
ListChange.vote(coll, id, guid, socket, false, false);
|
|
||||||
}else{
|
|
||||||
socket.emit("toast", "listhaspass");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
}
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
});
|
|
||||||
} else {
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
if(msg.type == "del")
|
||||||
|
ListChange.del(msg, socket, socketid);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var id = msg.id;
|
||||||
|
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||||
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
|
if(docs !== null && docs.length !== 0 && ((docs[0].vote === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||||
|
docs[0].vote === false))
|
||||||
|
{
|
||||||
|
ListChange.vote(coll, id, guid, socket, false, false);
|
||||||
|
}else{
|
||||||
|
socket.emit("toast", "listhaspass");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
socket.emit('update_required');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function shuffle(msg, coll, guid, offline, socket) {
|
function shuffle(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null)
|
if(msg.hasOwnProperty('adminpass') && msg.adminpass !== undefined && msg.adminpass !== null)
|
||||||
{
|
{
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
var hash;
|
var hash;
|
||||||
if(msg.adminpass === "") hash = msg.adminpass;
|
if(msg.adminpass === "") hash = msg.adminpass;
|
||||||
else hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
else hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash || docs[0].adminpass === "") || docs[0].shuffle === false))
|
if(docs !== null && docs.length !== 0 && ((docs[0].adminpass == hash || docs[0].adminpass === "") || docs[0].shuffle === false))
|
||||||
{
|
{
|
||||||
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
db.collection(coll).find({now_playing:false}).forEach(function(err, docs){
|
||||||
if(!docs){
|
if(!docs){
|
||||||
List.send_list(coll, undefined, false, true, false, true);
|
List.send_list(coll, undefined, false, true, false, true);
|
||||||
socket.emit("toast", "shuffled");
|
socket.emit("toast", "shuffled");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
num = Math.floor(Math.random()*1000000);
|
num = Math.floor(Math.random()*1000000);
|
||||||
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
db.collection(coll).update({id:docs.id}, {$set:{added:num}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
socket.emit("toast", "wrongpass");
|
||||||
|
} else {
|
||||||
|
socket.emit("auth_required");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else
|
|
||||||
socket.emit("toast", "wrongpass");
|
|
||||||
} else {
|
|
||||||
socket.emit("auth_required");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var complete = function(tot, curr){
|
var complete = function(tot, curr){
|
||||||
if(tot == curr)
|
if(tot == curr)
|
||||||
{
|
{
|
||||||
List.send_list(coll, undefined, false, true, false);
|
List.send_list(coll, undefined, false, true, false);
|
||||||
List.getNextSong(coll);
|
List.getNextSong(coll);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}else
|
}else
|
||||||
socket.emit("toast", "wrongpass");
|
socket.emit("toast", "wrongpass");
|
||||||
}
|
}
|
||||||
|
|
||||||
function del(params, socket, socketid) {
|
function del(params, socket, socketid) {
|
||||||
if(params.id){
|
if(params.id){
|
||||||
var coll = emojiStrip(params.channel).toLowerCase();
|
var coll = emojiStrip(params.channel).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.decrypt_string(socketid, params.adminpass)))
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.decrypt_string(socketid, params.adminpass)))
|
||||||
{
|
{
|
||||||
db.collection(coll).find({id:params.id}, function(err, docs){
|
db.collection(coll).find({id:params.id}, function(err, docs){
|
||||||
dont_increment = true;
|
dont_increment = true;
|
||||||
if(docs[0]){
|
if(docs[0]){
|
||||||
if(docs[0].type == "suggested"){
|
if(docs[0].type == "suggested"){
|
||||||
dont_increment = false;
|
dont_increment = false;
|
||||||
}
|
}
|
||||||
db.collection(coll).remove({id:params.id}, function(err, docs){
|
db.collection(coll).remove({id:params.id}, function(err, docs){
|
||||||
socket.emit("toast", "deletesong");
|
socket.emit("toast", "deletesong");
|
||||||
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
io.to(coll).emit("channel", {type:"deleted", value: params.id});
|
||||||
if(dont_increment) db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
if(dont_increment) db.collection("frontpage_lists").update({_id: coll}, {$inc: {count: -1}, $set:{accessed: Functions.get_time()}}, {upsert: true}, function(err, docs){});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_all(msg, coll, guid, offline, socket) {
|
function delete_all(msg, coll, guid, offline, socket) {
|
||||||
var socketid = socket.zoff_id;
|
var socketid = socket.zoff_id;
|
||||||
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
|
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||||
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
||||||
|
|
||||||
db.collection(coll).find({views: {$exists: true}}, function(err, conf) {
|
db.collection(coll).find({views: {$exists: true}}, function(err, conf) {
|
||||||
if(conf.length == 1 && conf) {
|
if(conf.length == 1 && conf) {
|
||||||
conf = conf[0];
|
conf = conf[0];
|
||||||
if(conf.adminpass == hash && conf.adminpass != "" && (conf.userpass == "" || conf.userpass == undefined || (conf.userpass != "" && conf.userpass != undefined && conf.pass == hash_userpass))) {
|
if(conf.adminpass == hash && conf.adminpass != "" && (conf.userpass == "" || conf.userpass == undefined || (conf.userpass != "" && conf.userpass != undefined && conf.pass == hash_userpass))) {
|
||||||
db.collection(coll).remove({views: {$exists: false}}, {multi: true}, function(err, succ) {
|
db.collection(coll).remove({views: {$exists: false}}, {multi: true}, function(err, succ) {
|
||||||
List.send_list(coll, false, true, true, true);
|
List.send_list(coll, false, true, true, true);
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {count: 0, accessed: Functions.get_time()}}, {upsert: true}, function(err, docs) {});
|
db.collection("frontpage_lists").update({_id: coll}, {$set: {count: 0, accessed: Functions.get_time()}}, {upsert: true}, function(err, docs) {});
|
||||||
socket.emit("toast", "deleted_songs");
|
socket.emit("toast", "deleted_songs");
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("toast", "listhaspass");
|
socket.emit("toast", "listhaspass");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("update_required");
|
socket.emit("update_required");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function vote(coll, id, guid, socket, full_list, last) {
|
function vote(coll, id, guid, socket, full_list, last) {
|
||||||
db.collection(coll).find({id:id, now_playing: false}, function(err, docs){
|
db.collection(coll).find({id:id, now_playing: false}, function(err, docs){
|
||||||
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
|
if(docs !== null && docs.length > 0 && !Functions.contains(docs[0].guids, guid))
|
||||||
{
|
{
|
||||||
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:Functions.get_time()}, $push :{guids: guid}}, function(err, docs)
|
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:Functions.get_time()}, $push :{guids: guid}}, function(err, docs)
|
||||||
{
|
{
|
||||||
if((full_list && last) || (!full_list))
|
if((full_list && last) || (!full_list))
|
||||||
socket.emit("toast", "voted");
|
socket.emit("toast", "voted");
|
||||||
io.to(coll).emit("channel", {type: "vote", value: id, time: Functions.get_time()});
|
io.to(coll).emit("channel", {type: "vote", value: id, time: Functions.get_time()});
|
||||||
|
|
||||||
List.getNextSong(coll);
|
List.getNextSong(coll);
|
||||||
});
|
});
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
socket.emit("toast", "alreadyvoted");
|
socket.emit("toast", "alreadyvoted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.add_function = add_function;
|
module.exports.add_function = add_function;
|
||||||
|
|||||||
@@ -1,156 +1,156 @@
|
|||||||
function password(inp, coll, guid, offline, socket) {
|
function password(inp, coll, guid, offline, socket) {
|
||||||
if(inp !== undefined && inp !== null && inp !== "")
|
if(inp !== undefined && inp !== null && inp !== "")
|
||||||
{
|
|
||||||
pw = inp.password;
|
|
||||||
opw = inp.password;
|
|
||||||
try {
|
|
||||||
coll = inp.channel;
|
|
||||||
if(coll.length == 0) return;
|
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
|
||||||
coll = coll.replace("_", "");
|
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
|
||||||
coll = filter.clean(coll);
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uncrypted = pw;
|
|
||||||
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
if(inp.oldpass)
|
|
||||||
{
|
{
|
||||||
opw = inp.oldpass;
|
pw = inp.password;
|
||||||
}
|
opw = inp.password;
|
||||||
opw = Functions.decrypt_string(socket.zoff_id, opw);
|
try {
|
||||||
|
coll = inp.channel;
|
||||||
|
if(coll.length == 0) return;
|
||||||
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
|
coll = coll.replace("_", "");
|
||||||
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
|
coll = filter.clean(coll);
|
||||||
|
} catch(e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
if(docs !== null && docs.length !== 0)
|
socket.emit("update_required");
|
||||||
{
|
return;
|
||||||
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
|
}
|
||||||
|
|
||||||
|
uncrypted = pw;
|
||||||
|
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
||||||
|
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
|
if(inp.oldpass)
|
||||||
{
|
{
|
||||||
db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
opw = inp.oldpass;
|
||||||
if(inp.oldpass)
|
}
|
||||||
socket.emit("toast", "changedpass");
|
opw = Functions.decrypt_string(socket.zoff_id, opw);
|
||||||
else
|
|
||||||
socket.emit("toast", "correctpass");
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
socket.emit("pw", true);
|
if(docs !== null && docs.length !== 0)
|
||||||
});
|
{
|
||||||
}else
|
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
|
||||||
socket.emit("toast", "wrongpass");
|
{
|
||||||
}
|
db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
||||||
});
|
if(inp.oldpass)
|
||||||
} else {
|
socket.emit("toast", "changedpass");
|
||||||
socket.emit('update_required');
|
else
|
||||||
}
|
socket.emit("toast", "correctpass");
|
||||||
|
socket.emit("pw", true);
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
socket.emit("toast", "wrongpass");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
socket.emit('update_required');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function conf_function(params, coll, guid, offline, socket) {
|
function conf_function(params, coll, guid, offline, socket) {
|
||||||
if(params !== undefined && params !== null && params !== "" &&
|
if(params !== undefined && params !== null && params !== "" &&
|
||||||
params.hasOwnProperty('voting') &&
|
params.hasOwnProperty('voting') &&
|
||||||
params.hasOwnProperty('addsongs') &&
|
params.hasOwnProperty('addsongs') &&
|
||||||
params.hasOwnProperty('longsongs') &&
|
params.hasOwnProperty('longsongs') &&
|
||||||
params.hasOwnProperty('frontpage') &&
|
params.hasOwnProperty('frontpage') &&
|
||||||
params.hasOwnProperty('allvideos') &&
|
params.hasOwnProperty('allvideos') &&
|
||||||
params.hasOwnProperty('removeplay') &&
|
params.hasOwnProperty('removeplay') &&
|
||||||
params.hasOwnProperty('adminpass') &&
|
params.hasOwnProperty('adminpass') &&
|
||||||
params.hasOwnProperty('skipping') &&
|
params.hasOwnProperty('skipping') &&
|
||||||
params.hasOwnProperty('shuffling') &&
|
params.hasOwnProperty('shuffling') &&
|
||||||
params.hasOwnProperty('channel'))
|
params.hasOwnProperty('channel'))
|
||||||
{
|
{
|
||||||
if(coll !== undefined) {
|
if(coll !== undefined) {
|
||||||
try {
|
try {
|
||||||
coll = params.channel;
|
coll = params.channel;
|
||||||
if(coll.length == 0) return;
|
if(coll.length == 0) return;
|
||||||
coll = emojiStrip(coll).toLowerCase();
|
coll = emojiStrip(coll).toLowerCase();
|
||||||
coll = coll.replace("_", "");
|
coll = coll.replace("_", "");
|
||||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||||
coll = filter.clean(coll);
|
coll = filter.clean(coll);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(coll == "" || coll == undefined || coll == null) {
|
|
||||||
socket.emit("update_required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Functions.check_inlist(coll, guid, socket, offline);
|
|
||||||
|
|
||||||
var voting = params.voting;
|
|
||||||
var addsongs = params.addsongs;
|
|
||||||
var longsongs = params.longsongs;
|
|
||||||
var frontpage = params.frontpage;
|
|
||||||
var allvideos = params.allvideos;
|
|
||||||
var removeplay = params.removeplay;
|
|
||||||
var adminpass = params.adminpass;
|
|
||||||
var skipping = params.skipping;
|
|
||||||
var shuffling = params.shuffling;
|
|
||||||
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
|
||||||
|
|
||||||
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
|
||||||
userpass = "";
|
|
||||||
} else if(params.userpass_changed && userpass != "") {
|
|
||||||
frontpage = false;
|
|
||||||
}
|
|
||||||
var description = "";
|
|
||||||
var hash;
|
|
||||||
if(params.description) description = params.description;
|
|
||||||
|
|
||||||
if(adminpass !== "") {
|
|
||||||
hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, adminpass));
|
|
||||||
} else {
|
|
||||||
hash = adminpass;
|
|
||||||
}
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs !== null && docs.length !== 0 && (docs[0].adminpass === "" || docs[0].adminpass == hash)) {
|
|
||||||
var obj = {
|
|
||||||
addsongs:addsongs,
|
|
||||||
allvideos:allvideos,
|
|
||||||
frontpage:frontpage,
|
|
||||||
skip:skipping,
|
|
||||||
vote:voting,
|
|
||||||
removeplay:removeplay,
|
|
||||||
shuffle:shuffling,
|
|
||||||
longsongs:longsongs,
|
|
||||||
adminpass:hash,
|
|
||||||
desc: description,
|
|
||||||
};
|
|
||||||
if(params.userpass_changed) {
|
|
||||||
obj["userpass"] = userpass;
|
|
||||||
} else if (frontpage) {
|
|
||||||
obj["userpass"] = "";
|
|
||||||
}
|
}
|
||||||
db.collection(coll).update({views:{$exists:true}}, {
|
|
||||||
$set:obj
|
|
||||||
}, function(err, docs){
|
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
|
||||||
if(docs[0].adminpass !== "") docs[0].adminpass = true;
|
|
||||||
if(docs[0].hasOwnProperty("userpass") && docs[0].userpass != "") docs[0].userpass = true;
|
|
||||||
else docs[0].userpass = false;
|
|
||||||
io.to(coll).emit("conf", docs);
|
|
||||||
socket.emit("toast", "savedsettings");
|
|
||||||
|
|
||||||
db.collection("frontpage_lists").update({_id: coll}, {$set:{
|
if(coll == "" || coll == undefined || coll == null) {
|
||||||
frontpage:frontpage, accessed: Functions.get_time()}
|
socket.emit("update_required");
|
||||||
},
|
return;
|
||||||
{upsert:true}, function(err, docs){});
|
}
|
||||||
});
|
|
||||||
|
Functions.check_inlist(coll, guid, socket, offline);
|
||||||
|
|
||||||
|
var voting = params.voting;
|
||||||
|
var addsongs = params.addsongs;
|
||||||
|
var longsongs = params.longsongs;
|
||||||
|
var frontpage = params.frontpage;
|
||||||
|
var allvideos = params.allvideos;
|
||||||
|
var removeplay = params.removeplay;
|
||||||
|
var adminpass = params.adminpass;
|
||||||
|
var skipping = params.skipping;
|
||||||
|
var shuffling = params.shuffling;
|
||||||
|
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
||||||
|
|
||||||
|
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
||||||
|
userpass = "";
|
||||||
|
} else if(params.userpass_changed && userpass != "") {
|
||||||
|
frontpage = false;
|
||||||
|
}
|
||||||
|
var description = "";
|
||||||
|
var hash;
|
||||||
|
if(params.description) description = params.description;
|
||||||
|
|
||||||
|
if(adminpass !== "") {
|
||||||
|
hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, adminpass));
|
||||||
|
} else {
|
||||||
|
hash = adminpass;
|
||||||
|
}
|
||||||
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
|
if(docs !== null && docs.length !== 0 && (docs[0].adminpass === "" || docs[0].adminpass == hash)) {
|
||||||
|
var obj = {
|
||||||
|
addsongs:addsongs,
|
||||||
|
allvideos:allvideos,
|
||||||
|
frontpage:frontpage,
|
||||||
|
skip:skipping,
|
||||||
|
vote:voting,
|
||||||
|
removeplay:removeplay,
|
||||||
|
shuffle:shuffling,
|
||||||
|
longsongs:longsongs,
|
||||||
|
adminpass:hash,
|
||||||
|
desc: description,
|
||||||
|
};
|
||||||
|
if(params.userpass_changed) {
|
||||||
|
obj["userpass"] = userpass;
|
||||||
|
} else if (frontpage) {
|
||||||
|
obj["userpass"] = "";
|
||||||
|
}
|
||||||
|
db.collection(coll).update({views:{$exists:true}}, {
|
||||||
|
$set:obj
|
||||||
|
}, function(err, docs){
|
||||||
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
|
if(docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||||
|
if(docs[0].hasOwnProperty("userpass") && docs[0].userpass != "") docs[0].userpass = true;
|
||||||
|
else docs[0].userpass = false;
|
||||||
|
io.to(coll).emit("conf", docs);
|
||||||
|
socket.emit("toast", "savedsettings");
|
||||||
|
|
||||||
|
db.collection("frontpage_lists").update({_id: coll}, {$set:{
|
||||||
|
frontpage:frontpage, accessed: Functions.get_time()}
|
||||||
|
},
|
||||||
|
{upsert:true}, function(err, docs){});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
socket.emit("toast", "wrongpass");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("toast", "wrongpass");
|
socket.emit('update_required');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
|
||||||
socket.emit('update_required');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.password = password;
|
module.exports.password = password;
|
||||||
|
|||||||
@@ -1,43 +1,43 @@
|
|||||||
function thumbnail(msg, coll, guid, offline, socket) {
|
function thumbnail(msg, coll, guid, offline, socket) {
|
||||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||||
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
||||||
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
|
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
|
||||||
var channel = msg.channel.toLowerCase();
|
var channel = msg.channel.toLowerCase();
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||||
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
|
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||||
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
||||||
socket.emit("toast", "suggested_thumbnail");
|
socket.emit("toast", "suggested_thumbnail");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit("auth_required");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("toast", "thumbnail_denied");
|
socket.emit("toast", "thumbnail_denied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function description(msg, coll, guid, offline, socket) {
|
function description(msg, coll, guid, offline, socket) {
|
||||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||||
var channel = msg.channel.toLowerCase();
|
var channel = msg.channel.toLowerCase();
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||||
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
|
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||||
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
||||||
socket.emit("toast", "suggested_description");
|
socket.emit("toast", "suggested_description");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
socket.emit("auth_required");
|
socket.emit("auth_required");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
socket.emit("toast", "description_denied");
|
socket.emit("toast", "description_denied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.thumbnail = thumbnail;
|
module.exports.thumbnail = thumbnail;
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
window.addEventListener("load", function() {
|
window.addEventListener("load", function() {
|
||||||
var query = getQueryHash(window.location.hash);
|
var query = getQueryHash(window.location.hash);
|
||||||
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
|
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
|
||||||
var client_id;
|
var client_id;
|
||||||
var response;
|
var response;
|
||||||
var scope;
|
var scope;
|
||||||
|
|
||||||
if(query.spotify) {
|
if(query.spotify) {
|
||||||
client_id = "b934ecdd173648f5bcd38738af529d58";
|
client_id = "b934ecdd173648f5bcd38738af529d58";
|
||||||
response = "token";
|
response = "token";
|
||||||
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
|
scope = "playlist-read-private playlist-read-collaborative user-read-private playlist-modify-public";
|
||||||
state = query.nonce;
|
state = query.nonce;
|
||||||
window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
|
window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
|
||||||
|
|
||||||
} else if (query.youtube) {
|
} else if (query.youtube) {
|
||||||
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
|
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
|
||||||
response = "token";
|
response = "token";
|
||||||
scope = "https://www.googleapis.com/auth/youtube";
|
scope = "https://www.googleapis.com/auth/youtube";
|
||||||
state = query.nonce;
|
state = query.nonce;
|
||||||
|
|
||||||
//window.opener.callback(query);
|
//window.opener.callback(query);
|
||||||
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
|
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
|
||||||
} else {
|
} else {
|
||||||
var query_parameters = getQueryHash(window.location.hash);
|
var query_parameters = getQueryHash(window.location.hash);
|
||||||
window.opener.callback(query_parameters);
|
window.opener.callback(query_parameters);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getQueryHash(url) {
|
function getQueryHash(url) {
|
||||||
var temp_arr = url.substring(1).split("&");
|
var temp_arr = url.substring(1).split("&");
|
||||||
var done_obj = {};
|
var done_obj = {};
|
||||||
var splitted;
|
var splitted;
|
||||||
for(var i in temp_arr) {
|
for(var i in temp_arr) {
|
||||||
splitted = temp_arr[i].split("=");
|
splitted = temp_arr[i].split("=");
|
||||||
if(splitted.length == 2) {
|
if(splitted.length == 2) {
|
||||||
done_obj[splitted[0]] = splitted[1];
|
done_obj[splitted[0]] = splitted[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return done_obj;
|
return done_obj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,149 +1,149 @@
|
|||||||
var Chat = {
|
var Chat = {
|
||||||
|
|
||||||
channel_received: 0,
|
channel_received: 0,
|
||||||
all_received: 0,
|
all_received: 0,
|
||||||
chat_help: [/*"/name <new name> to change name", "/removename to remove name"*/ "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 */
|
} else */
|
||||||
if(data.value.startsWith("/help")) {
|
if(data.value.startsWith("/help")) {
|
||||||
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
|
if($(".chat-tab-li a.active").attr("href") == "#all_chat"){
|
||||||
if($("#chatall").children().length > 100) {
|
if($("#chatall").children().length > 100) {
|
||||||
$("#chatall").children()[0].remove()
|
$("#chatall").children()[0].remove()
|
||||||
}
|
}
|
||||||
for(var x = 0; x < Chat.chat_help.length; x++) {
|
for(var x = 0; x < Chat.chat_help.length; x++) {
|
||||||
var color = Helper.intToARGB(Helper.hashCode("System"));
|
var color = Helper.intToARGB(Helper.hashCode("System"));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++) {
|
for(x = color.length; x < 6; x++) {
|
||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
$("#chatall").append("<li title='Zoff''><span style='color:"+color_temp+";'>System</span>: </li>");
|
$("#chatall").append("<li title='Zoff''><span style='color:"+color_temp+";'>System</span>: </li>");
|
||||||
var in_text = document.createTextNode(Chat.chat_help[x]);
|
var in_text = document.createTextNode(Chat.chat_help[x]);
|
||||||
$("#chatall li:last")[0].appendChild(in_text);
|
$("#chatall li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($("#chatchannel").children().length > 100) {
|
if($("#chatchannel").children().length > 100) {
|
||||||
$("#chatchannel").children()[0].remove()
|
$("#chatchannel").children()[0].remove()
|
||||||
}
|
}
|
||||||
for(var x = 0; x < Chat.chat_help.length; x++) {
|
for(var x = 0; x < Chat.chat_help.length; x++) {
|
||||||
|
|
||||||
var color = Helper.intToARGB(Helper.hashCode("System"));
|
var color = Helper.intToARGB(Helper.hashCode("System"));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++) {
|
for(x = color.length; x < 6; x++) {
|
||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
|
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>System</span>: </li>");
|
||||||
var in_text = document.createTextNode(Chat.chat_help[x]);
|
var in_text = document.createTextNode(Chat.chat_help[x]);
|
||||||
$("#chatchannel li:last")[0].appendChild(in_text);
|
$("#chatchannel li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(data.value.startsWith("/removename")) {
|
} else if(data.value.startsWith("/removename")) {
|
||||||
Chat.removename();
|
Chat.removename();
|
||||||
} else if($(".chat-tab-li a.active").attr("href") == "#all_chat") {
|
} else if($(".chat-tab-li a.active").attr("href") == "#all_chat") {
|
||||||
socket.emit("all,chat", {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) {
|
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;
|
||||||
chat_unseen = true;
|
chat_unseen = true;
|
||||||
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(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));
|
||||||
if(color.length < 6) {
|
if(color.length < 6) {
|
||||||
for(x = color.length; x < 6; x++){
|
for(x = color.length; x < 6; x++){
|
||||||
color = "0" + color;
|
color = "0" + color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
$("#chatall").append("<li title='"+inp.channel+"''><span style='color:"+color_temp+";'>"+inp.from+"</span></li>");
|
$("#chatall").append("<li title='"+inp.channel+"''><span style='color:"+color_temp+";'>"+inp.from+"</span></li>");
|
||||||
var in_text = document.createTextNode(inp.msg);
|
var in_text = document.createTextNode(inp.msg);
|
||||||
$("#chatall li:last")[0].appendChild(in_text);
|
$("#chatall li:last")[0].appendChild(in_text);
|
||||||
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
|
||||||
},
|
},
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
color = Helper.hexToRgb(color.substring(0,6));
|
color = Helper.hexToRgb(color.substring(0,6));
|
||||||
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
|
||||||
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data.from+"</span></li>");
|
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data.from+"</span></li>");
|
||||||
var in_text = document.createTextNode(data.msg);
|
var in_text = document.createTextNode(data.msg);
|
||||||
$("#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;
|
||||||
},
|
},
|
||||||
|
|
||||||
chat_blink: function() {
|
chat_blink: function() {
|
||||||
blinking = true;
|
blinking = true;
|
||||||
$(".chat-link").attr("style", "color: grey !important;");
|
$(".chat-link").attr("style", "color: grey !important;");
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$(".chat-link").attr("style", "color: white !important;");
|
$(".chat-link").attr("style", "color: white !important;");
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if(blinking) Chat.chat_blink();
|
if(blinking) Chat.chat_blink();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,238 +1,238 @@
|
|||||||
var Crypt = {
|
var Crypt = {
|
||||||
|
|
||||||
conf_pass: undefined,
|
conf_pass: undefined,
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
Hostcontroller.change_enabled(conf_arr.remote);
|
Hostcontroller.change_enabled(conf_arr.remote);
|
||||||
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
if(conf_arr.width != 100) Player.set_width(conf_arr.width);
|
||||||
//if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
//if(conf_arr.name !== undefined && conf_arr.name !== "") Chat.namechange(conf_arr.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
key = btoa(key);
|
key = btoa(key);
|
||||||
var decrypted = CryptoJS.AES.decrypt(
|
var decrypted = CryptoJS.AES.decrypt(
|
||||||
cookie,key,
|
cookie,key,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
return $.parseJSON(decrypted.toString(CryptoJS.enc.Utf8));
|
||||||
},
|
},
|
||||||
|
|
||||||
decrypt_pass: function(pass) {
|
decrypt_pass: function(pass) {
|
||||||
var 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);
|
||||||
var decrypted = CryptoJS.AES.decrypt(
|
var decrypted = CryptoJS.AES.decrypt(
|
||||||
pass,key,
|
pass,key,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return decrypted.toString(CryptoJS.enc.Utf8);
|
return decrypted.toString(CryptoJS.enc.Utf8);
|
||||||
},
|
},
|
||||||
|
|
||||||
encrypt: function(json_formated, cookie) {
|
encrypt: function(json_formated, cookie) {
|
||||||
var to_encrypt = JSON.stringify(json_formated);
|
var to_encrypt = JSON.stringify(json_formated);
|
||||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
key = btoa(key);
|
key = btoa(key);
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
to_encrypt,
|
to_encrypt,
|
||||||
key,
|
key,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var CookieDate = new Date();
|
var CookieDate = new Date();
|
||||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||||
if (location.protocol != "https:"){
|
if (location.protocol != "https:"){
|
||||||
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = cookie+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
} else {
|
} else {
|
||||||
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = cookie+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
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;
|
||||||
} else {
|
} else {
|
||||||
Crypt.set_offline(false);
|
Crypt.set_offline(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
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: {}};
|
||||||
|
|
||||||
var string_it = JSON.stringify(cookie_object);
|
var string_it = JSON.stringify(cookie_object);
|
||||||
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
var key = btoa("0103060703080703080701") + btoa("0103060703080703080701");
|
||||||
key = key.substring(0,32);
|
key = key.substring(0,32);
|
||||||
key = btoa(key);
|
key = btoa(key);
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
string_it,
|
string_it,
|
||||||
key,
|
key,
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7
|
padding: CryptoJS.pad.Pkcs7
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var CookieDate = new Date();
|
var CookieDate = new Date();
|
||||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||||
|
|
||||||
if (location.protocol != "https:"){
|
if (location.protocol != "https:"){
|
||||||
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
} else {
|
} else {
|
||||||
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
document.cookie = name+"="+encrypted.toString()+";secure;expires="+CookieDate.toGMTString()+";path=/;";
|
||||||
}
|
}
|
||||||
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||||
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||||
return Crypt.getCookie(name);
|
return Crypt.getCookie(name);
|
||||||
},
|
},
|
||||||
|
|
||||||
set_pass: function(chan, pass) {
|
set_pass: function(chan, pass) {
|
||||||
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());
|
||||||
},
|
},
|
||||||
|
|
||||||
set_userpass: function(chan, pass) {
|
set_userpass: function(chan, pass) {
|
||||||
Crypt.conf_pass.passwords["userpass"] = pass;
|
Crypt.conf_pass.passwords["userpass"] = pass;
|
||||||
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;
|
||||||
},
|
},
|
||||||
|
|
||||||
get_userpass: function(chan) {
|
get_userpass: function(chan) {
|
||||||
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords["userpass"];
|
if(Crypt.conf_pass !== undefined) return Crypt.conf_pass.passwords["userpass"];
|
||||||
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);
|
||||||
key = btoa(key);
|
key = btoa(key);
|
||||||
var iv = btoa(Crypt.makeiv());
|
var iv = btoa(Crypt.makeiv());
|
||||||
var encrypted = CryptoJS.AES.encrypt(
|
var encrypted = CryptoJS.AES.encrypt(
|
||||||
pass,
|
pass,
|
||||||
CryptoJS.enc.Base64.parse(key),
|
CryptoJS.enc.Base64.parse(key),
|
||||||
{
|
{
|
||||||
mode: CryptoJS.mode.CBC,
|
mode: CryptoJS.mode.CBC,
|
||||||
padding: CryptoJS.pad.Pkcs7,
|
padding: CryptoJS.pad.Pkcs7,
|
||||||
iv: CryptoJS.enc.Base64.parse(iv),
|
iv: CryptoJS.enc.Base64.parse(iv),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
window.encrypted = encrypted;
|
window.encrypted = encrypted;
|
||||||
return encrypted.toString() + "$" + iv;
|
return encrypted.toString() + "$" + iv;
|
||||||
},
|
},
|
||||||
|
|
||||||
makeiv: function() {
|
makeiv: function() {
|
||||||
var text = "";
|
var text = "";
|
||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
|
||||||
for( var i=0; i < 16; i++ )
|
for( var i=0; i < 16; i++ )
|
||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
|
|
||||||
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");
|
||||||
},
|
},
|
||||||
|
|
||||||
getCookie: function(name) {
|
getCookie: function(name) {
|
||||||
var value = "; " + document.cookie;
|
var value = "; " + document.cookie;
|
||||||
var parts = value.split("; " + name + "=");
|
var parts = value.split("; " + name + "=");
|
||||||
if (parts.length == 2) return parts.pop().split(";").shift();
|
if (parts.length == 2) return parts.pop().split(";").shift();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,136 +28,136 @@ var user_auth_started = false;
|
|||||||
var user_auth_avoid = false;
|
var user_auth_avoid = false;
|
||||||
|
|
||||||
var connection_options = {
|
var connection_options = {
|
||||||
'sync disconnect on unload':true,
|
'sync disconnect on unload':true,
|
||||||
'secure': true,
|
'secure': true,
|
||||||
'force new connection': true
|
'force new connection': true
|
||||||
};
|
};
|
||||||
|
|
||||||
var Crypt = {
|
var Crypt = {
|
||||||
crypt_pass: function(pass) {
|
crypt_pass: function(pass) {
|
||||||
return pass;
|
return pass;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
window.parentOrigin = event.origin;
|
window.parentOrigin = event.origin;
|
||||||
}
|
}
|
||||||
if(event.data == "lower") {
|
if(event.data == "lower") {
|
||||||
window.setVolume(10);
|
window.setVolume(10);
|
||||||
}else if(event.data == "reset") {
|
}else if(event.data == "reset") {
|
||||||
window.setVolume(100);
|
window.setVolume(100);
|
||||||
} else if(event.data == "get_info") {
|
} else if(event.data == "get_info") {
|
||||||
window.parentWindow.postMessage({type: "np", title: song_title}, window.parentOrigin);
|
window.parentWindow.postMessage({type: "np", title: song_title}, window.parentOrigin);
|
||||||
window.parentWindow.postMessage({type: "controller", id: Hostcontroller.old_id}, window.parentOrigin);
|
window.parentWindow.postMessage({type: "controller", id: Hostcontroller.old_id}, window.parentOrigin);
|
||||||
if(full_playlist.length > 0) {
|
if(full_playlist.length > 0) {
|
||||||
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
|
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hash.indexOf("videoonly") > -1) {
|
if(hash.indexOf("videoonly") > -1) {
|
||||||
$("#playlist").addClass("hide");
|
$("#playlist").addClass("hide");
|
||||||
$("#controls").addClass("hide");
|
$("#controls").addClass("hide");
|
||||||
$("#player").addClass("video_only");
|
$("#player").addClass("video_only");
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#locked_channel").modal({
|
$("#locked_channel").modal({
|
||||||
dismissible: false
|
dismissible: false
|
||||||
});
|
});
|
||||||
color = "#" + hash[1];
|
color = "#" + hash[1];
|
||||||
add = "https://zoff.me";
|
add = "https://zoff.me";
|
||||||
socket = io.connect(''+add+':8080', connection_options);
|
socket = io.connect(''+add+':8080', connection_options);
|
||||||
|
|
||||||
socket.on('auth_required', function() {
|
socket.on('auth_required', 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);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("self_ping", function() {
|
socket.on("self_ping", function() {
|
||||||
if(chan != undefined && chan.toLowerCase() != "") {
|
if(chan != undefined && chan.toLowerCase() != "") {
|
||||||
socket.emit("self_ping", {channel: chan.toLowerCase()});
|
socket.emit("self_ping", {channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("viewers", function(view) {
|
socket.on("viewers", function(view) {
|
||||||
viewers = view;
|
viewers = view;
|
||||||
|
|
||||||
if(song_title !== undefined)
|
if(song_title !== undefined)
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
});
|
});
|
||||||
|
|
||||||
setup_host_initialization();
|
setup_host_initialization();
|
||||||
setup_youtube_listener();
|
setup_youtube_listener();
|
||||||
setup_list_listener();
|
setup_list_listener();
|
||||||
|
|
||||||
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
|
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
|
||||||
|
|
||||||
Player.loadPlayer();
|
Player.loadPlayer();
|
||||||
|
|
||||||
Playercontrols.initSlider();
|
Playercontrols.initSlider();
|
||||||
|
|
||||||
window.setVolume = setVolume;
|
window.setVolume = setVolume;
|
||||||
$("#controls").css("background-color", color);
|
$("#controls").css("background-color", color);
|
||||||
$("#playlist").css("background-color", color);
|
$("#playlist").css("background-color", color);
|
||||||
if(hash.indexOf("controll") > -1) {
|
if(hash.indexOf("controll") > -1) {
|
||||||
Hostcontroller.change_enabled(true);
|
Hostcontroller.change_enabled(true);
|
||||||
} else {
|
} else {
|
||||||
Hostcontroller.change_enabled(false);
|
Hostcontroller.change_enabled(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVolume(val) {
|
function setVolume(val) {
|
||||||
$("#volume").slider('value', val);
|
$("#volume").slider('value', 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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,462 +7,462 @@ var rotation_timeout;
|
|||||||
|
|
||||||
var Frontpage = {
|
var Frontpage = {
|
||||||
|
|
||||||
blob_list: [],
|
blob_list: [],
|
||||||
|
|
||||||
winter: (new Date()).getMonth() >= 10 ? true : false,
|
winter: (new Date()).getMonth() >= 10 ? true : false,
|
||||||
|
|
||||||
times_rotated: 0,
|
times_rotated: 0,
|
||||||
|
|
||||||
all_channels: [],
|
all_channels: [],
|
||||||
|
|
||||||
frontpage_function: function(msg) {
|
frontpage_function: function(msg) {
|
||||||
frontpage = true;
|
frontpage = true;
|
||||||
|
|
||||||
Helper.log("-----------");
|
Helper.log("-----------");
|
||||||
Helper.log("Frontpage fetch");
|
Helper.log("Frontpage fetch");
|
||||||
Helper.log(msg);
|
Helper.log(msg);
|
||||||
Helper.log("------------");
|
Helper.log("------------");
|
||||||
Frontpage.all_channels = msg.channels;
|
Frontpage.all_channels = msg.channels;
|
||||||
Frontpage.populate_channels(msg.channels, true);
|
Frontpage.populate_channels(msg.channels, true);
|
||||||
Frontpage.set_viewers(msg.viewers);
|
Frontpage.set_viewers(msg.viewers);
|
||||||
},
|
},
|
||||||
|
|
||||||
populate_channels: function(lists, popular) {
|
populate_channels: function(lists, popular) {
|
||||||
$("#channels").empty();
|
$("#channels").empty();
|
||||||
|
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
|
||||||
if(popular) {
|
if(popular) {
|
||||||
lists = lists.sort(Helper.predicate({
|
lists = lists.sort(Helper.predicate({
|
||||||
name: 'pinned',
|
name: 'pinned',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'viewers',
|
name: 'viewers',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'accessed',
|
name: 'accessed',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'count',
|
name: 'count',
|
||||||
reverse: true
|
reverse: true
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
lists = lists.sort(Helper.predicate({
|
lists = lists.sort(Helper.predicate({
|
||||||
name: 'viewers',
|
name: 'viewers',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, {
|
}, {
|
||||||
name: 'count',
|
name: 'count',
|
||||||
reverse: true
|
reverse: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Helper.mobilecheck()) {
|
if(!Helper.mobilecheck()) {
|
||||||
clearTimeout(rotation_timeout);
|
clearTimeout(rotation_timeout);
|
||||||
Frontpage.add_backdrop(lists, 0);
|
Frontpage.add_backdrop(lists, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pre_card = $(channel_list);
|
pre_card = $(channel_list);
|
||||||
|
|
||||||
Helper.log("------------");
|
Helper.log("------------");
|
||||||
Helper.log(pre_card);
|
Helper.log(pre_card);
|
||||||
Helper.log("-------------");
|
Helper.log("-------------");
|
||||||
|
|
||||||
for(var x in lists) {
|
for(var x in lists) {
|
||||||
var chan = lists[x]._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", "");
|
||||||
}
|
}
|
||||||
card.find(".chan-name").text(chan);
|
card.find(".chan-name").text(chan);
|
||||||
card.find(".chan-name").attr("title", chan);
|
card.find(".chan-name").attr("title", chan);
|
||||||
card.find(".chan-views").text(viewers);
|
card.find(".chan-views").text(viewers);
|
||||||
card.find(".chan-songs").text(song_count);
|
card.find(".chan-songs").text(song_count);
|
||||||
card.find(".chan-bg").attr("style", img);
|
card.find(".chan-bg").attr("style", img);
|
||||||
card.find(".chan-link").attr("href", chan + "/");
|
card.find(".chan-link").attr("href", chan + "/");
|
||||||
|
|
||||||
if(description != "" && 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 = "";
|
||||||
} else {
|
} else {
|
||||||
card.find(".card-reveal").remove();
|
card.find(".card-reveal").remove();
|
||||||
card.find(".card").removeClass("sticky-action")
|
card.find(".card").removeClass("sticky-action")
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#channels").append(card.html());
|
$("#channels").append(card.html());
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = {};
|
||||||
for(var x in options_list) {
|
for(var x in options_list) {
|
||||||
data[options_list[x]._id] = null;
|
data[options_list[x]._id] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var to_autocomplete = "input.desktop-search";
|
var to_autocomplete = "input.desktop-search";
|
||||||
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
|
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
|
||||||
|
|
||||||
$(to_autocomplete).autocomplete({
|
$(to_autocomplete).autocomplete({
|
||||||
data: data,
|
data: data,
|
||||||
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
|
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
|
||||||
onAutocomplete: function(val) {
|
onAutocomplete: function(val) {
|
||||||
Frontpage.to_channel(val, false);
|
Frontpage.to_channel(val, false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("preloader").style.display = "none";
|
document.getElementById("preloader").style.display = "none";
|
||||||
//Materialize.fadeInImage('#channels');
|
//Materialize.fadeInImage('#channels');
|
||||||
$("#channels").fadeIn(800);
|
$("#channels").fadeIn(800);
|
||||||
$("#searchFrontpage").focus();
|
$("#searchFrontpage").focus();
|
||||||
num = 0;
|
num = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
sortFunction: function(a, b) {
|
sortFunction: function(a, b) {
|
||||||
var o1 = a.viewers;
|
var o1 = a.viewers;
|
||||||
var o2 = b.viewers;
|
var o2 = b.viewers;
|
||||||
|
|
||||||
var p1 = a.count;
|
var p1 = a.count;
|
||||||
var p2 = b.count;
|
var p2 = b.count;
|
||||||
|
|
||||||
if (o1 < o2) return 1;
|
if (o1 < o2) return 1;
|
||||||
if (o1 > o2) return -1;
|
if (o1 > o2) return -1;
|
||||||
if (p1 < p2) return 1;
|
if (p1 < p2) return 1;
|
||||||
if (p1 > p2) return -1;
|
if (p1 > p2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
sortFunction_active: function(a, b){
|
sortFunction_active: function(a, b){
|
||||||
var o1 = a.accessed;
|
var o1 = a.accessed;
|
||||||
var o2 = b.accessed;
|
var o2 = b.accessed;
|
||||||
|
|
||||||
var p1 = a.count;
|
var p1 = a.count;
|
||||||
var p2 = b.count;
|
var p2 = b.count;
|
||||||
|
|
||||||
if (o1 < o2) return 1;
|
if (o1 < o2) return 1;
|
||||||
if (o1 > o2) return -1;
|
if (o1 > o2) return -1;
|
||||||
if (p1 < p2) return 1;
|
if (p1 < p2) return 1;
|
||||||
if (p1 > p2) return -1;
|
if (p1 > p2) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
getCookie: function(cname) {
|
getCookie: function(cname) {
|
||||||
var name = cname + "=";
|
var name = cname + "=";
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
for(var i=0; i<ca.length; i++) {
|
for(var i=0; i<ca.length; i++) {
|
||||||
var c = ca[i];
|
var c = ca[i];
|
||||||
while (c.charAt(0)==' ') c = c.substring(1);
|
while (c.charAt(0)==' ') c = c.substring(1);
|
||||||
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
|
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
|
|
||||||
add_backdrop: function(list, i) {
|
add_backdrop: function(list, i) {
|
||||||
if(i >= list.length || i >= 20) i = 0;
|
if(i >= list.length || i >= 20) i = 0;
|
||||||
|
|
||||||
var id = list[i].id;
|
var id = list[i].id;
|
||||||
if(Frontpage.blob_list[i] !== undefined){
|
if(Frontpage.blob_list[i] !== undefined){
|
||||||
//$(".room-namer").css("opacity", 0);
|
//$(".room-namer").css("opacity", 0);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
if(frontpage){
|
if(frontpage){
|
||||||
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
|
$("#mega-background").css("background", "url(data:image/png;base64,"+Frontpage.blob_list[i]+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i]._id);
|
$(".desktop-search").attr("placeholder", list[i]._id);
|
||||||
//$(".room-namer").css("opacity", 1);
|
//$(".room-namer").css("opacity", 1);
|
||||||
}
|
}
|
||||||
},500);
|
},500);
|
||||||
} else {
|
} else {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.src = "/assets/images/thumbnails/"+id+".jpg";
|
img.src = "/assets/images/thumbnails/"+id+".jpg";
|
||||||
|
|
||||||
img.onerror = function(){ // Failed to load
|
img.onerror = function(){ // Failed to load
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {id:id},
|
data: {id:id},
|
||||||
url: "/api/imageblob",
|
url: "/api/imageblob",
|
||||||
success: function(data){
|
success: function(data){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
|
$("#mega-background").css("background", "url(/assets/images/thumbnails/"+data+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i]._id);
|
$(".desktop-search").attr("placeholder", list[i]._id);
|
||||||
},500);
|
},500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
img.onload = function(){ // Loaded successfully
|
img.onload = function(){ // Loaded successfully
|
||||||
$("#mega-background").css("background", "url("+img.src+")");
|
$("#mega-background").css("background", "url("+img.src+")");
|
||||||
$("#mega-background").css("background-size" , "200%");
|
$("#mega-background").css("background-size" , "200%");
|
||||||
$("#mega-background").css("opacity", 1);
|
$("#mega-background").css("opacity", 1);
|
||||||
$(".desktop-search").attr("placeholder", list[i]._id);
|
$(".desktop-search").attr("placeholder", list[i]._id);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
rotation_timeout = setTimeout(function(){
|
rotation_timeout = setTimeout(function(){
|
||||||
if(Frontpage.times_rotated == 50 && frontpage){
|
if(Frontpage.times_rotated == 50 && frontpage){
|
||||||
Frontpage.times_rotated = 0;
|
Frontpage.times_rotated = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
Frontpage.get_frontpage_lists();
|
Frontpage.get_frontpage_lists();
|
||||||
//socket.emit("frontpage_lists", {version: parseInt(localStorage.getItem("VERSION"))});
|
//socket.emit("frontpage_lists", {version: parseInt(localStorage.getItem("VERSION"))});
|
||||||
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||||
}else if(frontpage){
|
}else if(frontpage){
|
||||||
Frontpage.times_rotated += 1;
|
Frontpage.times_rotated += 1;
|
||||||
Frontpage.add_backdrop(list, i+1);
|
Frontpage.add_backdrop(list, i+1);
|
||||||
}
|
}
|
||||||
},6000);
|
},6000);
|
||||||
},
|
},
|
||||||
|
|
||||||
get_frontpage_lists: function() {
|
get_frontpage_lists: function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/frontpages",
|
url: "/api/frontpages",
|
||||||
method: "get",
|
method: "get",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
Frontpage.frontpage_function(response);
|
Frontpage.frontpage_function(response);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
Materialize.toast("Couldn't fetch lists, trying again in 3 seconds..", 3000, "red lighten connect_error");
|
Materialize.toast("Couldn't fetch lists, trying again in 3 seconds..", 3000, "red lighten connect_error");
|
||||||
retry_frontpage = setTimeout(function(){
|
retry_frontpage = setTimeout(function(){
|
||||||
Frontpage.get_frontpage_lists();
|
Frontpage.get_frontpage_lists();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
start_snowfall: function() {
|
start_snowfall: function() {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
var x = Math.floor((Math.random() * window.innerWidth) + 1);
|
var x = Math.floor((Math.random() * window.innerWidth) + 1);
|
||||||
var snow = document.createElement("div");
|
var snow = document.createElement("div");
|
||||||
var parent = document.getElementsByClassName("mega")[0];
|
var parent = document.getElementsByClassName("mega")[0];
|
||||||
|
|
||||||
snow.className = "snow";
|
snow.className = "snow";
|
||||||
//snow.attr("left", x);
|
//snow.attr("left", x);
|
||||||
snow.style.left = x+"px";
|
snow.style.left = x+"px";
|
||||||
snow.style.top = "0px";
|
snow.style.top = "0px";
|
||||||
parent.appendChild(snow);
|
parent.appendChild(snow);
|
||||||
Frontpage.fall_snow(snow);
|
Frontpage.fall_snow(snow);
|
||||||
Frontpage.start_snowfall();
|
Frontpage.start_snowfall();
|
||||||
}, 800);
|
}, 800);
|
||||||
},
|
},
|
||||||
|
|
||||||
fall_snow: function(corn) {
|
fall_snow: function(corn) {
|
||||||
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
|
corn.style.top = (parseInt(corn.style.top.replace("px", ""))+2)+"px";
|
||||||
if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
|
if(parseInt(corn.style.top.replace("px", "")) < document.getElementById("mega-background").offsetHeight-2.5){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
Frontpage.fall_snow(corn);
|
Frontpage.fall_snow(corn);
|
||||||
},50);
|
},50);
|
||||||
}else{
|
}else{
|
||||||
corn.remove();
|
corn.remove();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
set_viewers: function(viewers) {
|
set_viewers: function(viewers) {
|
||||||
$("#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;
|
||||||
new_channel = new_channel.toLowerCase();
|
new_channel = new_channel.toLowerCase();
|
||||||
clearTimeout(rotation_timeout);
|
clearTimeout(rotation_timeout);
|
||||||
if(Helper.mobilecheck()){
|
if(Helper.mobilecheck()){
|
||||||
Helper.log("removing all listeners");
|
Helper.log("removing all listeners");
|
||||||
socket.removeAllListeners();
|
socket.removeAllListeners();
|
||||||
}
|
}
|
||||||
$("#main-container").css("background-color", "#2d2d2d");
|
$("#main-container").css("background-color", "#2d2d2d");
|
||||||
$("#frontpage-viewer-counter").tooltip("remove");
|
$("#frontpage-viewer-counter").tooltip("remove");
|
||||||
$("#offline-mode").tooltip("remove");
|
$("#offline-mode").tooltip("remove");
|
||||||
currently_showing_channels = 1;
|
currently_showing_channels = 1;
|
||||||
clearTimeout(retry_frontpage);
|
clearTimeout(retry_frontpage);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/" + new_channel,
|
url: "/" + new_channel,
|
||||||
method: "get",
|
method: "get",
|
||||||
data: {channel: new_channel},
|
data: {channel: new_channel},
|
||||||
success: function(e){
|
success: function(e){
|
||||||
|
|
||||||
if(Player.player !== ""){
|
if(Player.player !== ""){
|
||||||
//Player.player.destroy();
|
//Player.player.destroy();
|
||||||
socket.emit("change_channel", {channel: chan.toLowerCase()});
|
socket.emit("change_channel", {channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
$("#frontpage_player").empty();
|
$("#frontpage_player").empty();
|
||||||
if(Helper.mobilecheck()) {
|
if(Helper.mobilecheck()) {
|
||||||
Helper.log("disconnecting");
|
Helper.log("disconnecting");
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!popstate){
|
if(!popstate){
|
||||||
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
window.history.pushState("to the channel!", "Title", "/" + new_channel);
|
||||||
if(prev_chan_list == "") prev_chan_list = new_channel;
|
if(prev_chan_list == "") prev_chan_list = new_channel;
|
||||||
if(prev_chan_player == "") prev_chan_player = new_channel;
|
if(prev_chan_player == "") prev_chan_player = new_channel;
|
||||||
window.chan = new_channel;
|
window.chan = new_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = $("<div>" + e + "</div>");
|
var response = $("<div>" + e + "</div>");
|
||||||
|
|
||||||
$('select').material_select('destroy');
|
$('select').material_select('destroy');
|
||||||
$(".mega").remove();
|
$(".mega").remove();
|
||||||
$(".mobile-search").remove();
|
$(".mobile-search").remove();
|
||||||
$("main").attr("class", "container center-align main");
|
$("main").attr("class", "container center-align main");
|
||||||
$("#main-container").addClass("channelpage");
|
$("#main-container").addClass("channelpage");
|
||||||
//$("header").html($($(e)[63]).html());
|
//$("header").html($($(e)[63]).html());
|
||||||
$("header").html($(response.find("header")).html());
|
$("header").html($(response.find("header")).html());
|
||||||
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
|
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.player === undefined){
|
||||||
$("main").html($(response.find("main")).html());
|
$("main").html($(response.find("main")).html());
|
||||||
} else {
|
} else {
|
||||||
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
|
$("#main-row").append($(response.find("#playlist").wrap("<div>").parent().html()));
|
||||||
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
|
$("#video-container").append($(response.find("#main_components").wrap("<div>").parent().html()));
|
||||||
$("#main-row").append("<div id='playbar'></div>");
|
$("#main-row").append("<div id='playbar'></div>");
|
||||||
$("#player").removeClass("player_bottom");
|
$("#player").removeClass("player_bottom");
|
||||||
$("#main-row").removeClass("frontpage_modified_heights");
|
$("#main-row").removeClass("frontpage_modified_heights");
|
||||||
$("#main_section_frontpage").remove();
|
$("#main_section_frontpage").remove();
|
||||||
$("#closePlayer").remove();
|
$("#closePlayer").remove();
|
||||||
$("#player_bottom_overlay").remove();
|
$("#player_bottom_overlay").remove();
|
||||||
}
|
}
|
||||||
$("#search").attr("placeholder", "Find song on YouTube...");
|
$("#search").attr("placeholder", "Find song on YouTube...");
|
||||||
$(".page-footer").addClass("padding-bottom-novideo");
|
$(".page-footer").addClass("padding-bottom-novideo");
|
||||||
from_frontpage = true;
|
from_frontpage = true;
|
||||||
if($("#alreadychannel").length == 1){
|
if($("#alreadychannel").length == 1){
|
||||||
init();
|
init();
|
||||||
}else{
|
}else{
|
||||||
fromFront = true;
|
fromFront = true;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
|
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.capitalizeFirstLetter = function() {
|
String.prototype.capitalizeFirstLetter = function() {
|
||||||
return this.charAt(0).toUpperCase() + this.slice(1);
|
return this.charAt(0).toUpperCase() + this.slice(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
function share_link_modifier_frontpage() {
|
function share_link_modifier_frontpage() {
|
||||||
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/");
|
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/");
|
||||||
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;");
|
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/', 'Share Zoff','width=600,height=300'); return false;");
|
||||||
$("#twitter-code-link").attr("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic");
|
$("#twitter-code-link").attr("href", "https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic");
|
||||||
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
|
$("#twitter-code-link").attr("onclick", "window.open('https://twitter.com/intent/tweet?url=https://zoff.me/&text=Check%20out%20Zoff!&via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
|
||||||
//$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
|
//$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
|
||||||
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
|
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.me/&choe=UTF-8&chld=L%7C1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function initfp() {
|
function initfp() {
|
||||||
|
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
Frontpage.blob_list = [];
|
Frontpage.blob_list = [];
|
||||||
if(date.getMonth() == 3 && date.getDate() == 1){
|
if(date.getMonth() == 3 && date.getDate() == 1){
|
||||||
$(".mega").css("-webkit-transform", "rotate(180deg)");
|
$(".mega").css("-webkit-transform", "rotate(180deg)");
|
||||||
$(".mega").css("-moz-transform", "rotate(180deg)");
|
$(".mega").css("-moz-transform", "rotate(180deg)");
|
||||||
//Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000);
|
//Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
window.onpopstate = function(e){
|
window.onpopstate = function(e){
|
||||||
var url_split = window.location.href.split("/");
|
var url_split = window.location.href.split("/");
|
||||||
|
|
||||||
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
|
if(url_split[3] !== "" && url_split[3].substring(0,1) != "#"){
|
||||||
Frontpage.to_channel(url_split[3], true);
|
Frontpage.to_channel(url_split[3], true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
channel_list = $("#channel-list-container").clone().html();
|
channel_list = $("#channel-list-container").clone().html();
|
||||||
|
|
||||||
if(window.location.hostname != "fb.zoff.me") share_link_modifier_frontpage();
|
if(window.location.hostname != "fb.zoff.me") share_link_modifier_frontpage();
|
||||||
|
|
||||||
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me";
|
if(window.location.hostname == "zoff.me" || window.location.hostname == "fb.zoff.me") add = "https://zoff.me";
|
||||||
else add = window.location.hostname;
|
else add = window.location.hostname;
|
||||||
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) {
|
if(socket === undefined || Helper.mobilecheck() || user_auth_avoid) {
|
||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
|
if($("#alreadyfp").length === 0 || Helper.mobilecheck() || !socket._callbacks.$playlists || user_auth_avoid){
|
||||||
setup_playlist_listener();
|
setup_playlist_listener();
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#about").modal();
|
$("#about").modal();
|
||||||
$("#help").modal();
|
$("#help").modal();
|
||||||
$("#contact").modal();
|
$("#contact").modal();
|
||||||
$('select').material_select();
|
$('select').material_select();
|
||||||
|
|
||||||
Helper.log("----");
|
Helper.log("----");
|
||||||
Helper.log("Sending frontpage_lists");
|
Helper.log("Sending frontpage_lists");
|
||||||
Helper.log("Socket", socket);
|
Helper.log("Socket", socket);
|
||||||
Helper.log("-----");
|
Helper.log("-----");
|
||||||
|
|
||||||
Crypt.init();
|
Crypt.init();
|
||||||
if(Crypt.get_offline()){
|
if(Crypt.get_offline()){
|
||||||
change_offline(true, offline);
|
change_offline(true, offline);
|
||||||
} else {
|
} else {
|
||||||
$("#offline-mode").tooltip({
|
$("#offline-mode").tooltip({
|
||||||
delay: 5,
|
delay: 5,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tooltip: "Enable local mode"
|
tooltip: "Enable local mode"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$("#frontpage-viewer-counter").tooltip({
|
$("#frontpage-viewer-counter").tooltip({
|
||||||
delay: 5,
|
delay: 5,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
tooltip: "Total Viewers"
|
tooltip: "Total Viewers"
|
||||||
});
|
});
|
||||||
Frontpage.get_frontpage_lists();
|
Frontpage.get_frontpage_lists();
|
||||||
//socket.emit('frontpage_lists', {version: parseInt(localStorage.getItem("VERSION"))});
|
//socket.emit('frontpage_lists', {version: parseInt(localStorage.getItem("VERSION"))});
|
||||||
//socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
//socket.emit('get_userlists', Crypt.getCookie('_uI'));
|
||||||
|
|
||||||
$("#channel-load").css("display", "none");
|
$("#channel-load").css("display", "none");
|
||||||
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
|
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
|
||||||
if(window.location.hash == "#donation") {
|
if(window.location.hash == "#donation") {
|
||||||
window.location.hash = "#";
|
window.location.hash = "#";
|
||||||
$('#donation').modal();
|
$('#donation').modal();
|
||||||
$('#donation').modal('open');
|
$('#donation').modal('open');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!localStorage.ok_cookie){
|
if(!localStorage.ok_cookie){
|
||||||
before_toast();
|
before_toast();
|
||||||
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);
|
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pad = 0;
|
var pad = 0;
|
||||||
document.getElementById("zicon").addEventListener("click", function(){
|
document.getElementById("zicon").addEventListener("click", function(){
|
||||||
pad+=10;
|
pad+=10;
|
||||||
document.getElementById("zicon").style.paddingLeft = pad+"%";
|
document.getElementById("zicon").style.paddingLeft = pad+"%";
|
||||||
if(pad >= 100)
|
if(pad >= 100)
|
||||||
window.location.href = 'http://etys.no';
|
window.location.href = 'http://etys.no';
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!Helper.mobilecheck() && Frontpage.winter) {
|
if(!Helper.mobilecheck() && Frontpage.winter) {
|
||||||
$(".mega").prepend('<div id="snow"></div>');
|
$(".mega").prepend('<div id="snow"></div>');
|
||||||
//Frontpage.start_snowfall();
|
//Frontpage.start_snowfall();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Helper.mobilecheck()){
|
if(Helper.mobilecheck()){
|
||||||
$('input#searchFrontpage').characterCounter();
|
$('input#searchFrontpage').characterCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
|
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
chromecastReady = true;
|
chromecastReady = true;
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user