mirror of
				https://github.com/KevinMidboe/zoff.git
				synced 2025-10-29 18:00:23 +00:00 
			
		
		
		
	Fixes for suggested-showing of soundcloud objects
This commit is contained in:
		| @@ -416,7 +416,7 @@ function add_function(arr, coll, guid, offline, socket) { | ||||
|                         } else { | ||||
|                             db.collection(coll).find({id: id}, function(err, docs) { | ||||
|                                 if(docs.length === 0) { | ||||
|                                     db.collection(coll).update({id: id}, {$set:{ | ||||
|                                     var suggestedAdd = { | ||||
|                                         "added":Functions.get_time(), | ||||
|                                         "guids": [guid], | ||||
|                                         "id":id, | ||||
| @@ -426,11 +426,21 @@ function add_function(arr, coll, guid, offline, socket) { | ||||
|                                         "duration":duration, | ||||
|                                         "start": start, | ||||
|                                         "end": end, | ||||
|                                         "type":"suggested"} | ||||
|                                     }, | ||||
|                                         "type":"suggested" | ||||
|                                     }; | ||||
|                                     var source = arr.source; | ||||
|                                     if(source == "soundcloud") { | ||||
|                                         suggestedAdd.thumbnail = arr.thumbnail; | ||||
|                                         suggestedAdd.source = source; | ||||
|                                     } else { | ||||
|                                         suggestedAdd.source = "youtube"; | ||||
|                                     } | ||||
|                                     db.collection(coll).update({id: id}, {$set: suggestedAdd}, | ||||
|                                     {upsert:true}, function(err, docs){ | ||||
|                                         socket.emit("toast", "suggested"); | ||||
|                                         io.to(coll).emit("suggested", {id: id, title: title, duration: duration}); | ||||
|                                         var toSend = {id: id, title: title, duration: duration, source: suggestedAdd.source}; | ||||
|                                         if(source == "soundcloud") toSend.thumbnail = arr.thumbnail; | ||||
|                                         io.to(coll).emit("suggested", toSend); | ||||
|                                     }); | ||||
|                                 } else if(docs[0].now_playing === true){ | ||||
|                                     socket.emit("toast", "alreadyplay"); | ||||
|   | ||||
| @@ -633,7 +633,7 @@ var List = { | ||||
|                                     success: function(resp) { | ||||
|                                     }, | ||||
|                                     error: function(error) { | ||||
|                                         console.log(error); | ||||
|                                         console.error(error); | ||||
|                                     } | ||||
|                                 }); | ||||
|                             } | ||||
| @@ -645,7 +645,7 @@ var List = { | ||||
|                     } | ||||
|                 }); | ||||
|             }, error: function(e) { | ||||
|                 console.log(e); | ||||
|                 console.error(e); | ||||
|             } | ||||
|         }) | ||||
|     }, | ||||
| @@ -822,7 +822,7 @@ var List = { | ||||
|                 List.addToYoutubePlaylist(playlist_id, full_playlist, number_added, request_url) | ||||
|             }, | ||||
|             error: function(response){ | ||||
|                 console.log(response); | ||||
|                 console.error(response); | ||||
|                 response = response.responseText; | ||||
|                 Helper.log([ | ||||
|                     "export to youtube response", | ||||
| @@ -868,14 +868,13 @@ var List = { | ||||
|                     //}, 50); | ||||
|                 } | ||||
|             }, error: function(response) { | ||||
|                 console.log(response); | ||||
|                 console.error(response); | ||||
|             } | ||||
|  | ||||
|         }); | ||||
|     }, | ||||
|  | ||||
|     addToYoutubePlaylist: function(playlist_id, full_playlist, num, request_url) { | ||||
|         console.log(full_playlist[num], num); | ||||
|         if(num == full_playlist.length - 1){ | ||||
|             Helper.log(["All videoes added!"]); | ||||
|             Helper.log(["url: https://www.youtube.com/playlist?list=" + playlist_id]); | ||||
| @@ -1007,13 +1006,13 @@ var List = { | ||||
|                                 } | ||||
|                             }, | ||||
|                             error: function(e) { | ||||
|                                 console.log(e); | ||||
|                                 console.error(e); | ||||
|                             } | ||||
|                         }); | ||||
|  | ||||
|                     } | ||||
|                 }, error: function(e) { | ||||
|                     console.log(e); | ||||
|                     console.error(e); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
|   | ||||
| @@ -30,8 +30,16 @@ var Suggestions = { | ||||
|         var duration 	= Helper.secondsToOther(params.duration); | ||||
|         var video_id 	= params.id; | ||||
|         var video_title = params.title; | ||||
|         var song 		= List.generateSong({id: video_id, title: video_title, length: params.duration, duration: duration}, false, false, false, true); | ||||
|         if(document.querySelectorAll("#" + video_id).length == 0) { | ||||
|         var toSend = {id: video_id, title: video_title, length: params.duration, duration: duration}; | ||||
|         if(params.source) toSend.source = params.source; | ||||
|         if(params.thumbnail) toSend.thumbnail = params.thumbnail; | ||||
|         var song 		= List.generateSong(toSend, false, false, false, true); | ||||
|         var testingElem; | ||||
|         try { | ||||
|             testingElem = document.getElementById(video_id); | ||||
|         } catch(e) {} | ||||
|  | ||||
|         if(!testingElem && document.querySelectorAll("#suggested-" + video_id).length == 0) { | ||||
|             document.getElementById("user-suggest-html").insertAdjacentHTML("beforeend", song); | ||||
|         } | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user