3 input#inputChat(type="text" :placeholder="st.tr['Type 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,
33 "opp-chatmsg": !!this.players && this.players.some(
34 p => p.name == chat.name && p.name != this.st.user.name)
37 sendChat: function() {
38 let chatInput = document.getElementById("inputChat");
39 const chatTxt = chatInput.value.trim();
41 return; //nothing to send
43 const chat = {msg:chatTxt, name: this.st.user.name || "@nonymous"};
44 this.$emit("mychat", chat);
45 this.chats.unshift(chat);
51 <style lang="sass" scoped>