3 input#inputChat(type="text" :placeholder="st.tr['Chat here']"
4 @keyup.enter="sendChat()")
5 button(@click="sendChat()") {{ st.tr["Send"] }}
6 p(v-for="chat in chats.concat(pastChats)")
7 span.name {{ chat.name }} :
8 span(:class="classObject(chat)" v-html="chat.msg")
12 import { store } from "@/store";
15 // Prop 'pastChats' for corr games where chats are on server
16 props: ["players", "pastChats", "newChat"],
20 chats: [] //chat messages after human game
24 newChat: function(chat) {
26 this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" });
30 classObject: function(chat) {
32 "my-chatmsg": chat.name == this.st.user.name,
36 p => p.name == chat.name && p.name != this.st.user.name
40 sendChat: function() {
41 let chatInput = document.getElementById("inputChat");
42 const chatTxt = chatInput.value.trim();
43 if (chatTxt == "") 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>