mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	maybe?
This commit is contained in:
		| @@ -89,7 +89,7 @@ io.on('connection', function(socket){ | ||||
|     	}else | ||||
|     	{ | ||||
|     		db.createCollection(coll, function(err, docs){ | ||||
|   				db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":true, "removeplay": false, "shuffle": false, "skip": true, "skips": [], "startTime":get_time(), "views": [], "vote": false}, function(err, docs) | ||||
|   				db.collection(coll).insert({"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":true, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":get_time(), "views": [], "vote": false}, function(err, docs) | ||||
|   				{ | ||||
|             db.collection(coll).find().sort({votes:-1}, function(err, docs) { | ||||
|     		    	socket.emit(coll, docs); | ||||
| @@ -101,11 +101,62 @@ io.on('connection', function(socket){ | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   socket.on('end', function(arg) | ||||
|   socket.on('end', function(id) | ||||
|   { | ||||
|   	db.collection(coll).find({now_playing:true}, function(err, docs){ | ||||
|   		if(docs.length > 0 && docs[0]["id"] == arg){ | ||||
|   			change_song(coll, arg, docs[0]["id"]); | ||||
|       console.log(docs); | ||||
|       console.log(docs.length); | ||||
|   		if(docs.length == 1 && docs[0]["id"] == id){ | ||||
|         db.collection(coll).find({views:{$exists:true}}, function(err, docs){ | ||||
|           var startTime = docs[0]["startTime"]; | ||||
|           if(docs[0]["removeplay"] == true) | ||||
|           { | ||||
|             db.collection(coll).remove({now_playing: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) | ||||
|                     { | ||||
|                       console.log(err); | ||||
|                       console.log(docs["n"]); | ||||
|                       if(docs["n"] == 1) | ||||
|                       { | ||||
|                         db.collection(coll).aggregate([ | ||||
|                           {$match:{now_playing:false}}, | ||||
|                           {$sort:{votes:-1, added:1}}, | ||||
|                           {$limit:1}], function(err, docs){ | ||||
|                             if(docs.length > 0){ | ||||
|                               db.collection(coll).update({id:docs[0]["id"]}, | ||||
|                               {$set:{ | ||||
|                                 now_playing:true, | ||||
|                                 votes:0, | ||||
|                                 guids:[], | ||||
|                                 added:get_time()}}, function(err, docs){ | ||||
|                                   db.collection(coll).update({views:{$exists:true}}, | ||||
|                                     {$set:{startTime:get_time(), skips:[]}}, function(err, docs){ | ||||
|                                       sort_list(coll, undefined, true); | ||||
|                                   }); | ||||
|                                 }); | ||||
|                             } | ||||
|                       }); | ||||
|                       } | ||||
|  | ||||
|                   }); | ||||
|  | ||||
|                 } | ||||
|               }); | ||||
|           } | ||||
|         }); | ||||
|   		} | ||||
|   	}) | ||||
|   }); | ||||
| @@ -346,8 +397,6 @@ function change_song(coll, id, np_id) | ||||
|             guids:[] | ||||
|           }}, function(err, docs) | ||||
|           { | ||||
|               console.log(err); | ||||
|               console.log(docs); | ||||
|               change_song_post(coll); | ||||
|         }); | ||||
|       }else{ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user