mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Server now deletes songs when they're not valid
This commit is contained in:
@@ -22,6 +22,7 @@ var server;
|
|||||||
console.log("Starting without https (probably on localhost)");
|
console.log("Starting without https (probably on localhost)");
|
||||||
//if(err["errno"] != 34)console.log(err);
|
//if(err["errno"] != 34)console.log(err);
|
||||||
var cors_proxy = require('cors-anywhere');
|
var cors_proxy = require('cors-anywhere');
|
||||||
|
var request = require('request');
|
||||||
|
|
||||||
cors_proxy.createServer({
|
cors_proxy.createServer({
|
||||||
requireHeader: ['origin', 'x-requested-with'],
|
requireHeader: ['origin', 'x-requested-with'],
|
||||||
@@ -396,7 +397,7 @@ io.on('connection', function(socket){
|
|||||||
|| (lists[coll].length == 2 && docs[0]["skips"].length+1 == 2 && !contains(docs[0]["skips"], guid))
|
|| (lists[coll].length == 2 && docs[0]["skips"].length+1 == 2 && !contains(docs[0]["skips"], guid))
|
||||||
|| (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "" && docs[0]["skip"]))
|
|| (docs[0]["adminpass"] == hash && docs[0]["adminpass"] != "" && docs[0]["skip"]))
|
||||||
{
|
{
|
||||||
change_song(coll);
|
change_song(coll, error);
|
||||||
socket.emit("toast", "skip");
|
socket.emit("toast", "skip");
|
||||||
io.to(coll).emit('chat', [name, " skipped"]);
|
io.to(coll).emit('chat', [name, " skipped"]);
|
||||||
}else if(!contains(docs[0]["skips"], guid)){
|
}else if(!contains(docs[0]["skips"], guid)){
|
||||||
@@ -625,27 +626,48 @@ function vote(coll, id, guid, socket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function change_song(coll, id, np_id)
|
function change_song(coll, error)
|
||||||
{
|
{
|
||||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||||
var startTime = docs[0]["startTime"];
|
var startTime = docs[0]["startTime"];
|
||||||
if(docs !== null && docs.length != 0)
|
if(docs !== null && docs.length != 0)
|
||||||
{
|
{
|
||||||
if(docs[0]["removeplay"] == true)
|
db.collection(coll).find({now_playing:true}, function(err, now_playing_doc){
|
||||||
{
|
if(error){
|
||||||
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
request('http://img.youtube.com/vi/'+docs[0].id+'/mqdefault.jpg', function (err, response, body) {
|
||||||
change_song_post(coll);
|
if (err || response.statusCode == 404) {
|
||||||
});
|
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
||||||
}else{
|
change_song_post(coll);
|
||||||
db.collection(coll).update({now_playing:true},
|
io.to(coll).emit("channel", ["deleted", now_playing_doc[0].id]);
|
||||||
{$set:{
|
});
|
||||||
now_playing:false,
|
}else{
|
||||||
votes:0,
|
db.collection(coll).update({now_playing:true},
|
||||||
guids:[]
|
{$set:{
|
||||||
}},{multi:true}, function(err, docs){
|
now_playing:false,
|
||||||
change_song_post(coll);
|
votes:0,
|
||||||
});
|
guids:[]
|
||||||
}
|
}},{multi:true}, function(err, docs){
|
||||||
|
change_song_post(coll);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}else if(docs[0]["removeplay"] == true){
|
||||||
|
db.collection(coll).remove({now_playing:true}, function(err, docs){
|
||||||
|
change_song_post(coll);
|
||||||
|
io.to(coll).emit("channel", ["deleted", now_playing_doc[0].id]);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
db.collection(coll).update({now_playing:true},
|
||||||
|
{$set:{
|
||||||
|
now_playing:false,
|
||||||
|
votes:0,
|
||||||
|
guids:[]
|
||||||
|
}},{multi:true}, function(err, docs){
|
||||||
|
change_song_post(coll);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
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
@@ -68,18 +68,26 @@ var List = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
deleted_song: function(deleted){
|
deleted_song: function(deleted){
|
||||||
|
console.log(deleted);
|
||||||
var index = List.getIndexOfSong(deleted);
|
var index = List.getIndexOfSong(deleted);
|
||||||
var to_delete = $("#wrapper").children()[index];
|
var to_delete = $("#wrapper").children()[index];
|
||||||
to_delete.style.height = 0;
|
try{
|
||||||
|
to_delete.style.height = 0;
|
||||||
|
|
||||||
setTimeout(function()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
$("#"+deleted).remove();
|
$("#"+deleted).remove();
|
||||||
|
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
||||||
|
}, 305);
|
||||||
|
|
||||||
|
document.getElementById('wrapper').scrollTop += 1;
|
||||||
|
document.getElementById('wrapper').scrollTop += -1;
|
||||||
|
}catch(err){
|
||||||
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
full_playlist.splice(List.getIndexOfSong(deleted), 1);
|
||||||
}, 305);
|
console.log(full_playlist.length-1);
|
||||||
|
console.log("here");
|
||||||
document.getElementById('wrapper').scrollTop += 1;
|
$("#wrapper").children()[$("#wrapper").children().length-1].remove();
|
||||||
document.getElementById('wrapper').scrollTop += -1;
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
voted_song: function(voted, time){
|
voted_song: function(voted, time){
|
||||||
@@ -96,7 +104,9 @@ var List = {
|
|||||||
|
|
||||||
song_change: function(time){
|
song_change: function(time){
|
||||||
var length = full_playlist.length-1;
|
var length = full_playlist.length-1;
|
||||||
|
console.log(full_playlist[0]);
|
||||||
|
console.log(full_playlist[full_playlist.length-1]);
|
||||||
|
console.log(full_playlist);
|
||||||
full_playlist[0].now_playing = true;
|
full_playlist[0].now_playing = true;
|
||||||
full_playlist[0].votes = 0;
|
full_playlist[0].votes = 0;
|
||||||
full_playlist[0].guids = [];
|
full_playlist[0].guids = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user