mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Merge branch 'master' of github.com:nixolas1/Zoff
This commit is contained in:
@@ -16,4 +16,4 @@
|
|||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<link type="text/css" rel="stylesheet" href="static/css/materialize.min.css" media="screen,projection"/>
|
<link type="text/css" rel="stylesheet" href="static/css/materialize.min.css" media="screen,projection"/>
|
||||||
<link rel="stylesheet" type="text/css" href="static/css/style.css" title="Default" />
|
<link rel="stylesheet" type="text/css" href="static/css/style.css" title="Default" />
|
||||||
<link rel="icon" type="image/png" href="static/images/favicon.png"/>
|
<link rel="icon" id="favicon" type="image/png" href="static/images/favicon.png"/>
|
||||||
|
|||||||
134
server/server.js
134
server/server.js
@@ -37,6 +37,7 @@ io.on('connection', function(socket){
|
|||||||
var in_list = false;
|
var in_list = false;
|
||||||
|
|
||||||
socket.on('chat', function (data) {
|
socket.on('chat', function (data) {
|
||||||
|
check_inlist(coll, guid, socket);
|
||||||
if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length)
|
if(data != "" && data !== undefined && data !== null && data.length < 151 && data.replace(/\s/g, '').length)
|
||||||
io.sockets.emit('chat,'+coll, rndName(guid) + ": " + data);
|
io.sockets.emit('chat,'+coll, rndName(guid) + ": " + data);
|
||||||
});
|
});
|
||||||
@@ -95,16 +96,7 @@ io.on('connection', function(socket){
|
|||||||
|
|
||||||
console.log(guid + " joined list " + coll);
|
console.log(guid + " joined list " + coll);
|
||||||
|
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
|
|
||||||
@@ -134,16 +126,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(id !== undefined && id !== null && id != "")
|
if(id !== undefined && id !== null && id != "")
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.collection(coll).find({now_playing:true}, function(err, np){
|
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||||
//console.log(docs);
|
//console.log(docs);
|
||||||
@@ -208,16 +191,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(arr !== undefined && arr !== null && arr != "")
|
if(arr !== undefined && arr !== null && arr != "")
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = arr[0];
|
var id = arr[0];
|
||||||
var title = arr[1];
|
var title = arr[1];
|
||||||
@@ -258,16 +232,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(msg !== undefined && msg !== null)
|
if(msg !== undefined && msg !== null)
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(msg[2] == "del")
|
if(msg[2] == "del")
|
||||||
del(msg, socket);
|
del(msg, socket);
|
||||||
@@ -297,16 +262,8 @@ io.on('connection', function(socket){
|
|||||||
pw = inp[0];
|
pw = inp[0];
|
||||||
coll = inp[1];
|
coll = inp[1];
|
||||||
//guid = inp[2];
|
//guid = inp[2];
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
//console.log(coll);
|
//console.log(coll);
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
//console.log(docs);
|
//console.log(docs);
|
||||||
@@ -330,16 +287,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(list !== undefined && list !== null && list != "")
|
if(list !== undefined && list !== null && list != "")
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
adminpass = "";
|
adminpass = "";
|
||||||
|
|
||||||
@@ -375,10 +323,10 @@ io.on('connection', function(socket){
|
|||||||
}else if(get_time() - docs[0]["startTime"] < 10 && lists[coll].length == 2 && !error)
|
}else if(get_time() - docs[0]["startTime"] < 10 && lists[coll].length == 2 && !error)
|
||||||
{
|
{
|
||||||
socket.emit("toast", "notyetskip");
|
socket.emit("toast", "notyetskip");
|
||||||
}else if(!contains(docs[0]["skips"], guid) && get_time() - docs[0]["startTime"] >= 30){
|
}else if(!contains(docs[0]["skips"], guid)){
|
||||||
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
||||||
socket.emit("toast", (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1) + " more are needed to skip!");
|
socket.emit("toast", (Math.ceil(lists[coll].length/2) - docs[0]["skips"].length-1) + " more are needed to skip!");
|
||||||
io.sockets.emit('chat,'+coll, rndName(guid) + " tried to skip!");
|
socket.broadcast.emit('chat,'+coll, rndName(guid) + " voted to skip");
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
socket.emit("toast", "alreadyskip");
|
socket.emit("toast", "alreadyskip");
|
||||||
@@ -394,16 +342,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(params !== undefined && params !== null && params != "")
|
if(params !== undefined && params !== null && params != "")
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
var voting = params[0];
|
var voting = params[0];
|
||||||
var addsongs = params[1];
|
var addsongs = params[1];
|
||||||
@@ -453,16 +392,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(pass !== undefined && pass !== null && pass != "")
|
if(pass !== undefined && pass !== null && pass != "")
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
var hash = hash_pass(pass);
|
var hash = hash_pass(pass);
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
@@ -498,29 +428,21 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(in_list)
|
if(in_list)
|
||||||
{
|
{
|
||||||
try
|
if(contains(lists[coll], guid))
|
||||||
{
|
{
|
||||||
console.log(guid + " left list " + coll);
|
console.log(guid + " left list " + coll);
|
||||||
var index = lists[coll].indexOf(guid);
|
var index = lists[coll].indexOf(guid);
|
||||||
lists[coll].splice(index, 1);
|
lists[coll].splice(index, 1);
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
}catch(err){}
|
io.sockets.emit('chat,'+coll, rndName(guid) + " left");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('pos', function()
|
socket.on('pos', function()
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
check_inlist(coll, guid, socket);
|
||||||
{
|
|
||||||
lists[coll] = [];
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}else if(!contains(lists[coll], guid))
|
|
||||||
{
|
|
||||||
lists[coll].push(guid);
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
|
||||||
}
|
|
||||||
|
|
||||||
send_play(coll, socket);
|
send_play(coll, socket);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -536,7 +458,23 @@ function del(params, socket)
|
|||||||
sort_list(coll, undefined, false, true);
|
sort_list(coll, undefined, false, true);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_inlist(coll, guid, socket)
|
||||||
|
{
|
||||||
|
if(lists[coll] == undefined)
|
||||||
|
{
|
||||||
|
lists[coll] = [];
|
||||||
|
lists[coll].push(guid);
|
||||||
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
|
socket.broadcast.emit('chat,'+coll, rndName(guid) + " joined");
|
||||||
|
}else if(!contains(lists[coll], guid))
|
||||||
|
{
|
||||||
|
lists[coll].push(guid);
|
||||||
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
|
socket.broadcast.emit('chat,'+coll, rndName(guid) + " joined");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hash_pass(adminpass)
|
function hash_pass(adminpass)
|
||||||
@@ -681,4 +619,4 @@ function rndName(seed) {
|
|||||||
word += arr[(seed[i%seed.length].charCodeAt()+i) % arr.length-1];
|
word += arr[(seed[i%seed.length].charCodeAt()+i) % arr.length-1];
|
||||||
}
|
}
|
||||||
return word.substring(0,8)
|
return word.substring(0,8)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,6 +208,11 @@ hide mdi-action-visibility mdi-action-visibility-off
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chat-btn i {
|
||||||
|
-webkit-transition:opacity 1s;
|
||||||
|
transition:opacity 1s;
|
||||||
|
}
|
||||||
|
|
||||||
ul #chat-log{
|
ul #chat-log{
|
||||||
padding: 0px 0px 0px 11px !important;
|
padding: 0px 0px 0px 11px !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
var blink_interval;
|
||||||
|
var blink_interval_exists = false;
|
||||||
|
|
||||||
function chat(data)
|
function chat(data)
|
||||||
{
|
{
|
||||||
@@ -11,14 +13,24 @@ function chat(data)
|
|||||||
document.getElementById("chat-btn").addEventListener("click", function(){
|
document.getElementById("chat-btn").addEventListener("click", function(){
|
||||||
console.log("clicked");
|
console.log("clicked");
|
||||||
$("#text-chat-input").focus();
|
$("#text-chat-input").focus();
|
||||||
$("#chat-btn").css("color", "white");
|
//$("#chat-btn").css("color", "white");
|
||||||
|
$("#chat-btn i").css("opacity", 1);
|
||||||
|
clearInterval(blink_interval);
|
||||||
|
blink_interval_exists = false;
|
||||||
|
$("#favicon").attr("href", "static/images/favicon.png");
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("chat,"+chan.toLowerCase(), function(data)
|
socket.on("chat,"+chan.toLowerCase(), function(data)
|
||||||
{
|
{
|
||||||
if($("#chat-bar").position()["left"] != 0)
|
if($("#chat-bar").position()["left"] != 0)
|
||||||
{
|
{
|
||||||
$("#chat-btn").css("color", "grey");
|
//$("#chat-btn").css("color", "grey");
|
||||||
|
if(!blink_interval_exists)
|
||||||
|
{
|
||||||
|
$("#favicon").attr("href", "static/images/highlogo.png");
|
||||||
|
blink_interval_exists = true;
|
||||||
|
blink_interval = setInterval(chat_blink, 2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
|
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
|
||||||
$("#chat").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span></li>");
|
$("#chat").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span></li>");
|
||||||
@@ -27,6 +39,12 @@ socket.on("chat,"+chan.toLowerCase(), function(data)
|
|||||||
document.getElementById("chat").scrollTop = document.getElementById("chat").scrollHeight
|
document.getElementById("chat").scrollTop = document.getElementById("chat").scrollHeight
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function chat_blink()
|
||||||
|
{
|
||||||
|
$("#chat-btn i").css("opacity", 0.5);
|
||||||
|
setTimeout(function(){$("#chat-btn i").css("opacity", 1);}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
function hashCode(str) { // java String#hashCode
|
function hashCode(str) { // java String#hashCode
|
||||||
var hash = 0;
|
var hash = 0;
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
|||||||
@@ -198,12 +198,13 @@ function search(search_input){
|
|||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
var song = pre_result;
|
var song = pre_result;
|
||||||
|
|
||||||
song.find(".search-title").text(title);
|
song.find(".search-title").text(title);
|
||||||
song.find(".result_info").text(duration);
|
song.find(".result_info").text(duration);
|
||||||
song.find(".thumb").attr("src", thumb);
|
song.find(".thumb").attr("src", thumb);
|
||||||
song.find(".add-many").attr("onclick", "submit('"+id+"','"+enc_title+"',"+secs+");");
|
song.find(".add-many").attr("onclick", "submit('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
song.attr("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
$($(song).find("div")[0]).attr("onclick", "submitAndClose('"+id+"','"+enc_title+"',"+secs+");");
|
||||||
song.attr("id",id);
|
$($(song).find("div")[0]).attr("id", id)
|
||||||
|
|
||||||
output += song.html();
|
output += song.html();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user