3 input#inputChat(type="text" :placeholder="st.tr['Type here']"
4 @keyup.enter="sendChat")
5 button#sendChatBtn(@click="sendChat") {{ st.tr["Send"] }}
6 p(v-for="chat in chats" :class="classObject(chat)"
7 v-html="chat.name + ': ' + chat.msg")
8 p(v-for="chat in pastChats" :class="classObject(chat)"
9 v-html="chat.name + ': ' + chat.msg")
13 import { store } from "@/store";
17 // Prop 'pastChats' for corr games where chats are on server
18 props: ["players","pastChats","newChat"],
22 chats: [], //chat messages after human game
26 newChat: function(chat) {
28 this.chats.unshift({msg:chat.msg, name:chat.name || "@nonymous"});
32 classObject: function(chat) {
34 "my-chatmsg": chat.name == this.st.user.name,
35 "opp-chatmsg": !!this.players && this.players.some(
36 p => p.name == chat.name && p.name != this.st.user.name)
39 sendChat: function() {
40 let chatInput = document.getElementById("inputChat");
41 const chatTxt = chatInput.value.trim();
43 return; //nothing to send
45 const chat = {msg:chatTxt, name: this.st.user.name || "@nonymous"};
46 this.$emit("mychat", chat);
47 this.chats.unshift(chat);
53 <style lang="sass" scoped>