ソースを参照

worked on chat

Akira Laine 9 年 前
コミット
706940a6fe

+ 9 - 40
app/client/scripts/events.js

@@ -153,8 +153,8 @@ function sendMessage() {
 }
 
 function sendMessageGlobal() {
-    var message = $("#global-chat-input").val();
-    if (!$("#global-chat-input").hasClass("disabled")) {
+    var message = $("#chat-message").val();
+    if (!$("#chat-message").hasClass("disabled")) {
         if (message.length > 0 && message[0] !== " ") {
             if (message[0] === "/") {
                 message = message.split("");
@@ -164,19 +164,15 @@ function sendMessageGlobal() {
                 var command = params.shift();
                 command = command.replace(/\r?\n|\r/g, "");
                 if (executeCommand(command, params)) {
-                    $("#global-chat-input").val("");
+                    $("#chat-message").val("");
                 } else {
-                    $("#global-chat-input").val("");
+                    $("#chat-message").val("");
                 }
             } else {
-                $("#global-chat-input").addClass("disabled");
-                $("#global-chat-input").attr("disabled", "");
                 Meteor.call("sendMessage", "global", message, function (err, res) {
                     if (res) {
-                        $("#global-chat-input").val("");
+                        $("#chat-message").val("");
                     }
-                    $("#global-chat-input").removeClass("disabled");
-                    $("#global-chat-input").removeAttr("disabled");
                 });
             }
         }
@@ -1385,46 +1381,19 @@ Template.room.events({
     "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);
+            $(".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) {
+    "keyup #chat-message": function (e) {
         if (e.type === "keyup" && e.which === 13) {
             e.preventDefault();
-            if (!$('#global-chat-input').data('dropdownshown')) {
+            if (!$('#chat-message').data('dropdownshown')) {
                 sendMessageGlobal();
                 Meteor.setTimeout(function () {
-                    $("#global-chat-ul").scrollTop(100000);
+                    $(".chat-ul").scrollTop(100000);
                 }, 1000)
             }
         }

+ 35 - 0
app/client/stylesheets/app.css

@@ -38,6 +38,10 @@ textarea{
     color: white;
 }
 
+hr{
+    margin: 0;
+}
+
 .brand-logo {
     margin-left: 10px;
     font-weight: 300 !important;
@@ -282,3 +286,34 @@ textarea{
 .alert i{
     vertical-align: middle;
 }
+
+.chat-ul{
+    height: 79%;
+    overflow-y: scroll;
+}
+
+.chat-message:hover{
+    background-color: white !important;
+}
+
+.chat-message small{
+    float: left;
+}
+
+.chat-message a{
+    width: 50px;
+    height: 50px;
+}
+
+#submit{
+    color: white;
+    height: 36px;
+    line-height: 36px;
+    margin: 0 10px !important;
+}
+
+@media screen and (max-width: 990px){
+    .card i{
+        line-height: 1.8em;
+    }
+}

+ 2 - 2
app/client/templates/header.html

@@ -85,8 +85,8 @@
                     </ul>
                     <!--<li><a class="mobile-dropdown" href="#!" data-activates="contributeDrop">Contribute<i class="material-icons right">arrow_drop_down</i></a></li>
                     <li><a class="mobile-dropdown" href="#!" data-activates="aboutDrop">About<i class="material-icons right">arrow_drop_down</i></a></li>
-                    <li><a class="mobile-dropdown" href="#!" data-activates="accountDrop">Account<i class="material-icons right">arrow_drop_down</i></a></li>
-                  --></ul>
+                    <li><a class="mobile-dropdown" href="#!" data-activates="accountDrop">Account<i class="material-icons right">arrow_drop_down</i></a></li>-->
+                </ul>
             </div>
         </nav>
         <script>

+ 30 - 3
app/client/templates/room.html

@@ -13,8 +13,8 @@
                     <span class="brand-logo center">{{type}}</span>
                     <ul class="right hide-on-med-and-down">
                         <li><a href="#"><i class="material-icons">queue_music</i></a></li>
-                        <li><a href="#" data-activates="chat" class="dropdown-button"><i class="material-icons">chat</i></a>
-                        </li>
+                        <!-- <li><a href="#" data-activates="chat" class="dropdown-button"><i class="material-icons">chat</i></a></li> -->
+                        <li><a href="#" data-activates="slide-out" class="header-collapse"><i class="material-icons">chat</i></a></li>
                     </ul>
                     <div id='chat' class='dropdown-content right'>
                         <ul id="chat-ul">
@@ -217,13 +217,36 @@
                         </form>
                     </div>
                 </div>
-
                 <div class="divider"></div>
                 <div class="modal-footer">
                     <a href="#" class="modal-action modal-close waves-effect btn">Close</a>
                 </div>
             </div>
         </main>
+        <div id="slide-out" class="side-nav">
+            <ul class="chat-ul">
+                {{#each globalChat}}
+                    {{#emojione}}
+                        <li class="chat-message">
+                            <span title="{{time}}" style="float: right;">{{rtime time}}</span>
+                            <small class="rank-{{this.rawrank}}">{{this.rank}}</small>
+                            <a style="text-decoration: none" href="/u/{{this.username}}" target="_blank">{{this.username}}</a>
+                            <p style="clear: both; margin-bottom: -10px">{{this.message}}</p>
+                        </li>
+                    {{/emojione}}
+                    <hr>
+                {{/each}}
+            </ul>
+            <div>
+                <div class="row">
+                    <div class="input-field col s12">
+                      <input id="chat-message" type="text">
+                      <label for="chat-message">Send a message</label>
+                    </div>
+                </div>
+                <a id="submit" class="waves-effect waves-light btn">Send</a>
+            </div>
+        </div>
         <script>
             $("#add-song-modal-button").leanModal({
                 dismissible: true,
@@ -236,6 +259,10 @@
                 alignment: 'right'
             });
             $('select').material_select();
+            $(".header-collapse").sideNav({
+                menuWidth: 350,
+                edge: 'right'
+            });
         </script>
     {{/if}}
 </template>

+ 2 - 19
app/server/server.js

@@ -753,24 +753,7 @@ Meteor.methods({
             var time = new Date();
             var rawrank = user.profile.rank;
             var username = user.profile.username;
-            var profanity = false;
-            var mentionUsername;
-            var isCurUserMentioned;
-            if (message.indexOf("@") !== -1) {
-                var messageArr = message.split(" ");
-                for (var i in messageArr) {
-                    if (messageArr[i].indexOf("@") !== -1) {
-                        var mention = messageArr[i];
-                    }
-                }
-                Meteor.users.find().forEach(function (user) {
-                    if (mention.indexOf(user.profile.username) !== -1) {
-                        mentionUsername = true;
-                        isCurUserMentioned = Meteor.user().profile.username === user.profile.username;
-                    }
-                    ;
-                })
-            }
+            var profanity = false
             if (!message.replace(/\s/g, "").length > 0) {
                 throw new Meteor.Error(406, "Message length cannot be 0.");
             }
@@ -821,7 +804,7 @@ Meteor.methods({
                         Chat.insert({
                             type: type,
                             rawrank: rawrank,
-                            rank: "",
+                            rank: "[D]",
                             message: message,
                             time: time,
                             username: username