mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Merge branch 'dev' of github.com:nixolas1/Zoff into dev
This commit is contained in:
@@ -47,7 +47,7 @@ if(isset($_GET['chan'])){
|
||||
Zöff is mainly a webbased service, but an <a href="https://play.google.com/store/apps/details?id=no.lqasse.zoff&hl=en">Android app</a> is made by Lasse Drevland, which has been a huge asset for the dev. team.<br><br>
|
||||
The website uses <a href="https://nodejs.org/">NodeJS</a> with <a href="http://socket.io/">Socket.IO</a>, <a href="https://www.mongodb.org/">MongoDB</a> and PHP on the backend, with JavaScript, jQuery and <a href="http://materializecss.com/">Materialize</a> on the frontend. More about the project itself can be found on <a href="https://github.com/nixolas1/Zoff">GitHub</a><br><br>
|
||||
The team consists of Kasper Rynning-Tønnesen and Nicolas Almagro Tonne, and the project has been worked on since late 2014.<br><br>
|
||||
The team can be reached on either <a href="mailto:kasper@kasperrt.no?Subject=Contact%20Zoff">kasper@kasperrt.no</a> or <a href="mailto:me@nixo.no?Subject=Contact%20Zoff">me@nixo.no</a>
|
||||
The team can be reached on <a href="mailto:contact@zoff.no?Subject=Contact%20Zoff">contact@zoff.no</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
124
server/server.js
124
server/server.js
@@ -82,7 +82,12 @@ io.on('connection', function(socket){
|
||||
{
|
||||
lists[coll] = [];
|
||||
lists[coll].push(guid);
|
||||
}else 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);
|
||||
|
||||
@@ -107,6 +112,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('end', function(id)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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){
|
||||
//console.log(docs);
|
||||
//console.log(docs.length);
|
||||
@@ -167,6 +183,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('add', function(arr)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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 title = arr[1];
|
||||
var hash = hash_pass(arr[2]);
|
||||
@@ -200,6 +227,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('vote', function(msg)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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")
|
||||
del(msg, socket);
|
||||
else
|
||||
@@ -221,6 +259,16 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('password', function(pw)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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({views:{$exists:true}}, function(err, docs){
|
||||
if(docs[0]["adminpass"] == "" || docs[0]["adminpass"] == hash_pass(pw))
|
||||
@@ -236,6 +284,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('skip', function(list)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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({skip: false}, function(err, docs){
|
||||
if(docs.length == 1)
|
||||
{
|
||||
@@ -256,6 +315,17 @@ io.on('connection', function(socket){
|
||||
|
||||
socket.on('conf', function(params)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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 addsongs = params[1];
|
||||
var longsongs = params[2];
|
||||
@@ -299,7 +369,19 @@ io.on('connection', function(socket){
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('shuffle', function(pass){
|
||||
socket.on('shuffle', function(pass)
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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);
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
if((docs[0]["adminpass"] == hash || docs[0]["adminpass"] == "") || docs[0]["shuffle"] == false)
|
||||
@@ -335,15 +417,26 @@ io.on('connection', function(socket){
|
||||
{
|
||||
try
|
||||
{
|
||||
var index = lists[coll].indexOf(guid);
|
||||
lists[coll].splice(index, 1);
|
||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||
var index = lists[coll].indexOf(guid);
|
||||
lists[coll].splice(index, 1);
|
||||
io.sockets.emit(coll+",viewers", lists[coll].length);
|
||||
}catch(err){}
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('pos', function()
|
||||
{
|
||||
if(lists[coll] == undefined)
|
||||
{
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -370,7 +463,7 @@ function hash_pass(adminpass)
|
||||
function vote(coll, id, guid, socket)
|
||||
{
|
||||
db.collection(coll).find({id:id}, function(err, docs){
|
||||
if(!contains(docs[0]["guids"], guid))
|
||||
if(docs.length > 0 && !contains(docs[0]["guids"], guid))
|
||||
{
|
||||
db.collection(coll).update({id:id}, {$inc:{votes:1}, $set:{added:get_time()}}, function(err, docs)
|
||||
{
|
||||
@@ -401,33 +494,16 @@ function change_song(coll, id, np_id)
|
||||
})
|
||||
}else
|
||||
{
|
||||
if(id === undefined){
|
||||
//console.log("undef");
|
||||
db.collection(coll).update({now_playing:true},
|
||||
{$set:{
|
||||
now_playing:false,
|
||||
votes:0,
|
||||
guids:[]
|
||||
}}, function(err, docs)
|
||||
}},{multi:true}, function(err, docs)
|
||||
{
|
||||
change_song_post(coll);
|
||||
});
|
||||
}else{
|
||||
db.collection(coll).find({id:id}, function(err, docs){
|
||||
if(startTime+docs[0]["duration"]<=get_time()-1)
|
||||
{
|
||||
db.collection(coll).update({now_playing:true, id:id},
|
||||
{$set:{
|
||||
now_playing:false,
|
||||
votes:0,
|
||||
guids:[]
|
||||
}}, function(err, docs)
|
||||
{
|
||||
change_song_post(coll);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user