X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=ddd5e5935605a7b75c4df1957e67bc59e0f79d20;hp=d366bb2d0b27e5ed9b4fb54d15254259f5450f56;hb=ac8f441c6441d827b43aabeb812cb4c79e9ee96b;hpb=5fd5fb22de02ed6c585e86a1c3dda50ff6071d2f diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index d366bb2d..ddd5e593 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -5,13 +5,13 @@ main #chat.card label.modal-close(for="modalChat") #participants - span {{ Object.keys(people).length }} st.tr["participant(s):"] + span {{ Object.keys(people).length + " " + st.tr["participant(s):"] }} span(v-for="p in Object.values(people)" v-if="!!p.name") | {{ p.name }} span.anonymous(v-if="Object.values(people).some(p => !p.name)") | + @nonymous Chat(:players="game.players" :pastChats="game.chats" - @newchat-sent="finishSendChat" @newchat-received="processChat") + :newChat="newChat" @mychat="processChat") .row #aboveBoard.col-sm-12.col-md-9.col-md-offset-3.col-lg-10.col-lg-offset-2 span.variant-info @@ -68,6 +68,7 @@ export default { people: {}, //players + observers lastate: undefined, //used if opponent send lastate before game is ready repeat: {}, //detect position repetition + newChat: "", }; }, watch: { @@ -246,6 +247,11 @@ export default { this.drawOffer = ""; this.$set(this.game, "moveToPlay", data.move); break; + case "newchat": + this.newChat = data.chat; + if (!document.getElementById("modalChat").checked) + document.getElementById("chatBtn").style.backgroundColor = "#c5fefe"; + break; case "lastate": //got opponent infos about last move { this.lastate = data; @@ -616,15 +622,12 @@ export default { // TODO: this is called twice, once on opening an once on closing document.getElementById("chatBtn").style.backgroundColor = "#e2e2e2"; }, - finishSendChat: function(chat) { + processChat: function(chat) { + this.st.conn.send(JSON.stringify({code:"newchat", chat:chat})); // NOTE: anonymous chats in corr games are not stored on server (TODO?) if (this.game.type == "corr" && this.st.user.id > 0) GameStorage.update(this.gameRef.id, {chat: chat}); }, - processChat: function() { - if (!document.getElementById("modalChat").checked) - document.getElementById("chatBtn").style.backgroundColor = "#c5fefe"; - }, gameOver: function(score, scoreMsg) { this.game.score = score; this.game.scoreMsg = this.st.tr[(!!scoreMsg @@ -666,7 +669,6 @@ export default { margin-top: 10px button display: inline-block - width: 33% margin: 0 @media screen and (max-width: 767px)