mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Nicer effect on chat icon
This commit is contained in:
123
server/server.js
123
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 = "";
|
||||||
|
|
||||||
@@ -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){
|
||||||
@@ -500,6 +430,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
io.sockets.emit('chat,'+coll, rndName(guid) + " left");
|
||||||
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);
|
||||||
@@ -510,17 +441,7 @@ io.on('connection', function(socket){
|
|||||||
|
|
||||||
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 +457,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 +618,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 {
|
||||||
|
-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,4 @@
|
|||||||
|
var blink_interval;
|
||||||
|
|
||||||
function chat(data)
|
function chat(data)
|
||||||
{
|
{
|
||||||
@@ -11,14 +12,17 @@ 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").css("opacity", 1);
|
||||||
|
clearInterval(blink_interval);
|
||||||
});
|
});
|
||||||
|
|
||||||
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");
|
||||||
|
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 +31,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").css("opacity", 0.5);
|
||||||
|
setTimeout(function(){$("#chat-btn").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++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user