X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=cb1b720d540e587b378313932c8fe8d1b1ed4029;hb=3a2a7b5fd3c6bfd0752838094c27e1fb6172d109;hp=e909f70e601ccb3c05ba5507ed00547937dcf8ea;hpb=cafe016679ee9c14bf7bf0a37104ade7f74aff89;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index e909f70e..cb1b720d 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -89,7 +89,7 @@ main ) img(src="/images/icons/resign.svg") button.tooltip( - v-else-if="!!game.mycolor" + v-else @click="clickRematch()" :class="{['rematch-' + rematchOffer]: true}" :aria-label="st.tr['Rematch']" @@ -216,12 +216,13 @@ export default { }, mounted: function() { document.addEventListener('visibilitychange', this.visibilityChange); - document - .getElementById("chatWrap") - .addEventListener("click", processModalClick); + ["chatWrap", "infoDiv"].forEach(eltName => { + document.getElementById(eltName) + .addEventListener("click", processModalClick); + }); if ("ontouchstart" in window) { // Disable tooltips on smartphones: - document.getElementsByClassName("tooltip").forEach(elt => { + document.querySelectorAll("#aboveBoard .tooltip").forEach(elt => { elt.classList.remove("tooltip"); }); } @@ -757,7 +758,7 @@ export default { drawSent: this.drawOffer == "sent", rematchSent: this.rematchOffer == "sent", score: this.game.score, - score: this.game.scoreMsg, + scoreMsg: this.game.scoreMsg, movesCount: L, initime: this.game.initime[1 - myIdx] //relevant only if I played }; @@ -937,14 +938,9 @@ export default { if (game.score == "*") { // Set clocks + initime game.initime = [0, 0]; - if (L >= 1) { - const gameLastupdate = game.moves[L-1].played; - game.initime[L % 2] = gameLastupdate; - if (L >= 2) { - game.clocks[L % 2] = - tc.mainTime - (Date.now() - gameLastupdate) / 1000; - } - } + if (L >= 1) game.initime[L % 2] = game.moves[L-1].played; + // NOTE: game.clocks shouldn't be computed right now: + // job will be done in re_setClocks() called soon below. } // Sort chat messages from newest to oldest game.chats.sort((c1, c2) => { @@ -1040,11 +1036,8 @@ export default { }, game, ); - if (this.gameIsLoading) - // Re-load game because we missed some moves: - // artificially reset BaseGame (required if moves arrived in wrong order) - this.$refs["basegame"].re_setVariables(); - else { + this.$refs["basegame"].re_setVariables(this.game); + if (!this.gameIsLoading) { // Initial loading: this.gotMoveIdx = game.moves.length - 1; // If we arrive here after 'nextGame' action, the board might be hidden