浏览代码

Merge branch 'master' of https://github.com/Musare/Musare

# Conflicts:
#	app/client/app.css
#	app/client/client.js
#	app/client/templates/stations.html
Wesley McCann 9 年之前
父节点
当前提交
99e59c03fd
共有 5 个文件被更改,包括 191 次插入15 次删除
  1. 58 1
      app/client/app.css
  2. 74 2
      app/client/client.js
  3. 8 3
      app/client/templates/profile.html
  4. 6 1
      app/client/templates/room.html
  5. 45 8
      app/server/server.js

+ 58 - 1
app/client/app.css

@@ -1414,7 +1414,64 @@ nav form input[type="image"]{
     margin-right: 5px;
     float: left;
 }
-
+.profile-img{
+    width: 100px;
+    height: 100px;
+    margin: 0 auto;
+}
+.profile-img .avatar-initials{
+    line-height: 100px !important;
+}
 #doorbell-email{
     color: black;
 }
+.song-panel{
+    max-height: 400px;
+    overflow-y: scroll;
+    overflow-x: hidden;
+}
+.song-panel-room{
+    float: right;
+}
+/*Credit to: http://thecodeplayer.com/walkthrough/custom-animated-checkbox-inputs-using-css-iconfonts*/
+#two-label {
+    position: relative;
+    padding-left: 30px;
+    font-size: 14px;
+    cursor: pointer;
+    margin-bottom: 15px;
+    color: white;
+    padding-top: 3px;
+}
+#two-label:before, #two-label:after {
+    font-family: FontAwesome;
+    font-size: 21px;
+    /*absolutely positioned*/
+    position: absolute; top: 0; left: 0;
+}
+#two-label:before {
+    content: '\f096'; /*unchecked*/
+}
+#two-label:after {
+    content: '\f046'; /*checked*/
+    /*checked icon will be hidden by default by using 0 max-width and overflow hidden*/
+    max-width: 0;
+    overflow: hidden;
+    opacity: 0.5;
+    /*CSS3 transitions for animated effect*/
+    transition: all 0.35s;
+}
+
+/*hiding the original checkboxes*/
+input[type="checkbox"] {
+    display: none;
+}
+/*when the user checks the checkbox the checked icon will animate in*/
+input[type="checkbox"]:checked + #two-label:after {
+    max-width: 25px; /*an arbitratry number more than the icon's width*/
+    opacity: 1; /*for fade in effect*/
+}
+
+/*adding some colors for fun*/
+#two+label:before, #two+label:after {color: hsl(180, 45%, 40%);}
+

+ 74 - 2
app/client/client.js

@@ -97,7 +97,7 @@ Template.settings.events({
 
 Template.profile.helpers({
     "username": function() {
-        return Session.get("username");
+        return Session.get("username")
     },
     "first_joined": function() {
         return moment(Session.get("first_joined")).format("DD/MM/YYYY HH:mm:ss");
@@ -137,7 +137,15 @@ Template.profile.helpers({
             })
         });
         return dislikedArr;
-    }
+    },
+    initials: function() {
+        var user = Meteor.user();
+        if (user !== undefined) {
+            return user.profile.username[0].toUpperCase();
+        } else {
+            return "";
+        }
+    },
 });
 
 Template.profile.onCreated(function() {
@@ -403,6 +411,17 @@ function executeCommand(command, params){
                 return true;
             }
         }
+    } else if(command === "mute"){
+        $("#volume-slider").slider("setValue", 0);
+        $("#volume-icon").removeClass("fa-volume-down").addClass("fa-volume-off");
+        if (yt_player !== undefined) {
+            yt_player.setVolume(0);
+            localStorage.setItem("volume", 0);
+        } else if (_sound !== undefined) {
+            //_sound
+            _sound.setVolume(0);
+            localStorage.setItem("volume", 0);
+        }
     } else if(command === "ban"){
         var user = params[0];
         var time = params[1];
@@ -412,6 +431,30 @@ function executeCommand(command, params){
                 console.log(err);
             }
         });
