| 
					
				 | 
			
			
				@@ -182,7 +182,7 @@ Template.admin.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Session.set("playlistToEdit", id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     "click #croom_create": function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), $("#croom_private").prop("checked"), function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), $("#croom_private").prop("checked"), $("#croom_desc").val(), function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 alert("Error " + err.error + ": " + err.reason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -906,10 +906,767 @@ Template.register.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/*Template.room.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+Template.news.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #createArticleButton": function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var title = $("#title").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var content = $("#content").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var anonymous = $("#anonymous").is(":checked"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("createArticle", {title: title, content: content, anonymous: anonymous}, function(err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var $toastContent = $('<span><strong>Article not created.</strong> ' + err.reason + '</span>'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Materialize.toast($toastContent, 8000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $('#createArticle').closeModal() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#title").val("").change(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#content").val("").change(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#anonymous").prop("checked", false).change(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-});*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+Template.room.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #youtube-playlist-button": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!Session.get("importingPlaylist")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var playlist_link = $("#youtube-playlist-input").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var playlist_id = gup("list", playlist_link); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var ytImportQueue = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var totalVideos = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var videosInvalid = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var videosInQueue = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var videosInPlaylist = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var ranOnce = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Session.set("importingPlaylist", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#youtube-playlist-button").attr("disabled", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#youtube-playlist-button").addClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#youtube-playlist-input").attr("disabled", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#youtube-playlist-input").addClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#playlist-import-queue").empty(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#playlist-import-queue").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#add-youtube-playlist").addClass("hidden-2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#import-progress").attr("aria-valuenow", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#import-progress").css({width: "0%"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#import-progress").text("0%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            function makeAPICall(playlist_id, nextPageToken) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (nextPageToken !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    nextPageToken = "&pageToken=" + nextPageToken; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    nextPageToken = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $.ajax({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    type: "GET", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    url: "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=" + playlist_id + nextPageToken + "&key=AIzaSyAgBdacEWrHCHVPPM4k-AFM7uXg-Q__YXY", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    applicationType: "application/json", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    contentType: "json", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    success: function (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (!ranOnce) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            ranOnce = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            totalVideos = data.pageInfo.totalResults; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        var nextToken = data.nextPageToken; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        for (var i in data.items) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            var item = data.items[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (item.snippet.thumbnails !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                var genre = Session.get("type"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (Playlists.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        type: genre, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "songs.id": item.snippet.resourceId.videoId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }, {songs: {$elemMatch: {id: item.snippet.resourceId.videoId}}}).count() !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    videosInPlaylist++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } else if (Queues.find({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        type: genre, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "songs.id": item.snippet.resourceId.videoId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }, {songs: {$elemMatch: {id: item.snippet.resourceId.videoId}}}).count() !== 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    videosInQueue++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#playlist-import-queue").append( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<div class='youtube-import-queue-item'>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<img src='" + item.snippet.thumbnails.medium.url + "' class='song-result-thumbnail'/>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<div>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<span class='song-result-title'>" + item.snippet.title + "</span>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<span class='song-result-channel'>" + item.snippet.channelTitle + "</span>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "</div>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "<i class='fa fa-times remove-import-song'></i>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        "</div>" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    var percentage = ytImportQueue.length / (totalVideos - videosInvalid) * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#import-progress").attr("aria-valuenow", percentage.toFixed(2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#import-progress").css({width: percentage + "%"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#import-progress").text(percentage.toFixed(1) + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    ytImportQueue.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        title: item.snippet.title, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        id: item.snippet.resourceId.videoId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                videosInvalid++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (nextToken !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            makeAPICall(playlist_id, nextToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#playlist-import-queue > div > i").click(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                var title = $(this).parent().find("div > .song-result-title").text(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                for (var i in ytImportQueue) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if (ytImportQueue[i].title === title) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        ytImportQueue.splice(i, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                $(this).parent().remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Session.set("YTImportQueue", ytImportQueue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Session.set("importingPlaylist", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#import-progress").attr("aria-valuenow", 100); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#import-progress").css({width: "100%"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#import-progress").text("100%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#youtube-playlist-button").removeAttr("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#youtube-playlist-button").removeClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#youtube-playlist-input").removeAttr("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#youtube-playlist-input").removeClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#playlist-import-queue").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#add-youtube-playlist").removeClass("hidden-2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Session.set("YTImportQueue", ytImportQueue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            makeAPICall(playlist_id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #add-youtube-playlist": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var YTImportQueue = Session.get("YTImportQueue"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#youtube-playlist-button").attr("disabled", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#youtube-playlist-button").addClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#youtube-playlist-input").attr("disabled", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#youtube-playlist-input").addClass("disabled"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#import-progress").attr("aria-valuenow", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#import-progress").css({width: "0%"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#import-progress").text("0%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var failed = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var success = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var processed = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var total = YTImportQueue.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        YTImportQueue.forEach(function (song) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var songData = {type: "YouTube", id: song.id, title: song.title, artist: "", img: ""}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Meteor.call("addSongToQueue", songData, function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    console.log(err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    failed++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    success++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                processed++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var percentage = processed / total * 100; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#import-progress").attr("aria-valuenow", percentage.toFixed(2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#import-progress").css({width: percentage + "%"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#import-progress").text(percentage.toFixed(1) + "%"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #chat-tab": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#chat-tab").removeClass("unread-messages"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #global-chat-tab": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#global-chat-tab").removeClass("unread-messages"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #sync": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (Session.get("currentSong") !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var room = Rooms.findOne({type: Session.get("type")}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (room !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var timeIn = Date.now() - Session.get("currentSong").started - room.timePaused; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var skipDuration = Number(Session.get("currentSong").skipDuration) | 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (YTPlayer !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    YTPlayer.seekTo(skipDuration + timeIn / 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #lock": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("lockRoom", Session.get("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #unlock": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("unlockRoom", Session.get("type")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #chat-tab": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #global-chat-tab": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#global-chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #submit": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sendMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 1000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #global-submit": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sendMessageGlobal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#global-chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 1000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "keyup #chat-input": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (e.type === "keyup" && e.which === 13) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.preventDefault(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!$('#chat-input').data('dropdownshown')) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sendMessage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, 1000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "keyup #global-chat-input": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (e.type === "keyup" && e.which === 13) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.preventDefault(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!$('#global-chat-input').data('dropdownshown')) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sendMessageGlobal(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Meteor.setTimeout(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#global-chat-ul").scrollTop(100000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }, 1000) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #like": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#like").blur(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("likeSong", Session.get("currentSong").mid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #dislike": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#dislike").blur(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("dislikeSong", Session.get("currentSong").mid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #vote-skip": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("voteSkip", type, function (err, res) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#vote-skip").attr("disabled", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #report-prev": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (Session.get("previousSong") !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Session.set("reportPrevious", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#report-prev").prop("disabled", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#report-curr").prop("disabled", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #report-curr": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Session.set("reportPrevious", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#report-prev").prop("disabled", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#report-curr").prop("disabled", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #report-modal": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#media-container").removeClass("hidden"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#toggle-video").text("Hide video"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Session.set("mediaHidden", false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#media-container").addClass("hidden"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#toggle-video").text("Show video"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Session.set("mediaHidden", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #return": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#add-info").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#search-info").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #search-song": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var songs = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#song-results").empty(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $.ajax({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            type: "GET", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            url: "https://www.googleapis.com/youtube/v3/search?part=snippet&q=" + $("#song-input").val() + "&key=AIzaSyAgBdacEWrHCHVPPM4k-AFM7uXg-Q__YXY", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            applicationType: "application/json", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            contentType: "json", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            success: function (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for (var i in data.items) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    var item = data.items[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#song-results").append( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "<div>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "<img src='" + item.snippet.thumbnails.medium.url + "' class='song-result-thumbnail'/>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "<div>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "<span class='song-result-title'>" + item.snippet.title + "</span>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "<span class='song-result-channel'>" + item.snippet.channelTitle + "</span>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "</div>" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        "</div>" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    songs.push({title: item.snippet.title, id: item.id.videoId}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $("#song-results > div").click(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#search-info").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $("#add-info").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    var title = $(this).find("div > .song-result-title").text(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (var i in songs) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (songs[i].title === title) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            var songObj = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                id: songs[i].id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                title: songs[i].title, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                type: "youtube" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#title").val(songObj.title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#artist").val(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            $("#id").val(songObj.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            getSpotifyInfo(songObj.title.replace(/\[.*\]/g, ""), function (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                if (data.tracks.items.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#title").val(data.tracks.items[0].name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    var artists = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#img").val(data.tracks.items[0].album.images[2].url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    data.tracks.items[0].artists.forEach(function (artist) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        artists.push(artist.name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    $("#artist").val(artists.join(", ")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #volume-icon": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var volume = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var slider = $("#volume-slider").slider(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#volume-icon").removeClass("fa-volume-down").addClass("fa-volume-off") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (YTPlayer !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            YTPlayer.setVolume(volume); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            localStorage.setItem("volume", volume); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#volume-slider").slider("setValue", volume); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #play": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("resumeRoom", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #pause": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("pauseRoom", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #skip": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("skipSong", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #shuffle": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("shufflePlaylist", type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "change input": function (e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (e.target && e.target.id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var partsOfId = e.target.id.split("-"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            partsOfId[1] = partsOfId[1].charAt(0).toUpperCase() + partsOfId[1].slice(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var camelCase = partsOfId.join(""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Session.set(camelCase, e.target.checked); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #report-song-button": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var room = Session.get("type"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        var reportData = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        reportData.song = Session.get("currentSong").mid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        reportData.type = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        reportData.reason = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $(".report-layer-1 > .checkbox input:checked").each(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            reportData.type.push(this.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (this.id == "report-other") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                var otherText = $(".other-textarea").val(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $(".report-layer-2 input:checked").each(function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            reportData.reason.push(this.id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(reportData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Meteor.call("submitReport", room, reportData, Session.get("id"), function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#close-modal-r").click(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "change #si_or_pl": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($("#select_playlist").is(':selected')) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#search-info").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#playlist-import").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($("#select_single").is(':selected')) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#search-info").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $("#playlist-import").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    "click #close-modal-a": function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#select_single").attr("selected", true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#search-info").show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $("#playlist-import").hide(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -948,4 +1705,4 @@ Template.settings.events({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-var previewEndSongTimeout = undefined; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+var previewEndSongTimeout = undefined; 
			 |