2
0
Эх сурвалжийг харах

removed unnecessary function

unknown 9 жил өмнө
parent
commit
7ff3e75fa2

+ 1 - 0
app/.meteor/packages

@@ -27,3 +27,4 @@ joncursi:socket-io-client
 meteorhacks:async
 meteorhacks:async
 altapp:recaptcha
 altapp:recaptcha
 http
 http
+zimme:iron-router-active

+ 3 - 0
app/.meteor/versions

@@ -17,6 +17,7 @@ caching-compiler@1.0.0
 caching-html-compiler@1.0.2
 caching-html-compiler@1.0.2
 callback-hook@1.0.4
 callback-hook@1.0.4
 check@1.0.6
 check@1.0.6
+coffeescript@1.0.10
 ddp@1.2.2
 ddp@1.2.2
 ddp-client@1.2.1
 ddp-client@1.2.1
 ddp-common@1.2.1
 ddp-common@1.2.1
@@ -92,3 +93,5 @@ underscore@1.0.4
 url@1.0.5
 url@1.0.5
 webapp@1.2.2
 webapp@1.2.2
 webapp-hashing@1.0.5
 webapp-hashing@1.0.5
+zimme:active-route@2.0.4_1
+zimme:iron-router-active@2.0.1

+ 51 - 14
app/app.css

@@ -354,20 +354,6 @@ footer a:hover{
 .button:hover {
 .button:hover {
   background-color: #f5f7f9;
   background-color: #f5f7f9;
 }
 }
-
-.logout{
-  position: fixed;
-  top: 2px;
-  left: 2px;
-  background-color: white;
-  padding: 12px;
-  cursor: pointer;
-  border-radius: 100%;
-  z-index: 2;
-  width: 38px;
-  height: 38px;
-  text-align: center;
-}
 .station{
 .station{
   background-color: rgba(102,205,170,0.7);
   background-color: rgba(102,205,170,0.7);
   height: 300px;
   height: 300px;
@@ -446,6 +432,25 @@ footer a:hover{
           transition-duration: 0.25s;
           transition-duration: 0.25s;
   font-weight: 300;
   font-weight: 300;
 }
 }
+#chat-input {
+  -webkit-appearance: none;
+  -moz-appearance: none;
+  appearance: none;
+  outline: 0;
+  border: 1px solid rgba(83, 227, 166, 0.4);
+  background-color: rgba(83, 227, 166, 0.2);
+  width: 100%;
+  border-radius: 3px;
+  padding: 10px 15px;
+  margin: 1em auto 10px auto;
+  display: block;
+  text-align: left;
+  font-size: 18px;
+  color: #53e3a6;
+  -webkit-transition-duration: 0.25s;
+  transition-duration: 0.25s;
+  font-weight: 300;
+}
 .song-input-select{
 .song-input-select{
   -webkit-appearance: none;
   -webkit-appearance: none;
      -moz-appearance: none;
      -moz-appearance: none;
@@ -628,3 +633,35 @@ footer a:hover{
 .column-small {
 .column-small {
   width: 1px;
   width: 1px;
 }
 }
+#return {
+  display: block;
+  margin: 0 auto 20px auto;
+}
+#chat {
+  margin-top: 100px;
+}
+#chat-container {
+  padding: 0;
+}
+.chat-message {
+  font-size: 20px;
+  color: #53e3a6;
+}
+#chat-ul {
+  max-height: 500px;
+  overflow-y: scroll;
+  border: 1px solid rgba(83, 227, 166, 0.4);
+}
+#submit-message {
+  background-color: #53e3a6;
+  color: white;
+}
+.chat-message:nth-child(even) {
+  background-color: white;
+}
+.chat-message:nth-child(odd) {
+  background-color: #F2F2F2;
+}
+#header {
+  margin-bottom: 0px;
+}

+ 191 - 183
app/app.js

@@ -2,6 +2,7 @@ History = new Mongo.Collection("history");
 Playlists = new Mongo.Collection("playlists");
 Playlists = new Mongo.Collection("playlists");
 Rooms = new Mongo.Collection("rooms");
 Rooms = new Mongo.Collection("rooms");
 Queues = new Mongo.Collection("queues");
 Queues = new Mongo.Collection("queues");
