X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=fa5a86d63cb537af5e892c4f736d6698a0f95076;hb=98f149990956bca9ced09c22b29a37ab849b9896;hp=0d7a4ee90b1dd1ceb3ec706ffd82ddaa00677403;hpb=07052665845283c65b50a76537669d0602ba436b;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 0d7a4ee9..fa5a86d6 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -97,13 +97,13 @@ main ) img(src="/images/icons/draw.svg") button.tooltip( - v-if="!!game.mycolor" + v-show="!!game.mycolor" @click="abortGame()" :aria-label="st.tr['Abort']" ) img(src="/images/icons/abort.svg") button.tooltip( - v-if="!!game.mycolor" + v-show="!!game.mycolor" @click="resign()" :aria-label="st.tr['Resign']" ) @@ -270,12 +270,6 @@ export default { .addEventListener("click", processModalClick); } ); - if ("ontouchstart" in window) { - // Disable tooltips on smartphones: - document.querySelectorAll("#aboveBoard .tooltip").forEach(elt => { - elt.classList.remove("tooltip"); - }); - } }, beforeDestroy: function() { this.cleanBeforeDestroy(); @@ -815,8 +809,7 @@ export default { GameStorage.update(this.gameRef, { drawOffer: "" }); } } - this.$refs["basegame"].play( - movePlus.move, "received", null, true); + this.$refs["basegame"].play(movePlus.move, "received"); this.game.clocks[moveColIdx] = movePlus.clock; this.processMove( movePlus.move, @@ -883,6 +876,8 @@ export default { this.$router.push("/game/" + gameInfo.id); } else { this.rematchId = gameInfo.id; + document.getElementById("modalRules").checked = false; + document.getElementById("modalScore").checked = false; document.getElementById("modalRematch").checked = true; } break; @@ -945,7 +940,7 @@ export default { this.game.clocks[oppIdx] = data.clock; if (data.movesCount > L) { // Just got last move from him - this.$refs["basegame"].play(data.lastMove, "received", null, true); + this.$refs["basegame"].play(data.lastMove, "received"); this.processMove(data.lastMove); } else { if (!!this.clockUpdate) clearInterval(this.clockUpdate); @@ -1212,6 +1207,19 @@ export default { }, game ); + if ("ontouchstart" in window) { + // TODO: I don't like this timeout, but $nextTick() fails, + // and in mounted() hook that fails too. + setTimeout( + () => { + // Disable tooltips on smartphones: + document.querySelectorAll("#aboveBoard .tooltip").forEach(elt => { + elt.classList.remove("tooltip"); + }); + }, + 750 + ); + } this.$refs["basegame"].re_setVariables(this.game); if (!this.gameIsLoading) { // Initial loading: @@ -1243,21 +1251,21 @@ export default { await import("@/variants/" + game.vname + ".js") .then((vModule) => { window.V = vModule[game.vname + "Rules"]; - // (AJAX) Request to get rules content (plain text, HTML) - this.rulesContent = - require( - "raw-loader!@/translations/rules/" + - game.vname + "/" + - this.st.lang + ".pug" - ) - // Next two lines fix a weird issue after last update (2019-11) - .replace(/\\n/g, " ") - .replace(/\\"/g, '"') - .replace('module.exports = "', "") - .replace(/"$/, "") - .replace(/(fen:)([^:]*):/g, replaceByDiag); this.loadGame(game, callback); }); + // (AJAX) Request to get rules content (plain text, HTML) + this.rulesContent = + require( + "raw-loader!@/translations/rules/" + + game.vname + "/" + + this.st.lang + ".pug" + ) + // Next two lines fix a weird issue after last update (2019-11) + .replace(/\\n/g, " ") + .replace(/\\"/g, '"') + .replace('module.exports = "', "") + .replace(/"$/, "") + .replace(/(fen:)([^:]*):/g, replaceByDiag); }, // 3 cases for loading a game: // - from indexedDB (running or completed live game I play) @@ -1564,8 +1572,18 @@ export default { // In corr games, callback to change page only after score is set: gameOver: function(score, scoreMsg, callback) { this.game.score = score; + if ("ontouchstart" in window) { + this.$nextTick(() => { + // Disable tooltips on smartphones + // (might be required for rematch button at least): + document.querySelectorAll("#aboveBoard .tooltip").forEach(elt => { + elt.classList.remove("tooltip"); + }); + }); + } if (!scoreMsg) scoreMsg = getScoreMessage(score); this.game.scoreMsg = scoreMsg; + document.getElementById("modalRules").checked = false; // Display result in a un-missable way: document.getElementById("modalScore").checked = true; this.$set(this.game, "scoreMsg", scoreMsg); @@ -1610,19 +1628,22 @@ export default {