| 
					
				 | 
			
			
				@@ -1166,47 +1166,6 @@ Template.room.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Session.set("currentSongR", Session.get("currentSong")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Session.set("previousSongR", Session.get("previousSong")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    "click #add-song-button": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        e.preventDefault(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        parts = location.href.split('/'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var roomType = parts.pop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var genre = roomType.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var type = $("#type").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        id = $("#id").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var title = $("#title").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var artist = $("#artist").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var img = $("#img").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var songData = {type: type, id: id, title: title, artist: artist, img: img}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Playlists.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                type: genre, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "songs.id": songData.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, {songs: {$elemMatch: {id: songData.id}}}).count() !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $("<div class='alert alert-danger alert-dismissible' role='alert' style='margin-bottom: 0'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'><i class='fa fa-times'></i></span></button><strong>Song not added.</strong> This song is already in the playlist.</div>").prependTo($(".landing")).delay(7000).fadeOut(1000, function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $(this).remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else if (Queues.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                type: genre, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                "songs.id": songData.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, {songs: {$elemMatch: {id: songData.id}}}).count() !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $("<div class='alert alert-danger alert-dismissible' role='alert' style='margin-bottom: 0'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'><i class='fa fa-times'></i></span></button><strong>Song not added.</strong> This song has already been requested.</div>").prependTo($(".landing")).delay(7000).fadeOut(1000, function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $(this).remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Meteor.call("addSongToQueue", songData, function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                console.log(err, res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    $("<div class='alert alert-danger alert-dismissible' role='alert' style='margin-bottom: 0'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'><i class='fa fa-times'></i></span></button><strong>Song not added.</strong> Something went wrong.</div>").prependTo($(".landing")).delay(7000).fadeOut(1000, function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $(this).remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    $("<div class='alert alert-success alert-dismissible' role='alert' style='margin-bottom: 0'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'><i class='fa fa-times'></i></span></button><strong>Song added.</strong> Your song has been added to the queue.</div>").prependTo($(".landing")).delay(7000).fadeOut(1000, function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        $(this).remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $("#close-modal-a").click(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "click #toggle-video": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         e.preventDefault(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (Session.get("mediaHidden")) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1346,330 +1305,6 @@ Template.room.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-Template.room.helpers({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    singleVideo: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    chat: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Meteor.setTimeout(function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var elem = document.getElementById('chat'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (elem !== undefined && elem !== null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                elem.scrollTop = elem.scrollHeight; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Chat.find({type: Session.get("type")}, {sort: {time: -1}, limit: 50 }).fetch().reverse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    globalChat: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Meteor.setTimeout(function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var elem = document.getElementById('global-chat'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (elem !== undefined && elem !== null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                elem.scrollTop = elem.scrollHeight; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Chat.find({type: "global"}, {sort: {time: -1}, limit: 50 }).fetch().reverse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    likes: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var playlist = Playlists.findOne({type: Session.get("type")}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var likes = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        playlist.songs.forEach(function(song) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (Session.get("currentSong") && song.mid === Session.get("currentSong").mid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                likes = song.likes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return likes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    dislikes: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var playlist = Playlists.findOne({type: Session.get("type")}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var dislikes = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        playlist.songs.forEach(function(song) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (Session.get("currentSong") && song.mid === Session.get("currentSong").mid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                dislikes = song.dislikes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return dislikes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    liked: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Meteor.userId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var currentSong = Session.get("currentSong"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (currentSong && Meteor.user().profile.liked.indexOf(currentSong.mid) !== -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return "active"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    disliked: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Meteor.userId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var currentSong = Session.get("currentSong"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (currentSong && Meteor.user().profile.disliked.indexOf(currentSong.mid) !== -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return "active"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    type: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var parts = location.href.split('/'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var id = parts.pop().toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Rooms.findOne({type: id}).display; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    users: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var parts = location.href.split('/'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var id = parts.pop().toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Rooms.findOne({type: id}).users; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    title: function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("title"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    artist: function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("artist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    loaded: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("loaded"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    paused: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("state") === "paused"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Rooms.findOne({type: Session.get("type")}).private === true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    report: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportObj"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportSong: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportSong"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportTitle: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportTitle"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportAuthor: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportAuthor"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportDuration: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportDuration"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportAudio: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportAudio"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportAlbumart: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportAlbumart"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportOther: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("reportOther"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    currentSong: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("currentSong"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    previousSong: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("previousSong"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    currentSongR: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("currentSongR"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    previousSongR: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Session.get("previousSongR"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    reportingSong: function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Session.get("reportPrevious")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return Session.get("previousSongR"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return Session.get("currentSongR"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    votes: function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return Rooms.findOne({type: Session.get("type")}).votes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-Template.room.onCreated(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Chat.after.find(function(userId, selector) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (selector.type === "global") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!$("#global-chat-tab").hasClass("active")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $("#global-chat-tab").addClass("unread-messages"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else if(selector.type === Session.get("type")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!$("#chat-tab").hasClass("active")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $("#chat-tab").addClass("unread-messages"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportSong", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportTitle", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportAuthor", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportDuration", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportAudio", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportAlbumart", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("reportOther", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    /*if (resizeSeekerbarInterval !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Meteor.clearInterval(resizeSeekerbarInterval); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        resizeSeekerbarInterval = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    YTPlayer = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("videoHidden", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    var tag = document.createElement("script"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tag.src = "https://www.youtube.com/iframe_api"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    var firstScriptTag = document.getElementsByTagName('script')[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("singleVideo", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    var currentSong = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    var currentSongR = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function getTimeElapsed() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (currentSong !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var room = Rooms.findOne({type: type}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (room !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return Date.now() - currentSong.started - room.timePaused; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function getSongInfo(songData){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("title", songData.title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("artist", songData.artist); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("id", songData.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $("#song-img").attr("src", songData.img); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("duration", parseInt(songData.duration)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var d = moment.duration(parseInt(songData.duration), 'seconds'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $("#time-total").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("timeFormat", d.minutes() + ":" + ("0" + d.seconds()).slice(-2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function resizeSeekerbar() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Session.get("state") === "playing") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $("#seeker-bar").width(((getTimeElapsed() / 1000) / Session.get("duration") * 100) + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    function startSong() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $("#time-elapsed").text("0:00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $("#vote-skip").attr("disabled", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (currentSong !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (YTPlayer !== undefined && YTPlayer.stopVideo !== undefined) YTPlayer.stopVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            var volume = localStorage.getItem("volume") || 20; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ($("#player").length !== 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $("#media-container").append('<div id="player" class="embed-responsive-item"></div>'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $("#player").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            function loadVideo() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!Session.get("YTLoaded")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Session.set("loadVideoTimeout", Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        loadVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    }, 500)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (YTPlayer === undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        YTPlayer = new YT.Player("player", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            height: 540, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            width: 960, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            videoId: currentSong.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            events: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                'onReady': function (event) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    if (currentSong.skipDuration === undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        currentSong.skipDuration = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    event.target.playVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    event.target.setVolume(volume); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    resizeSeekerbar(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                'onStateChange': function (event) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    if (Session.get("YTLoaded")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        if (event.data == YT.PlayerState.PAUSED && Session.get("state") === "playing") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            event.target.playVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        if (event.data == YT.PlayerState.PLAYING && Session.get("state") === "paused") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            event.target.pauseVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        YTPlayer.loadVideoById(currentSong.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (currentSong.skipDuration === undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            currentSong.skipDuration = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        YTPlayer.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Session.set("pauseVideo", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    getSongInfo(currentSong); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            loadVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Session.set("loaded", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Meteor.subscribe("rooms", function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var parts = location.href.split('/'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var id = parts.pop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        var type = id.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Session.set("type", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (Rooms.find({type: type}).count() !== 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            window.location = "/"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            StationSubscription = Meteor.subscribe(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Session.set("loaded", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            minterval = Meteor.setInterval(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                var room = Rooms.findOne({type: type}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (room !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (room.state === "paused" || Session.get("pauseVideo")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        Session.set("state", "paused"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        // TODO Fix issue where sometimes nothing loads with the YT is not defined error. The error points to around this. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            YTPlayer.pauseVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        Session.set("state", "playing"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (YTPlayer !== undefined && YTPlayer.getPlayerState !== undefined && YTPlayer.getPlayerState() !== 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            YTPlayer.playVideo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (room.currentSong.song !== undefined && (currentSongR === undefined || room.currentSong.started !== currentSongR.started)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Session.set("previousSong", currentSong); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    currentSongR = room.currentSong; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    currentSong = room.currentSong.song; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    currentSong.started = room.currentSong.started; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Session.set("currentSong", currentSong); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Meteor.clearTimeout(Session.get("loadVideoTimeout")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    startSong(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (currentSong !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (room !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        var duration = (Date.now() - currentSong.started - room.timePaused) / 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        var song_duration = currentSong.duration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if (song_duration <= duration) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                Session.set("pauseVideo", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        var d = moment.duration(duration, 'seconds'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (Session.get("state") === "playing") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            $("#time-elapsed").text(d.minutes() + ":" + ("0" + d.seconds()).slice(-2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            resizeSeekerbarInterval = Meteor.setInterval(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                resizeSeekerbar(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }, 500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Settings Template 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 Template.settings.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "click #save-settings": function() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1708,4 +1343,4 @@ Template.settings.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-var previewEndSongTimeout = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var previewEndSongTimeout = undefined; 
			 |