+Chat = new Mongo.Collection("chat");
 
 
 if (Meteor.isClient) {
 if (Meteor.isClient) {
     Meteor.startup(function() {
     Meteor.startup(function() {
@@ -52,6 +53,35 @@ if (Meteor.isClient) {
         return artist;
         return artist;
     }
     }
 
 
+    curPath=function(){var c=window.location.pathname;var b=c.slice(0,-1);var a=c.slice(-1);if(b==""){return"/"}else{if(a=="/"){return b}else{return c}}};
+
+    Handlebars.registerHelper('active', function(path) {
+        return curPath() == path ? 'active' : '';
+    });
+
+    Template.header.helpers({
+        currentUser: function() {
+            return Meteor.user();
+        },
+        isAdmin: function() {
+            if (Meteor.user() && Meteor.user().profile) {
+                return Meteor.user().profile.rank === "admin";
+            } else {
+                return false;
+            }
+        }
+    });
+
+    Template.header.events({
+        "click .logout": function(e){
+            e.preventDefault();
+            Meteor.logout();
+            if (hpSound !== undefined) {
+                hpSound.stop();
+            }
+        }
+    });
+
     Template.register.events({
     Template.register.events({
         "submit form": function(e){
         "submit form": function(e){
             e.preventDefault();
             e.preventDefault();
@@ -117,14 +147,6 @@ if (Meteor.isClient) {
     });
     });
 
 
     Template.dashboard.events({
     Template.dashboard.events({
-        "click .logout": function(e){
-            e.preventDefault();
-            Meteor.logout();
-            if (hpSound !== undefined) {
-                hpSound.stop();
-            }
-        },
-
         "click #croom_create": function() {
         "click #croom_create": function() {
             Meteor.call("createRoom", $("#croom").val(), function (err, res) {
             Meteor.call("createRoom", $("#croom").val(), function (err, res) {
                 if (err) {
                 if (err) {
@@ -152,54 +174,94 @@ if (Meteor.isClient) {
             id = $("#id").val();
             id = $("#id").val();
             var title = $("#title").val();
             var title = $("#title").val();
             var artist = $("#artist").val();
             var artist = $("#artist").val();
-            var songData = {type: type, id: id, title: title, artist: artist};
-            console.log(songData);
+            var img = $("#img").val();
+            var songData = {type: type, id: id, title: title, artist: artist, img: img};
             Meteor.call("addSongToQueue", genre, songData, function(err, res) {
             Meteor.call("addSongToQueue", genre, songData, function(err, res) {
                 console.log(err, res);
                 console.log(err, res);
             });
             });
         },
         },
+        "click #return": function(e){
+            $("#add-info").hide();
+            $("#search-info").show();
+        },
         "click #search-song": function(){
         "click #search-song": function(){
-            $("#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){
-                    console.log(data);
-                    for(var i in data.items){
-                        $("#song-results").append("<p>" + data.items[i].snippet.title + "</p>");
-                        ytArr.push({title: data.items[i].snippet.title, id: data.items[i].id.videoId});
+            $("#song-results").empty();
+            var search_type = $("#search_type").val();
+            if (search_type === "YouTube") {
+                $.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){
+                            $("#song-results").append("<p>" + data.items[i].snippet.title + "</p>");
+                            ytArr.push({title: data.items[i].snippet.title, id: data.items[i].id.videoId});
+                        }
+                        $("#song-results p").click(function(){
+                            $("#search-info").hide();
+                            $("#add-info").show();
+                            var title = $(this).text();
+                            for(var i in ytArr){
+                                if(ytArr[i].title === title){
+                                    var songObj = {
+                                        id: ytArr[i].id,
+                                        title: ytArr[i].title,
+                                        type: "youtube"
+                                    };
+                                    $("#title").val(songObj.title);
+                                    $("#artist").val("");
+                                    $("#id").val(songObj.id);
+                                    $("#type").val("YouTube");
+                                    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[1].url);
+
+                                            data.tracks.items[0].artists.forEach(function(artist) {
+                                                artists.push(artist.name);
+                                            });
+
+                                            $("#artist").val(artists.join(", "));
+                                        }
+                                    });
+                                }
+                            }
+                        })
+                    }
+                })
+            } else if (search_type === "SoundCloud") {
+                SC.get('/tracks', { q: $("#song-input").val()}, function(tracks) {
+                    for(var i in tracks){
+                        $("#song-results").append("<p>" + tracks[i].title + "</p>")
+                        songsArr.push({title: tracks[i].title, id: tracks[i].id, duration: tracks[i].duration / 1000});
                     }
                     }
-                    console.log(ytArr);
                     $("#song-results p").click(function(){
                     $("#song-results p").click(function(){
                         $("#search-info").hide();
                         $("#search-info").hide();
                         $("#add-info").show();
                         $("#add-info").show();
                         var title = $(this).text();
                         var title = $(this).text();
-                        for(var i in ytArr){
-                            if(ytArr[i].title === title){
+                        for(var i in songsArr){
+                            if(songsArr[i].title === title){
+                                var id = songsArr[i].id;
+                                var duration = songsArr[i].duration;
                                 var songObj = {
                                 var songObj = {
-                                    id: ytArr[i].id,
-                                    title: ytArr[i].title,
-                                    type: "youtube"
-                                };
-                                console.log(ytArr[i].title);
-                                console.log(ytArr[i].id);
-                                // Set title field
+                                    title: songsArr[i].title,
+                                    id: id,
+                                    duration: duration,
+                                    type: "soundcloud"
+                                }
                                 $("#title").val(songObj.title);
                                 $("#title").val(songObj.title);
                                 // Set ID field
                                 // Set ID field
                                 $("#id").val(songObj.id);
                                 $("#id").val(songObj.id);
+                                $("#type").val("SoundCloud");
                                 getSpotifyInfo(songObj.title.replace(/\[.*\]/g, ""), function(data) {
                                 getSpotifyInfo(songObj.title.replace(/\[.*\]/g, ""), function(data) {
-                                    console.log(data);
                                     if (data.tracks.items.length > 0) {
                                     if (data.tracks.items.length > 0) {
                                         $("#title").val(data.tracks.items[0].name);
                                         $("#title").val(data.tracks.items[0].name);
                                         var artists = [];
                                         var artists = [];
                                         data.tracks.items[0].artists.forEach(function(artist) {
                                         data.tracks.items[0].artists.forEach(function(artist) {
                                             artists.push(artist.name);
                                             artists.push(artist.name);
                                         });
                                         });
-
-                                        console.log(artists);
-                                        console.log(artists.join(", "));
                                         $("#artist").val(artists.join(", "));
                                         $("#artist").val(artists.join(", "));
                                     }
                                     }
                                     // Set title field again if possible
                                     // Set title field again if possible
@@ -208,31 +270,8 @@ if (Meteor.isClient) {
                             }
                             }
                         }
                         }
                     })
                     })
-                }
-            })
-            // SC.get('/tracks', { q: $("#song-input").val()}, function(tracks) {
-            //   console.log(tracks);
-            //   for(var i in tracks){
-            //     $("#song-results").append("<p>" + tracks[i].title + "</p>")
-            //     songsArr.push({title: tracks[i].title, id: tracks[i].id, duration: tracks[i].duration / 1000});
-            //   }
-            //   $("#song-results p").click(function(){
-            //     var title = $(this).text();
-            //     for(var i in songsArr){
-            //       if(songsArr[i].title === title){
-            //         var id = songsArr[i].id;
-            //         var duration = songsArr[i].duration;
-            //         var songObj = {
-            //           title: songsArr[i].title,
-            //           id: id,
-            //           duration: duration,
-            //           type: "soundcloud"
-            //         }
-            //       }
-            //     }
-            //     console.log(id);
-            //   })
-            // });
+                });
+            }
         },
         },
         "click #add-songs": function(){
         "click #add-songs": function(){
           $("#add-songs-modal").show();
           $("#add-songs-modal").show();
@@ -240,6 +279,10 @@ if (Meteor.isClient) {
         "click #close-modal": function(){
         "click #close-modal": function(){
           $("#search-info").show();
           $("#search-info").show();
           $("#add-info").hide();
           $("#add-info").hide();
+        },
+        "click #submit-message": function(){
+            var message = $("#chat-input").val();
+            Meteor.call("sendMessage", type, message);
         }
         }
     });
     });
 
 
@@ -269,6 +312,14 @@ if (Meteor.isClient) {
         },
         },
         loaded: function() {
         loaded: function() {
           return Session.get("loaded");
           return Session.get("loaded");
+        },
+        chat: function() {
+            var chatArr = Chat.find({type: type}).fetch();
+            if (chatArr.length === 0) {
+                return [];
+            } else {
+                return chatArr[0].messages;
+            }
         }
         }
     });
     });
 
 
@@ -279,6 +330,7 @@ if (Meteor.isClient) {
     });
     });
 
 
     var yt_player = undefined;
     var yt_player = undefined;
+    var _sound = undefined;
 
 
     Template.admin.events({
     Template.admin.events({
         "click .preview-button": function(e){
         "click .preview-button": function(e){
@@ -299,11 +351,8 @@ if (Meteor.isClient) {
             var id = song.id;
             var id = song.id;
             var type = song.type;
             var type = song.type;
 
 
-            console.log(this);
-            console.log(id, type);
             if (type === "YouTube") {
             if (type === "YouTube") {
                 if (yt_player === undefined) {
                 if (yt_player === undefined) {
-                    console.log("STUFF!");
                     yt_player = new YT.Player("previewPlayer", {
                     yt_player = new YT.Player("previewPlayer", {
                         height: 540,
                         height: 540,
                         width: 568,
                         width: 568,
@@ -311,22 +360,31 @@ if (Meteor.isClient) {
                         playerVars: {autoplay: 1, controls: 0, iv_load_policy: 3},
                         playerVars: {autoplay: 1, controls: 0, iv_load_policy: 3},
                         events: {
                         events: {
                             'onReady': function(event) {
                             'onReady': function(event) {
-                                console.log("WOOH! Does it work?");
                                 event.target.playVideo();
                                 event.target.playVideo();
                             }
                             }
                         }
                         }
                     });
                     });
                 } else {
                 } else {
-                    console.log("YEEE");
                     yt_player.loadVideoById(id);
                     yt_player.loadVideoById(id);
                 }
                 }
                 $("#previewPlayer").show();
                 $("#previewPlayer").show();
+            } else if (type === "SoundCloud") {
+                SC.stream("/tracks/" + song.id, function(sound) {
+                    _sound = sound;
+                    sound._player._volume = 0.3;
+                    sound.play();
+                });
             }
             }
         },
         },
         "click #stop": function() {
         "click #stop": function() {
             $("#play").attr("disabled", false);
             $("#play").attr("disabled", false);
             $("#stop").attr("disabled", true);
             $("#stop").attr("disabled", true);
-            yt_player.stopVideo();
+            if (yt_player !== undefined) {
+                yt_player.stopVideo();
+            }
+            if (_sound !== undefined) {
+                _sound.stop();
+            }
         }
         }
     });
     });
 
 
@@ -347,6 +405,11 @@ if (Meteor.isClient) {
                 yt_player.seekTo(0);
                 yt_player.seekTo(0);
                 yt_player.stopVideo();
                 yt_player.stopVideo();
             }
             }
+            if (_sound !== undefined) {
+                _sound.stop();
+                $("#play").attr("disabled", false);
+                $("#stop").attr("disabled", true);
+            }
         });
         });
     });
     });
 
 
