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"],
28 chats: [] //chat messages after human game
32 classObject: function(chat) {
34 "my-chatmsg": chat.name == this.st.user.name,
38 p => p.name == chat.name && p.name != this.st.user.name
42 sendChat: function() {
43 let chatInput = document.getElementById("inputChat");
44 const chatTxt = chatInput.value.trim();
45 if (chatTxt == "") return; //nothing to send
47 const chat = { msg: chatTxt, name: this.st.user.name || "@nonymous" };
48 this.$emit("mychat", chat);
49 this.chats.unshift(chat);
51 newChat: function(chat) {
53 this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" });
55 clearHistory: function() {
57 this.$emit("chatcleared");
63 <style lang="sass" scoped>