mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Sending conf as own message instead of with the list
This commit is contained in:
@@ -167,13 +167,13 @@ io.on('connection', function(socket){
|
|||||||
|
|
||||||
if(contains(docs, coll))
|
if(contains(docs, coll))
|
||||||
{
|
{
|
||||||
send_list(coll, socket, true, false);
|
send_list(coll, socket, true, false, true);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
db.createCollection(coll, function(err, docs){
|
db.createCollection(coll, function(err, docs){
|
||||||
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":false, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false}, function(err, docs)
|
db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":false, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false}, function(err, docs)
|
||||||
{
|
{
|
||||||
send_list(coll, socket, true, false);
|
send_list(coll, socket, true, false, true);
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -464,7 +464,7 @@ io.on('connection', function(socket){
|
|||||||
{
|
{
|
||||||
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){
|
||||||
send_list(coll, undefined, false, true);
|
send_list(coll, undefined, false, true, false);
|
||||||
socket.emit("toast", "shuffled");
|
socket.emit("toast", "shuffled");
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
@@ -479,7 +479,7 @@ io.on('connection', function(socket){
|
|||||||
var complete = function(tot, curr){
|
var complete = function(tot, curr){
|
||||||
if(tot == curr)
|
if(tot == curr)
|
||||||
{
|
{
|
||||||
send_list(coll, undefined, false, true);
|
send_list(coll, undefined, false, true, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}else
|
}else
|
||||||
@@ -654,9 +654,9 @@ function change_song_post(coll)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_list(coll, socket, send, list_send)
|
function send_list(coll, socket, send, list_send, configs)
|
||||||
{
|
{
|
||||||
db.collection(coll).find(function(err, docs)
|
db.collection(coll).find({views:{$exists:false}}, function(err, docs)
|
||||||
{
|
{
|
||||||
if(list_send)
|
if(list_send)
|
||||||
io.to(coll).emit("channel", ["list", docs]);
|
io.to(coll).emit("channel", ["list", docs]);
|
||||||
@@ -667,6 +667,14 @@ function send_list(coll, socket, send, list_send)
|
|||||||
else if(send)
|
else if(send)
|
||||||
send_play(coll, socket);
|
send_play(coll, socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(configs)
|
||||||
|
{
|
||||||
|
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||||
|
io.to(coll).emit("conf", conf);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_play(coll, socket)
|
function send_play(coll, socket)
|
||||||
|
|||||||
4
static/dist/main-min.js
vendored
4
static/dist/main-min.js
vendored
File diff suppressed because one or more lines are too long
@@ -12,14 +12,10 @@ var List = {
|
|||||||
if(msg[0] == "list")
|
if(msg[0] == "list")
|
||||||
{
|
{
|
||||||
full_playlist = msg[1];
|
full_playlist = msg[1];
|
||||||
var index_of_conf = List.getIndexOfConf(full_playlist);
|
|
||||||
conf = full_playlist[index_of_conf];
|
|
||||||
full_playlist.splice(index_of_conf, 1);
|
|
||||||
full_playlist.sort(Helper.predicate({
|
full_playlist.sort(Helper.predicate({
|
||||||
name: 'votes',
|
name: 'votes',
|
||||||
reverse: true
|
reverse: true
|
||||||
}, 'added'));
|
}, 'added'));
|
||||||
Admin.set_conf(conf);
|
|
||||||
List.populate_list(full_playlist);
|
List.populate_list(full_playlist);
|
||||||
}else if(msg[0] == "added")
|
}else if(msg[0] == "added")
|
||||||
{
|
{
|
||||||
@@ -217,15 +213,5 @@ var List = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return indexes[0];
|
return indexes[0];
|
||||||
},
|
|
||||||
|
|
||||||
getIndexOfConf: function(flist)
|
|
||||||
{
|
|
||||||
indexes = $.map(flist, function(obj, index) {
|
|
||||||
if("views" in obj) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return indexes[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user