Some graphical improvements (first attempt)
[vchess.git] / client / src / components / Chat.vue
index b4970f7..517d2cd 100644 (file)
@@ -1,13 +1,11 @@
 <template lang="pug">
-.row
-  .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
-    // TODO: Chat modal sur petit écran, dans la page pour grand écran
-    .card.smallpad
-      h4 Chat
-      p(v-for="chat in chats" :class="classObject(chat)" v-html="chat.msg")
-      input#inputChat(type="text" :placeholder="st.tr['Type here']"
-        @keyup.enter="sendChat")
-      button#sendChatBtn(@click="sendChat") {{ st.tr["Send"] }}
+div
+  .card.smallpad
+    h4 Chat
+    p(v-for="chat in chats" :class="classObject(chat)" v-html="chat.msg")
+    input#inputChat(type="text" :placeholder="st.tr['Type here']"
+      @keyup.enter="sendChat")
+    button#sendChatBtn(@click="sendChat") {{ st.tr["Send"] }}
 </template>
 
 <script>
@@ -23,12 +21,14 @@ export default {
     };
   },
   created: function() {
+    const curMsgListener = this.st.conn.onmessage; //from Game or Hall
     const socketMessageListener = msg => {
+      curMsgListener(msg);
       const data = JSON.parse(msg.data);
       if (data.code == "newchat") //only event at this level
       {
         this.chats.push({msg:data.msg,
-          name:data.name || "@nonymous", sid:data.sid});
+          name:data.name || "@nonymous", sid:data.from});
       }
     };
     const socketCloseListener = () => {