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:
@@ -56,6 +56,7 @@
|
|||||||
<script type="text/javascript" src="static/js/lib/jquery-ui-1.10.3.min.js"></script>-->
|
<script type="text/javascript" src="static/js/lib/jquery-ui-1.10.3.min.js"></script>-->
|
||||||
<script src="//cdn.socket.io/socket.io-1.2.0.js"></script>
|
<script src="//cdn.socket.io/socket.io-1.2.0.js"></script>
|
||||||
<script type="text/javascript" src="static/js/lib/iscroll-min.js"></script>
|
<script type="text/javascript" src="static/js/lib/iscroll-min.js"></script>
|
||||||
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var socket = io.connect('http://'+window.location.hostname+':3000');
|
var socket = io.connect('http://'+window.location.hostname+':3000');
|
||||||
var guid = "<?php echo $guid; ?>";
|
var guid = "<?php echo $guid; ?>";
|
||||||
|
|||||||
@@ -35,18 +35,29 @@ io.on('connection', function(socket){
|
|||||||
//var guid;
|
//var guid;
|
||||||
var tot_lists = [];
|
var tot_lists = [];
|
||||||
var in_list = false;
|
var in_list = false;
|
||||||
|
var name = rndName(guid);
|
||||||
|
|
||||||
|
socket.on('namechange', function(data)
|
||||||
|
{
|
||||||
|
if(name.length < 9 && name.indexOf(" ") == -1)
|
||||||
|
{
|
||||||
|
io.sockets.emit('chat,'+coll, name + ": changed name to " + data);
|
||||||
|
io.sockets.emit('chat.all', [name + ": changed name to " + data, coll]);
|
||||||
|
name = data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('chat', function (data) {
|
socket.on('chat', function (data) {
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
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, name + ": " + data);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("all,chat", function(data)
|
socket.on("all,chat", function(data)
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
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.all', rndName(guid) + ": " + data);
|
io.sockets.emit('chat.all', [name + ": " + data, coll]);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('frontpage_lists', function()
|
socket.on('frontpage_lists', function()
|
||||||
@@ -101,9 +112,9 @@ io.on('connection', function(socket){
|
|||||||
coll = list[0].toLowerCase();
|
coll = list[0].toLowerCase();
|
||||||
//guid = list[1];
|
//guid = list[1];
|
||||||
|
|
||||||
console.log(guid + " joined list " + coll);
|
console.log(name + " joined list " + coll);
|
||||||
|
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
|
|
||||||
@@ -133,7 +144,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(id !== undefined && id !== null && id != "")
|
if(id !== undefined && id !== null && id != "")
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
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);
|
||||||
@@ -198,7 +209,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(arr !== undefined && arr !== null && arr != "")
|
if(arr !== undefined && arr !== null && arr != "")
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
var id = arr[0];
|
var id = arr[0];
|
||||||
var title = arr[1];
|
var title = arr[1];
|
||||||
@@ -239,7 +250,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(msg !== undefined && msg !== null)
|
if(msg !== undefined && msg !== null)
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
if(msg[2] == "del")
|
if(msg[2] == "del")
|
||||||
del(msg, socket);
|
del(msg, socket);
|
||||||
@@ -269,7 +280,7 @@ io.on('connection', function(socket){
|
|||||||
pw = inp[0];
|
pw = inp[0];
|
||||||
coll = inp[1];
|
coll = inp[1];
|
||||||
//guid = inp[2];
|
//guid = inp[2];
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
//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){
|
||||||
@@ -294,7 +305,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(list !== undefined && list !== null && list != "")
|
if(list !== undefined && list !== null && list != "")
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
adminpass = "";
|
adminpass = "";
|
||||||
|
|
||||||
@@ -326,14 +337,14 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
change_song(coll);
|
change_song(coll);
|
||||||
socket.emit("toast", "skip");
|
socket.emit("toast", "skip");
|
||||||
io.sockets.emit('chat,'+coll, rndName(guid) + " skipped");
|
io.sockets.emit('chat,'+coll, name + " skipped");
|
||||||
}/*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)){
|
}*/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!");
|
||||||
socket.broadcast.emit('chat,'+coll, rndName(guid) + " voted to skip");
|
socket.broadcast.emit('chat,'+coll, name + " voted to skip");
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
socket.emit("toast", "alreadyskip");
|
socket.emit("toast", "alreadyskip");
|
||||||
@@ -349,7 +360,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(params !== undefined && params !== null && params != "")
|
if(params !== undefined && params !== null && params != "")
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket,name);
|
||||||
|
|
||||||
var voting = params[0];
|
var voting = params[0];
|
||||||
var addsongs = params[1];
|
var addsongs = params[1];
|
||||||
@@ -399,7 +410,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(pass !== undefined && pass !== null && pass != "")
|
if(pass !== undefined && pass !== null && pass != "")
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
|
|
||||||
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){
|
||||||
@@ -428,7 +439,8 @@ io.on('connection', function(socket){
|
|||||||
sort_list(coll, undefined, false, true);
|
sort_list(coll, undefined, false, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}else
|
||||||
|
socket.emit("toast", "wrongpass");
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', function()
|
socket.on('disconnect', function()
|
||||||
@@ -437,11 +449,11 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
if(contains(lists[coll], guid))
|
if(contains(lists[coll], guid))
|
||||||
{
|
{
|
||||||
console.log(guid + " left list " + coll);
|
console.log(name + " 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);
|
||||||
io.sockets.emit('chat,'+coll, rndName(guid) + " left");
|
io.sockets.emit('chat,'+coll, name + " left");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -449,7 +461,7 @@ io.on('connection', function(socket){
|
|||||||
|
|
||||||
socket.on('pos', function()
|
socket.on('pos', function()
|
||||||
{
|
{
|
||||||
check_inlist(coll, guid, socket);
|
check_inlist(coll, guid, socket, name);
|
||||||
send_play(coll, socket);
|
send_play(coll, socket);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -468,19 +480,19 @@ function del(params, socket)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_inlist(coll, guid, socket)
|
function check_inlist(coll, guid, socket, name)
|
||||||
{
|
{
|
||||||
if(lists[coll] == undefined)
|
if(lists[coll] == undefined)
|
||||||
{
|
{
|
||||||
lists[coll] = [];
|
lists[coll] = [];
|
||||||
lists[coll].push(guid);
|
lists[coll].push(guid);
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
socket.broadcast.emit('chat,'+coll, rndName(guid) + " joined");
|
socket.broadcast.emit('chat,'+coll, name + " joined");
|
||||||
}else if(!contains(lists[coll], guid))
|
}else if(!contains(lists[coll], guid))
|
||||||
{
|
{
|
||||||
lists[coll].push(guid);
|
lists[coll].push(guid);
|
||||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||||
socket.broadcast.emit('chat,'+coll, rndName(guid) + " joined");
|
socket.broadcast.emit('chat,'+coll, name + " joined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ socket.on("toast", function(msg)
|
|||||||
break;
|
break;
|
||||||
case "wrongpass":
|
case "wrongpass":
|
||||||
msg=rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."])
|
msg=rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."])
|
||||||
break;
|
if(localStorage[chan.toLowerCase()]){
|
||||||
|
localStorage.removeItem(chan.toLowerCase());
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "shuffled":
|
case "shuffled":
|
||||||
msg=rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"])
|
msg=rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"])
|
||||||
break;
|
break;
|
||||||
@@ -75,12 +78,13 @@ $('input[class=conf]').change(function()
|
|||||||
|
|
||||||
function pass_save()
|
function pass_save()
|
||||||
{
|
{
|
||||||
socket.emit('password', [document.getElementById("password").value, chan.toLowerCase(), guid]);
|
|
||||||
|
socket.emit('password', [CryptoJS.SHA256(document.getElementById("password").value).toString(), chan.toLowerCase(), guid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log_out(){
|
function log_out(){
|
||||||
if(localStorage[chan.toLowerCase()]){
|
if(localStorage[chan.toLowerCase()]){
|
||||||
localStorage.removeItem(chan.toLowerCase())
|
localStorage.removeItem(chan.toLowerCase());
|
||||||
w_p = true;
|
w_p = true;
|
||||||
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
|
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
|
||||||
for (var i = 0; i < names.length; i++) {
|
for (var i = 0; i < names.length; i++) {
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ $(".chat-tab").click(function(){
|
|||||||
$("#text-chat-input").focus();
|
$("#text-chat-input").focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("chat.all", function(data)
|
socket.on("chat.all", function(inp)
|
||||||
{
|
{
|
||||||
|
data = inp[0];
|
||||||
|
|
||||||
if($("#chat-bar").position()["left"] != 0)
|
if($("#chat-bar").position()["left"] != 0)
|
||||||
{
|
{
|
||||||
//$("#chat-btn").css("color", "grey");
|
//$("#chat-btn").css("color", "grey");
|
||||||
@@ -46,9 +48,9 @@ socket.on("chat.all", function(data)
|
|||||||
$("#favicon").attr("href", "static/images/highlogo.png");
|
$("#favicon").attr("href", "static/images/highlogo.png");
|
||||||
unseen = true;
|
unseen = true;
|
||||||
}
|
}
|
||||||
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
|
var color = intToARGB(hashCode(data.substring(0,data.indexOf(": ")))).substring(0,6);
|
||||||
$("#chatall").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span></li>");
|
$("#chatall").append("<li title='"+inp[1]+"'><span style='color:"+color+";'>"+data.substring(0,data.indexOf(": "))+"</span></li>");
|
||||||
var in_text = document.createTextNode(data.substring(8));
|
var in_text = document.createTextNode(data.substring(data.indexOf(": ")));
|
||||||
$("#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
|
||||||
});
|
});
|
||||||
@@ -73,9 +75,9 @@ socket.on("chat,"+chan.toLowerCase(), function(data)
|
|||||||
blink_interval = setInterval(chat_blink, 2000);
|
blink_interval = setInterval(chat_blink, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
|
var color = intToARGB(hashCode(data.substring(0,data.indexOf(": ")))).substring(0,6);
|
||||||
$("#chatchannel").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span></li>");
|
$("#chatchannel").append("<li><span style='color:"+color+";'>"+data.substring(0,data.indexOf(": "))+"</span></li>");
|
||||||
var in_text = document.createTextNode(data.substring(8));
|
var in_text = document.createTextNode(data.substring(data.indexOf(": ")));
|
||||||
$("#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
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ socket.on(chan.toLowerCase()+",viewers", function(view)
|
|||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
|
Materialize.toast("Passwords have been reset. If anything is not right, please send us a mail @ contact@zoff.no", 10000);
|
||||||
$("#settings").sideNav({
|
$("#settings").sideNav({
|
||||||
menuWidth: 300, // Default is 240
|
menuWidth: 300, // Default is 240
|
||||||
edge: 'right', // Choose the horizontal origin
|
edge: 'right', // Choose the horizontal origin
|
||||||
@@ -104,7 +104,8 @@ $(document).ready(function()
|
|||||||
|
|
||||||
if(localStorage[chan.toLowerCase()])
|
if(localStorage[chan.toLowerCase()])
|
||||||
{
|
{
|
||||||
socket.emit("password", [localStorage[chan.toLowerCase()], chan.toLowerCase(), guid]);
|
localStorage.removeItem(chan.toLowerCase());
|
||||||
|
//socket.emit("password", [localStorage[chan.toLowerCase()], chan.toLowerCase(), guid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($("#chan").html().toLowerCase() == "jazz")
|
if($("#chan").html().toLowerCase() == "jazz")
|
||||||
|
|||||||
Reference in New Issue
Block a user