3 button(@click="clearHistory()")
4 | {{ st.tr["Clear history"] }}
7 :placeholder="st.tr['Chat here']"
8 @keyup.enter="sendChat()"
10 button(@click="sendChat()") {{ st.tr["Send"] }}
11 p(v-for="chat in chats.concat(pastChats)")
12 span.name {{ chat.name }} :
14 :class="classObject(chat)"
20 import { store } from "@/store";
23 // Prop 'pastChats' for corr games where chats are on server
24 props: ["players", "pastChats", "newChat"],
28 chats: [] //chat messages after human game
32 newChat: function(chat) {
34 this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" });
38 classObject: function(chat) {
40 "my-chatmsg": chat.name == this.st.user.name,
44 p => p.name == chat.name && p.name != this.st.user.name
48 sendChat: function() {
49 let chatInput = document.getElementById("inputChat");
50 const chatTxt = chatInput.value.trim();
51 if (chatTxt == "") return; //nothing to send
53 const chat = { msg: chatTxt, name: this.st.user.name || "@nonymous" };
54 this.$emit("mychat", chat);
55 this.chats.unshift(chat);
57 clearHistory: function() {
59 this.$emit("chatcleared");
65 <style lang="sass" scoped>