@@ -362,6 +425,7 @@ if (Meteor.isClient) {
     });
     });
 
 
     Meteor.subscribe("rooms");
     Meteor.subscribe("rooms");
+    Meteor.subscribe("chat");
 
 
     Template.room.onCreated(function () {
     Template.room.onCreated(function () {
         var tag = document.createElement("script");
         var tag = document.createElement("script");
@@ -386,81 +450,11 @@ if (Meteor.isClient) {
             return 0;
             return 0;
         }
         }
 
 
-        function getSongInfo(query, artistName, platform){
-            var search = query;
-            var titles = [];
-
-            getSpotifyInfo(query, function(data) {
-                console.log(data);
-                for(var i in data){
-                    for(var j in data[i].items){
-                        if(search.indexOf(data[i].items[j].name) !== -1 && artistName.indexOf(data[i].items[j].artists[0].name) !== -1){
-                            console.log(data[i].items[j].name);
-                            var info = data[i].items[j];
-                            Session.set("title", data[i].items[j].name);
-                            console.log("Info: " + info);
-                            if(platform === "youtube"){
-                                Session.set("duration", data[i].items[j].duration_ms / 1000)
-                                console.log(Session.get("duration"));
-                            }
-                            var artist = getSpotifyArtist(data[i].items[j]);
-                            Session.set("artist", artist);
-                            $("#song-img").attr("src", data[i].items[j].album.images[1].url);
-                            return true;
-                        }
-                    }
-                    //---------------------------------------------------------------//
-
-                }
-            });
-        }
-
-        function getNextSongInfo(query, artistName, platform){
-            var search = query;
-            var titles = [];
-
-            getSpotifyInfo(query, function(data) {
-                console.log(data);
-                for(var i in data){
-                    for(var j in data[i].items){
-                        if(search.indexOf(data[i].items[j].name) !== -1  && artistName.indexOf(data[i].items[j].artists[0].name) !== -1){
-                            console.log(data[i].items[j].name);
-                            var info = data[i].items[j];
-                            Session.set("title_next", data[i].items[j].name);
-                            var artist = getSpotifyArtist(data[i].items[j]);
-                            Session.set("artist_next", artist);
-                            $("#song-img-next").attr("src", data[i].items[j].album.images[1].url);
-                            return true;
-                        }
-                    }
-                    //---------------------------------------------------------------//
-
-                }
-            });
-        }
-
-        function getAfterSongInfo(query, artistName, platform){
-            var search = query;
-            var titles = [];
-
-            getSpotifyInfo(query, function(data) {
-                console.log(data);
-                for(var i in data){
-                    for(var j in data[i].items){
-                        if(search.indexOf(data[i].items[j].name) !== -1 && artistName.indexOf(data[i].items[j].artists[0].name) !== -1){
-                            console.log(data[i].items[j].name);
-                            var info = data[i].items[j];
-                            Session.set("title_after", data[i].items[j].name);
-                            var artist = getSpotifyArtist(data[i].items[j]);
-                            Session.set("artist_after", artist);
-                            $("#song-img-after").attr("src", data[i].items[j].album.images[1].url);
-                            return true;
-                        }
-                    }
-                    //---------------------------------------------------------------//
-
-                }
-            });
+        function getSongInfo(songData){
+            Session.set("title", songData.title);
+            Session.set("artist", songData.artist);
+            $("#song-img").attr("src", songData.img);
+            Session.set("duration", songData.duration);
         }
         }
 
 
         function resizeSeekerbar() {
         function resizeSeekerbar() {
@@ -472,24 +466,22 @@ if (Meteor.isClient) {
                 if (_sound !== undefined) _sound.stop();
                 if (_sound !== undefined) _sound.stop();
                 if (yt_player !== undefined && yt_player.stopVideo !== undefined) yt_player.stopVideo();
                 if (yt_player !== undefined && yt_player.stopVideo !== undefined) yt_player.stopVideo();
 
 
-                if (currentSong.song.type === "soundcloud") {
+                if (currentSong.type === "soundcloud") {
                   $("#player").attr("src", "")
                   $("#player").attr("src", "")
-                  getSongInfo(currentSong.song.title, "soundcloud");
-                  SC.stream("/tracks/" + currentSong.song.id + "#t=20s", function(sound){
-                    console.log(sound);
+                  getSongInfo(currentSong);
+                  SC.stream("/tracks/" + currentSong.id + "#t=20s", function(sound){
                     _sound = sound;
                     _sound = sound;
                     sound._player._volume = 0.3;
                     sound._player._volume = 0.3;
                     sound.play();
                     sound.play();
-                    console.log(getTimeElapsed());
                     var interval = setInterval(function() {
                     var interval = setInterval(function() {
                         if (sound.getState() === "playing") {
                         if (sound.getState() === "playing") {
                             sound.seek(getTimeElapsed());
                             sound.seek(getTimeElapsed());
                             window.clearInterval(interval);
                             window.clearInterval(interval);
                         }
                         }
                     }, 200);
                     }, 200);
-                    // Session.set("title", currentSong.song.title || "Title");
-                    // Session.set("artist", currentSong.song.artist || "Artist");
-                    Session.set("duration", currentSong.song.duration);
+                    // Session.set("title", currentSong.title || "Title");
+                    // Session.set("artist", currentSong.artist || "Artist");
+                    Session.set("duration", currentSong.duration);
                     resizeSeekerbar();
                     resizeSeekerbar();
                   });
                   });
                 } else {
                 } else {
@@ -497,7 +489,7 @@ if (Meteor.isClient) {
                         yt_player = new YT.Player("player", {
                         yt_player = new YT.Player("player", {
                             height: 540,
                             height: 540,
                             width: 960,
                             width: 960,
-                            videoId: currentSong.song.id,
+                            videoId: currentSong.id,
                             events: {
                             events: {
                                 'onReady': function(event) {
                                 'onReady': function(event) {
                                     event.target.seekTo(getTimeElapsed() / 1000);
                                     event.target.seekTo(getTimeElapsed() / 1000);
@@ -513,13 +505,13 @@ if (Meteor.isClient) {
                             }
                             }
                         });
                         });
                     } else {
                     } else {
-                        yt_player.loadVideoById(currentSong.song.id);
+                        yt_player.loadVideoById(currentSong.id);
                     }
                     }
 
 
-                    // Session.set("title", currentSong.song.title || "Title");
-                    // Session.set("artist", currentSong.song.artist || "Artist");
-                    getSongInfo(currentSong.song.title, currentSong.song.artist, "youtube");
-                    //Session.set("duration", currentSong.song.duration);
+                    // Session.set("title", currentSong.title || "Title");
+                    // Session.set("artist", currentSong.artist || "Artist");
+                    getSongInfo(currentSong);
+                    //Session.set("duration", currentSong.duration);
                 }
                 }
             }
             }
         }
         }
@@ -531,7 +523,6 @@ if (Meteor.isClient) {
             var parts = location.href.split('/');
             var parts = location.href.split('/');
             var id = parts.pop();
             var id = parts.pop();
             var type = id.toLowerCase();
             var type = id.toLowerCase();
-            //console.log(Rooms.find({type: type}).fetch().length);
             if (Rooms.find({type: type}).count() !== 1) {
             if (Rooms.find({type: type}).count() !== 1) {
                 window.location = "/";
                 window.location = "/";
             } else {
             } else {
@@ -546,33 +537,37 @@ if (Meteor.isClient) {
                         }
                         }
                     });
                     });
                     if (data !== undefined && data.history.length > size) {
                     if (data !== undefined && data.history.length > size) {
-                        currentSong = data.history[data.history.length - 1];
+                        //currentSong = data.history[data.history.length - 1];
+                        var songArray = Playlists.find({type: type}).fetch()[0].songs;
+                        var historyObj = data.history[data.history.length - 1];
+                        songArray.forEach(function(song) {
+                            if (song.id === historyObj.song.id) {
+                                currentSong = song;
+                            }
+                        });
+                        currentSong.started = historyObj.started;
                         var songs = dataCursorP.fetch()[0].songs;
                         var songs = dataCursorP.fetch()[0].songs;
-                        console.log(currentSong, " 555");
                         songs.forEach(function(song, index) {
                         songs.forEach(function(song, index) {
-                            if (currentSong.song.title === song.title) {
-                                console.log(index);
-                                console.log(song);
+                            if (currentSong.title === song.title) {
                                 if (index + 1 < songs.length) {
                                 if (index + 1 < songs.length) {
-                                    // INDEX+1
                                     nextSong = songs[index + 1];
                                     nextSong = songs[index + 1];
                                 } else {
                                 } else {
-                                    // 0
                                     nextSong = songs[0];
                                     nextSong = songs[0];
                                 }
                                 }
-                                console.log(nextSong, 5555);
-                                getNextSongInfo(nextSong.title, nextSong.artist, nextSong.type);
-                                console.log("nextSongArtist: " + nextSong.artist);
+                                Session.set("title_next", nextSong.title);
+                                Session.set("artist_next", nextSong.artist);
+                                $("#song-img-next").attr("src", nextSong.img);
+
                                 if (index + 2 < songs.length) {
                                 if (index + 2 < songs.length) {
-                                    console.log("OOO 1");
                                     afterSong = songs[index + 2];
                                     afterSong = songs[index + 2];
                                 } else if (songs.length === index + 1 && songs.length > 1 ) {
                                 } else if (songs.length === index + 1 && songs.length > 1 ) {
                                     afterSong = songs[1];
                                     afterSong = songs[1];
                                 } else {
                                 } else {
                                     afterSong = songs[0];
                                     afterSong = songs[0];
                                 }
                                 }
-                                getAfterSongInfo(afterSong.title, afterSong.artist, afterSong.type);
-                                console.log("afterSongArtist: " + afterSong.artist);
+                                Session.set("title_after", afterSong.title);
+                                Session.set("artist_after", afterSong.artist);
+                                $("#song-img-after").attr("src",afterSong.img);
                             }
                             }
                         });
                         });
                         size = data.history.length;
                         size = data.history.length;
@@ -609,7 +604,6 @@ if (Meteor.isServer) {
             for(var j in res.data[i].items){
             for(var j in res.data[i].items){
                 if(search.indexOf(res.data[i].items[j].name) !== -1){
                 if(search.indexOf(res.data[i].items[j].name) !== -1){
                     duration = res.data[i].items[j].duration_ms / 1000;
                     duration = res.data[i].items[j].duration_ms / 1000;
-                    console.log(duration);
                     return duration;
                     return duration;
                 }
                 }
             }
             }
@@ -639,13 +633,13 @@ if (Meteor.isServer) {
     function getSongsByType(type) {
     function getSongsByType(type) {
         if (type === "edm") {
         if (type === "edm") {
             return [
             return [
-                {id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), albumart: getSongAlbumArt("Radioactive - Lindsey Stirling and Pentatonix"), artist: "Lindsey Stirling, Pentatonix", type: "youtube"},
-                {id: "aHjpOzsQ9YI", title: "Crystallize", artist: "Linsdey Stirling", duration: getSongDuration("Crystallize"), albumart: getSongAlbumArt("Crystallize"), type: "youtube"}
+                {id: "aE2GCa-_nyU", title: "Radioactive - Lindsey Stirling and Pentatonix", duration: getSongDuration("Radioactive - Lindsey Stirling and Pentatonix"), artist: "Lindsey Stirling, Pentatonix", type: "youtube", img: "https://i.scdn.co/image/62167a9007cef2e8ef13ab1d93019312b9b03655"},
+                {id: "aHjpOzsQ9YI", title: "Crystallize", artist: "Lindsey Stirling", duration: getSongDuration("Crystallize"), type: "youtube", img: "https://i.scdn.co/image/b0c1ccdd0cd7bcda741ccc1c3e036f4ed2e52312"}
             ];
             ];
         } else if (type === "nightcore") {
         } else if (type === "nightcore") {
-            return [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)"), albumart: getSongAlbumArt("Monster (DotEXE Remix)"), artist: "Meg & Dia", type: "youtube"}];
+            return [{id: "f7RKOP87tt4", title: "Monster (DotEXE Remix)", duration: getSongDuration("Monster (DotEXE Remix)"), artist: "Meg & Dia", type: "youtube", img: "https://i.scdn.co/image/35ecdfba9c31a6c54ee4c73dcf1ad474c560cd00"}];
         } else {
         } else {
-            return [{id: "dQw4w9WgXcQ", title: "Never Gonna Give You Up", duration: getSongDuration("Never Gonna Give You Up"), albumart: getSongAlbumArt("Never Gonna Give You Up"), artist: "Rick Astley", type: "youtube"}];
+            return [{id: "dQw4w9WgXcQ", title: "Never Gonna Give You Up", duration: getSongDuration("Never Gonna Give You Up"), artist: "Rick Astley", type: "youtube", img: "https://i.scdn.co/image/5246898e19195715e65e261899baba890a2c1ded"}];
         }
         }
     }
     }
 
 
@@ -667,8 +661,14 @@ if (Meteor.isServer) {
             // Add a global video to Playlist so it can proceed
             // Add a global video to Playlist so it can proceed
         } else {
         } else {
             var startedAt = Date.now();
             var startedAt = Date.now();
-            var songs = Playlists.find({type: type}).fetch()[0].songs;
-            var currentSong = 0;
+            var playlist = Playlists.find({type: type}).fetch()[0];
+            var songs = playlist.songs;
+            if (playlist.lastSong === undefined) {
+                Playlists.update({type: type}, {$set: {lastSong: 0}});
+                playlist = Playlists.find({type: type}).fetch()[0];
+                songs = playlist.songs;
+            }
+            var currentSong = playlist.lastSong;
             addToHistory(songs[currentSong], startedAt);
             addToHistory(songs[currentSong], startedAt);
 
 
             function addToHistory(song, startedAt) {
             function addToHistory(song, startedAt) {
@@ -680,6 +680,7 @@ if (Meteor.isServer) {
                 if (currentSong < (songs.length - 1)) {
                 if (currentSong < (songs.length - 1)) {
                     currentSong++;
                     currentSong++;
                 } else currentSong = 0;
                 } else currentSong = 0;
+                Playlists.update({type: type}, {$set: {lastSong: currentSong}});
                 songTimer();
                 songTimer();
                 addToHistory(songs[currentSong], startedAt);
                 addToHistory(songs[currentSong], startedAt);
             }
             }
@@ -696,7 +697,6 @@ if (Meteor.isServer) {
     });
     });
 
 
     Accounts.onCreateUser(function(options, user) {
     Accounts.onCreateUser(function(options, user) {
-        console.log(options, user);
         if (options.profile) {
         if (options.profile) {
             user.profile = options.profile;
             user.profile = options.profile;
             user.profile.rank = "default";
             user.profile.rank = "default";
@@ -740,6 +740,10 @@ if (Meteor.isServer) {
         return Queues.find({});
         return Queues.find({});
     });
     });
 
 
+    Meteor.publish("chat", function() {
+        return Chat.find({});
+    });
+
     Meteor.publish("isAdmin", function() {
     Meteor.publish("isAdmin", function() {
         return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
         return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
     });
     });
@@ -760,16 +764,21 @@ if (Meteor.isServer) {
             }
             }
             return true;
             return true;
         },
         },
+        sendMessage: function(type, message) {
+            if (Chat.find({type: type}).count() === 0) {
+                Chat.insert({type: type, messages: []});
+            }
+            Chat.update({type: type}, {$push: {messages: {message: message, userid: "Kris"}}})
+        },
         addSongToQueue: function(type, songData) {
         addSongToQueue: function(type, songData) {
             type = type.toLowerCase();
             type = type.toLowerCase();
             if (Rooms.find({type: type}).count() === 1) {
             if (Rooms.find({type: type}).count() === 1) {
-                console.log(songData);
                 if (Queues.find({type: type}).count() === 0) {
                 if (Queues.find({type: type}).count() === 0) {
                     Queues.insert({type: type, songs: []});
                     Queues.insert({type: type, songs: []});
                 }
                 }
-                if (songData !== undefined && Object.keys(songData).length === 4 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined) {
+                if (songData !== undefined && Object.keys(songData).length === 5 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined && songData.img !== undefined) {
                     songData.duration = getSongDuration(songData.title);
                     songData.duration = getSongDuration(songData.title);
-                    Queues.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
+                    Queues.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, img: songData.img, type: songData.type}}});
                     return true;
                     return true;
                 } else {
                 } else {
                     throw new Meteor.error(403, "Invalid data.");
                     throw new Meteor.error(403, "Invalid data.");
@@ -785,12 +794,11 @@ if (Meteor.isServer) {
         addSongToPlaylist: function(type, songData) {
         addSongToPlaylist: function(type, songData) {
             type = type.toLowerCase();
             type = type.toLowerCase();
             if (Rooms.find({type: type}).count() === 1) {
             if (Rooms.find({type: type}).count() === 1) {
-                console.log(songData);
                 if (Playlists.find({type: type}).count() === 0) {
                 if (Playlists.find({type: type}).count() === 0) {
                     Playlists.insert({type: type, songs: []});
                     Playlists.insert({type: type, songs: []});
                 }
                 }
-                if (songData !== undefined && Object.keys(songData).length === 5 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined && songData.duration !== undefined) {
-                    Playlists.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, type: songData.type}}});
+                if (songData !== undefined && Object.keys(songData).length === 6 && songData.type !== undefined && songData.title !== undefined && songData.title !== undefined && songData.artist !== undefined && songData.duration !== undefined && songData.img !== undefined) {
+                    Playlists.update({type: type}, {$push: {songs: {id: songData.id, title: songData.title, artist: songData.artist, duration: songData.duration, img: songData.img, type: songData.type}}});
                     Queues.update({type: type}, {$pull: {songs: {id: songData.id}}});
                     Queues.update({type: type}, {$pull: {songs: {id: songData.id}}});
                     return true;
                     return true;
                 } else {
                 } else {

+ 0 - 1
app/head.html

@@ -7,7 +7,6 @@
     <meta name=viewport content='width=700'>
     <meta name=viewport content='width=700'>
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
     <link href='http://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
     <link href='http://fonts.googleapis.com/css?family=Oxygen:400,300,700' rel='stylesheet' type='text/css'>
-    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
     <script type="application/javascript">
     <script type="application/javascript">
         addEventListener("load", function() {
         addEventListener("load", function() {
             setTimeout(hideURLbar, 0);
             setTimeout(hideURLbar, 0);

+ 3 - 0
app/templates/admin.html

@@ -1,4 +1,5 @@
 <template name="admin">
 <template name="admin">
+    {{> header}}
     <div class="landing row">
     <div class="landing row">
         {{#each queues}}
         {{#each queues}}
             <div class="col-md-8 col-md-offset-2 ">
             <div class="col-md-8 col-md-offset-2 ">
@@ -14,6 +15,7 @@
                                     <th>Artist(s)</th>
                                     <th>Artist(s)</th>
                                     <th>Type</th>
                                     <th>Type</th>
                                     <th>Id</th>
                                     <th>Id</th>
+                                    <th>Img</th>
                                     <th>Preview</th>
                                     <th>Preview</th>
                                     <th>Add</th>
                                     <th>Add</th>
                                     <th colspan="10">Remove</th>
                                     <th colspan="10">Remove</th>
@@ -26,6 +28,7 @@
                                         <td>{{artist}}</td>
                                         <td>{{artist}}</td>
                                         <td>{{type}}</td>
                                         <td>{{type}}</td>
                                         <td>{{id}}</td>
                                         <td>{{id}}</td>
+                                        <td>{{img}}</td>
                                         <td class="column-small"><button class="btn btn-primary preview-button" data-toggle="modal" data-target="#previewModal">Preview</button></td>
                                         <td class="column-small"><button class="btn btn-primary preview-button" data-toggle="modal" data-target="#previewModal">Preview</button></td>
                                         <td class="column-small"><button class="btn btn-success" id="add-song-button" data-genre="{{../type}}"><i class="fa fa-check-circle"></i></button></td>
                                         <td class="column-small"><button class="btn btn-success" id="add-song-button" data-genre="{{../type}}"><i class="fa fa-check-circle"></i></button></td>
                                         <td class="column-small"><button class="btn btn-danger" id="deny-song-button" data-genre="{{../type}}"><i class="fa fa-ban"></i></button></td>
                                         <td class="column-small"><button class="btn btn-danger" id="deny-song-button" data-genre="{{../type}}"><i class="fa fa-ban"></i></button></td>

+ 0 - 1
app/templates/dashboard.html

@@ -1,6 +1,5 @@
 <template name="dashboard">
 <template name="dashboard">
     <div class="landing">
     <div class="landing">
-        <!-- <i class="fa fa-power-off logout" tooltip="Logout"></i> -->
         <div class="row">
         <div class="row">
            {{#each rooms}}
            {{#each rooms}}
               <div class="col-md-4 col-sm-6 col-xs-12">
               <div class="col-md-4 col-sm-6 col-xs-12">

+ 43 - 0
app/templates/header.html

@@ -0,0 +1,43 @@
+<template name="header">
+    <nav class="navbar navbar-default" id="header">
+        <div class="container-fluid">
+            <!-- Brand and toggle get grouped for better mobile display -->
+            <div class="navbar-header">
+                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
+                    <span class="sr-only">Toggle navigation</span>
+                    <span class="icon-bar"></span>
+                    <span class="icon-bar"></span>
+                    <span class="icon-bar"></span>
+                </button>
+                <a class="navbar-brand" href="#">Music App</a>
+            </div>
+
+            <!-- Collect the nav links, forms, and other content for toggling -->
+            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+                <ul class="nav navbar-nav">
+                    <!--li class="active"><a href="">Link <span class="sr-only">(current)</span></a></li-->
+                    <li class="{{isActivePath '/'}}"><a href="/">Home</a></li>
+                    {{#if isAdmin}}
+                        <li class="{{isActivePath '/admin'}}"><a href="/admin">Admin</a></li>
+                    {{/if}}
+                </ul>
+                <!--form class="navbar-form navbar-left" role="search">
+                    <div class="form-group">
+                        <input type="text" class="form-control" placeholder="Search">
+                    </div>
+                    <button type="submit" class="btn btn-default">Submit</button>
+                </form-->
+                <ul class="nav navbar-nav navbar-right">
+                    <li class="dropdown">
+                        {{#if currentUser}}
+                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{currentUser.profile.name}} <span class="caret"></span></a>
+                            <ul class="dropdown-menu">
+                                <li><a href="#" class="logout">Logout</a></li>
+                            </ul>
+                        {{/if}}
+                    </li>
+                </ul>
+            </div><!-- /.navbar-collapse -->
+        </div><!-- /.container-fluid -->
+    </nav>
+</template>

+ 1 - 0
app/templates/home.html

@@ -1,4 +1,5 @@
 <template name="home">
 <template name="home">
+    {{> header}}
     {{#if currentUser}}
     {{#if currentUser}}
     <div id="dashboard">
     <div id="dashboard">
         {{> dashboard}}
         {{> dashboard}}

+ 1 - 0
app/templates/privacy.html

@@ -1,4 +1,5 @@
 <template name="privacy">
 <template name="privacy">
+    {{> header}}
     <div class="privacy">
     <div class="privacy">
         <h2>Privacy Policy</h2>
         <h2>Privacy Policy</h2>
 
 

+ 39 - 15
app/templates/room.html

@@ -1,4 +1,5 @@
 <template name="room">
 <template name="room">
+    {{> header}}
     <div class="landing">
     <div class="landing">
         {{#if loaded}}
         {{#if loaded}}
             <h1 class="room-name">{{{type}}}</h1>
             <h1 class="room-name">{{{type}}}</h1>
@@ -26,6 +27,22 @@
                 <button type="button" id="song-modal" class="button-nowidth col-md-4 col-sm-4 col-xs-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4" data-toggle="modal" data-target="#myModal">Add songs</button>
                 <button type="button" id="song-modal" class="button-nowidth col-md-4 col-sm-4 col-xs-4 col-md-offset-4 col-sm-offset-4 col-xs-offset-4" data-toggle="modal" data-target="#myModal">Add songs</button>
             </div>
             </div>
             {{> playlist}}
             {{> playlist}}
+
+            <div class="row" id="chat">
+                <div class="panel panel-success col-md-6 col-md-offset-3" id="chat-container">
+                    <div class="panel-heading">Chat</div>
+                    <div class="panel-body">
+                        <ul id="chat-ul">
+                            {{#each chat}}
+                                <li class="chat-message"><b class="bold">{{userid}}:</b> {{message}}</li>
+                            {{/each}}
+                        </ul>
+                        <input id="chat-input"/>
+                        <button id="submit-message" class="button-nowidth">Submit Message</button>
+                    </div>
+                </div>
+            </div>
+
             <!-- Modal -->
             <!-- Modal -->
             <div id="myModal" class="modal fade" role="dialog">
             <div id="myModal" class="modal fade" role="dialog">
               <div class="modal-dialog">
               <div class="modal-dialog">
@@ -38,23 +55,30 @@
                   </div>
                   </div>
                   <div class="modal-body">
                   <div class="modal-body">
                     <div id="search-info">
                     <div id="search-info">
-                      <input type="text" id="song-input" class="song-input">
-                      <button type="button" id="search-song" class="button">Search</button>
-                      <div id="song-results"></div>
+                        <select name="type" id="search_type" class="song-input-select">
+                            <option name="youtube" id="search_youtube">YouTube</option>
+                            <option name="soundcloud" id="search_soundcloud">SoundCloud</option>
+                        </select>
+                        <input type="text" id="song-input" class="song-input">
+                        <button type="button" id="search-song" class="button">Search</button>
+                        <div id="song-results"></div>
                     </div>
                     </div>
                     <div id="add-info" style="display:none">
                     <div id="add-info" style="display:none">
-                      <label for="type" class="song-input-label">Song Type</label>
-                      <select name="type" id="type" class="song-input-select">
-                          <option name="youtube" id="youtube">YouTube</option>
-                          <option name="soundcloud" id="soundcloud">SoundCloud</option>
-                      </select>
-                      <label for="id" class="song-input-label">Song ID</label>
-                      <input class="song-input" name="id" id="id" type="text" />
-                      <label for="id" class="song-input-label">Song Artist</label>
-                      <input class="song-input" name="artist" id="artist" type="text" />
-                      <label for="title" class="song-input-label">Song Title</label>
-                      <input class="song-input" name="title" id="title" type="text" />
-                      <button type="button" id="add-song-button" class="button">Add Song</button>
+                        <button type="button" id="return" class="button">Return</button>
+                        <label for="type" class="song-input-label">Song Type</label>
+                        <select name="type" id="type" class="song-input-select">
+                            <option name="youtube" id="youtube">YouTube</option>
+                            <option name="soundcloud" id="soundcloud">SoundCloud</option>
+                        </select>
+                        <label for="id" class="song-input-label">Song ID</label>
+                        <input class="song-input" name="id" id="id" type="text" />
+                        <label for="id" class="song-input-label">Song Artist</label>
+                        <input class="song-input" name="artist" id="artist" type="text" />
+                        <label for="title" class="song-input-label">Song Title</label>
+                        <input class="song-input" name="title" id="title" type="text" />
+                        <label for="img" class="song-input-label">Song Img</label>
+                        <input class="song-input" name="img" id="img" type="text" />
+                        <button type="button" id="add-song-button" class="button">Add Song</button>
                     </div>
                     </div>
                       <!--small id="search-alert">Searching for a song fills out the above fields automatically, but you will still have to verify them.</small-->
                       <!--small id="search-alert">Searching for a song fills out the above fields automatically, but you will still have to verify them.</small-->
                   </div>
                   </div>

+ 1 - 0
app/templates/terms.html

@@ -1,4 +1,5 @@
 <template name="terms">
 <template name="terms">
+    {{> header}}
     <div class="terms">
     <div class="terms">
         <h1>Terms of Service</h1>
         <h1>Terms of Service</h1>
         <small>Last updated: Septemeber 29, 2015</small>
         <small>Last updated: Septemeber 29, 2015</small>