+    } else if(command === "pause"){
+        Meteor.call("pauseRoom", Session.get("type"), function(err, res){
+            if(err){
+                console.log(err);
+            }
+        });
+    } else if(command === "resume"){
+        Meteor.call("resumeRoom", Session.get("type"), function(err, res){
+            if(err){
+                console.log(err);
+            }
+        });
+    } else if(command === "shuffle"){
+        Meteor.call("shufflePlaylist", Session.get("type"), function(err, res){
+            if(err){
+                console.log(err);
+            }
+        });
+    } else if(command === "skip"){
+        Meteor.call("skipSong", Session.get("type"), function(err, res){
+            if(err){
+                console.log(err);
+            }
+        });
     }
 }
 
@@ -424,6 +467,7 @@ function sendMessage() {
             message = message.join("");
             var params = message.split(" ");
             var command = params.shift();
+            command = command.replace(/\r?\n|\r/g, "");
             if (executeCommand(command, params)) {
                 $("#chat-input").val("");
             } else {
@@ -1111,6 +1155,25 @@ Template.stations.events({
         var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
         Meteor.call("removeSongFromPlaylist", genre, this.mid);
     },
+    "click #moveSong": function(e){
+      var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
+      if (genre !== Session.get(genre)) {
+        Meteor.call("addSongToPlaylist", genre, {type: Session.get("song").type, mid: Session.get("song").mid, id: Session.get("song").id, title: Session.get("song").title, artist: Session.get("song").artist, duration: Session.get("song").duration, skipDuration: Session.get("song").skipDuration, img: Session.get("song").img, likes: Session.get("song").likes, dislikes: Session.get("song").dislikes});
+        Meteor.call("removeSongFromPlaylist", Session.get("genre"), Session.get("song").mid);
+      }else {
+        console.log("Something Went Wrong?!");
+        return false;
+      }
+
+    },
+    "click #copySong": function(e){
+      var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
+      Meteor.call("addSongToPlaylist", genre, {type: Session.get("song").type, mid: Session.get("song").mid, id: Session.get("song").id, title: Session.get("song").title, artist: Session.get("song").artist, duration: Session.get("song").duration, skipDuration: Session.get("song").skipDuration, img: Session.get("song").img, likes: Session.get("song").likes, dislikes: Session.get("song").dislikes});
+    },
+    "click .copyMove-button": function(e){
+        Session.set("song", this);
+        Session.set("genre", $(e.target).data("genre"));
+    },
     "click #play": function() {
         $("#play").attr("disabled", true);
         $("#stop").attr("disabled", false);
@@ -1219,6 +1282,15 @@ Template.stations.events({
             }, 10000);
         }
     },
+    "click #croom_create": function() {
+        Meteor.call("createRoom", $("#croom_display").val(), $("#croom_tag").val(), $("#two").prop("checked"), function (err, res) {
+            if (err) {
+                alert("Error " + err.error + ": " + err.reason);
+            } else {
+                window.location = "/" + $("#croom_tag").val();
+            }
+        });
+    },
     "click #get-spotify-info": function() {
         var search = $("#title").val();
         var artistName = $("#artist").val();

+ 8 - 3
app/client/templates/profile.html

@@ -4,6 +4,7 @@
       {{> header}}
       <div class="row">
         {{#if loaded}}
+            {{> avatar userId=userId shape="circle" class="profile-img" initials=initials}}
             <h1 id="profile-name">{{username}}</h1>
 
             <div class="col-md-4">
@@ -20,10 +21,14 @@
             <div class="col-md-4">
                 <div class="panel panel-success">
                     <div class="panel-heading">Liked Songs</div>
-                    <div class="panel-body">
+                    <div class="panel-body song-panel">
                         <ul>
                             {{#each likedSongs}}
-                                <li>{{title}} - {{artist}} - {{room}}</li>
+                                <li>
+                                    <p class="song-panel-room">{{room}}</p>
+                                    <h4>{{title}}</h4>
+                                    <h5>{{artist}}</h5>
+                                </li>
                             {{/each}}
                         </ul>
                     </div>
@@ -32,7 +37,7 @@
             <div class="col-md-4">
                 <div class="panel panel-danger">
                     <div class="panel-heading">Disliked Songs</div>
-                    <div class="panel-body">
+                    <div class="panel-body song-panel">
                         <ul>
                             {{#each dislikedSongs}}
                                 <li>{{title}} - {{artist}} - {{room}}</li>

+ 6 - 1
app/client/templates/room.html

@@ -413,13 +413,18 @@
                             <ul>
                                 {{#if isAdmin}}
                                     <h5 style="margin-bottom:0 !important;">Admin Commands:</h5>
-                                    <li>/ban [userName] [time] [reason]</li>
+                                    <li>/ban &lt;userName&gt; &lt;time&gt; &lt;reason&gt;</li>
+                                    <li>/shuffle</li>
+                                    <li>/skip</li>
+                                    <li>/pause</li>
+                                    <li>/resume</li>
                                 {{/if}}
                                 <br>
                                 <h5 style="margin-bottom:0 !important;">User Commands:</h5>
                                 <li>/help</li>
                                 <li>/commands</li>
                                 <li>/volume</li>
+                                <li>/mute</li>
                             </ul>
                         </div>
                         <div class="modal-footer">

+ 45 - 8
app/server/server.js

@@ -13,7 +13,7 @@ Meteor.startup(function() {
     var stations = [{tag: "edm", display: "EDM"}, {tag: "pop", display: "Pop"}]; //Rooms to be set on server startup
     for(var i in stations){
         if(Rooms.find({type: stations[i]}).count() === 0){
-            createRoom(stations[i].display, stations[i].tag);
+            createRoom(stations[i].display, stations[i].tag, false);
         }
     }
     emojione.ascii = true;
@@ -86,9 +86,9 @@ function getStation(type, cb) {
     });
 }
 
-function createRoom(display, tag) {
+function createRoom(display, tag, private) {
     var type = tag;
-    if (Rooms.find({type: type}).count() === 0) {
+    if (Rooms.find({type: type}).count() === 0 && private === false) {
         Rooms.insert({display: display, type: type, users: 0}, function(err) {
             if (err) {
                 throw err;
@@ -106,6 +106,24 @@ function createRoom(display, tag) {
                 }
             }
         });
+    } else if (Rooms.find({type: type}).count() === 0 && private === true) {
+        Rooms.insert({display: display, type: type, users: 0, private: true}, function(err) {
+            if (err) {
+                throw err;
+            } else {
+                if (Playlists.find({type: type}).count() === 1) {
+                    stations.push(new Station(type));
+                } else {
+                    Playlists.insert({type: type, songs: getSongsByType(type)}, function (err2) {
+                        if (err2) {
+                            throw err2;
+                        } else {
+                            stations.push(new Station(type));
+                        }
+                    });
+                }
+            }
+        });
     } else {
         return "Room already exists";
     }
@@ -585,6 +603,7 @@ Meteor.methods({
             var time = new Date();
             var rawrank = user.profile.rank;
             var username = user.profile.username;
+            var profanity = false;
             if (!message.replace(/\s/g, "").length > 0) {
                 throw new Meteor.Error(406, "Message length cannot be 0.");
             }
@@ -592,15 +611,33 @@ Meteor.methods({
                 throw new Meteor.Error(406, "Message length cannot be more than 300 characters long..");
             }
             else if (user.profile.rank === "admin") {
-                Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
+                HTTP.call("GET", "http://www.wdyl.com/profanity?q=" + encodeURIComponent(message), function(err,res){
+                    if(res.content.indexOf("true") > -1){
+                        return true;
+                    } else{
+                        Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
+                    }
+                });
                 return true;
             }
             else if (user.profile.rank === "moderator") {
-                Chat.insert({type: type, rawrank: rawrank, rank: "[M]", message: message, time: time, username: username});
+                HTTP.call("GET", "http://www.wdyl.com/profanity?q=" + encodeURIComponent(message), function(err,res){
+                    if(res.content.indexOf("true") > -1){
+                        return true;
+                    } else{
+                        Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
+                    }
+                });
                 return true;
             }
             else {
-                Chat.insert({type: type, rawrank: rawrank, message: message, time: time, username: username});
+                HTTP.call("GET", "http://www.wdyl.com/profanity?q=" + encodeURIComponent(message), function(err,res){
+                    if(res.content.indexOf("true") > -1){
+                        return true;
+                    } else{
+                        Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
+                    }
+                });
                 return true;
             }
         } else {
@@ -895,9 +932,9 @@ Meteor.methods({
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    createRoom: function(display, tag) {
+    createRoom: function(display, tag, private) {
         if (isAdmin() && !isBanned()) {
-            createRoom(display, tag);
+            createRoom(display, tag, private);
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }