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 || "@nonymous" }} :
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) {
35 !!chat.name && chat.name == this.st.user.name ||
36 !!chat.sid && chat.sid == this.st.user.sid
45 p.name == chat.name &&
46 p.name != this.st.user.name
52 p.sid != this.st.user.sid
59 sendChat: function() {
60 let chatInput = document.getElementById("inputChat");
61 const chatTxt = chatInput.value.trim();
62 chatInput.focus(); //required on smartphones
63 if (chatTxt == "") return; //nothing to send
67 name: this.st.user.name,
68 // SID is required only for anonymous users (in live games)
69 sid: this.st.user.id == 0 ? this.st.user.sid : null
71 this.$emit("mychat", chat);
72 this.chats.unshift(chat);
74 newChat: function(chat) {
75 if (chat.msg != "") this.chats.unshift(chat);
77 clearHistory: function() {
79 this.$emit("chatcleared");
85 <style lang="sass" scoped>