Browse Source

Added /shuffle, /skip, /pause, /resume and /mute command.

KrisVos130 9 years ago
parent
commit
b4d3eff58e
2 changed files with 42 additions and 1 deletions
  1. 36 0
      app/client/client.js
  2. 6 1
      app/client/templates/room.html

+ 36 - 0
app/client/client.js

@@ -411,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];
@@ -420,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);
+            }
+        });
     }
 }
 
@@ -432,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 {

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

@@ -414,13 +414,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">