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 chatInput.focus(); //required on smartphones
46 if (chatTxt == "") return; //nothing to send
48 const chat = { msg: chatTxt, name: this.st.user.name || "@nonymous" };
49 this.$emit("mychat", chat);
50 this.chats.unshift(chat);
52 newChat: function(chat) {
54 this.chats.unshift({ msg: chat.msg, name: chat.name || "@nonymous" });
56 clearHistory: function() {
58 this.$emit("chatcleared");
64 <style lang="sass" scoped>