From: Benjamin Auder Date: Tue, 18 Feb 2020 17:02:44 +0000 (+0100) Subject: Some more cleaning + fixes X-Git-Url: https://git.auder.net/img/app_dev.php/js/current/git-logo.png?a=commitdiff_plain;h=910d631b73cad5ffef1b4461157b704e7e7057d8;p=vchess.git Some more cleaning + fixes --- diff --git a/client/package.json b/client/package.json index 88feedb9..172b5c4c 100644 --- a/client/package.json +++ b/client/package.json @@ -64,13 +64,13 @@ "flatTernaryExpressions": true } ], - "no-else-return" : [ + "no-else-return": [ 1, { "allowElseIf": false } ], - "semi" : [1, "always"] + "semi": [1, "always"] } }, "postcss": { diff --git a/client/src/App.vue b/client/src/App.vue index 9879e275..9c724e76 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -25,19 +25,22 @@ router-link(to="/problems") | {{ st.tr["Problems"] }} #rightMenu - .clickable(onClick="doClick('modalUser')") + .clickable(onClick="window.doClick('modalUser')") | {{ st.user.id > 0 ? (st.user.name || "@nonymous") : "Login" }} - .clickable(onClick="doClick('modalSettings')") + .clickable(onClick="window.doClick('modalSettings')") | {{ st.tr["Settings"] }} - .clickable#flagContainer(onClick="doClick('modalLang')") - img(v-if="!!st.lang" :src="flagImage") + .clickable#flagContainer(onClick="window.doClick('modalLang')") + img( + v-if="!!st.lang" + :src="flagImage" + ) router-view .row .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 footer router-link.menuitem(to="/about") {{ st.tr["About"] }} router-link.menuitem(to="/news") {{ st.tr["News"] }} - p.clickable(onClick="doClick('modalContact')") + p.clickable(onClick="window.doClick('modalContact')") | {{ st.tr["Contact"] }} diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 056f4774..42d9bdc8 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -4,8 +4,8 @@ import { ArrayFun } from "@/utils/array"; import { randInt, shuffle } from "@/utils/alea"; +// class "PiPo": Piece + Position export const PiPo = class PiPo { - //Piece+Position // o: {piece[p], color[c], posX[x], posY[y]} constructor(o) { this.p = o.p; @@ -15,7 +15,6 @@ export const PiPo = class PiPo { } }; -// TODO: for animation, moves should contains "moving" and "fading" maybe... export const Move = class Move { // o: {appear, vanish, [start,] [end,]} // appear,vanish = arrays of PiPo diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index b2dd4a72..f4603d6b 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -52,7 +52,7 @@ div#baseGame( #downloadDiv(v-if="game.vname!='Dark' || game.score!='*'") a#download(href="#") button(@click="download()") {{ st.tr["Download"] }} PGN - button(onClick="doClick('modalAdjust')") ⤢ + button(onClick="window.doClick('modalAdjust')") ⤢ button( v-if="game.vname!='Dark' && game.mode!='analyze'" @click="analyzePosition()" @@ -169,7 +169,6 @@ export default { }, methods: { focusBg: function() { - // NOTE: small blue border appears... document.getElementById("baseGame").focus(); }, adjustBoard: function() { @@ -259,9 +258,9 @@ export default { this.game.vname + "/?fen=" + this.vr.getFen().replace(/ /g, "_"); + // Open in same tab in live games (against cheating) if (this.game.type == "live") this.$router.push(newUrl); - //open in same tab: against cheating... - else window.open("#" + newUrl); //open in a new tab: more comfortable + else window.open("#" + newUrl); }, download: function() { const content = this.getPgn(); @@ -305,9 +304,6 @@ export default { }, animateMove: function(move, callback) { let startSquare = document.getElementById(getSquareId(move.start)); - // TODO: error "flush nextTick callbacks" when observer reloads page: - // this late check is not a fix! - if (!startSquare) return; let endSquare = document.getElementById(getSquareId(move.end)); let rectStart = startSquare.getBoundingClientRect(); let rectEnd = endSquare.getBoundingClientRect(); @@ -318,9 +314,6 @@ export default { let movingPiece = document.querySelector( "#" + getSquareId(move.start) + " > img.piece" ); - if (!movingPiece) - //TODO: shouldn't happen - return; // HACK for animation (with positive translate, image slides "under background") // Possible improvement: just alter squares on the piece's way... const squares = document.getElementsByClassName("board"); @@ -330,7 +323,7 @@ export default { } movingPiece.style.transform = "translate(" + translation.x + "px," + translation.y + "px)"; - movingPiece.style.transitionDuration = "0.2s"; + movingPiece.style.transitionDuration = "0.25s"; movingPiece.style.zIndex = "3000"; setTimeout(() => { for (let i = 0; i < squares.length; i++) @@ -353,7 +346,8 @@ export default { return; } const doPlayMove = () => { - if (!!receive && this.cursor < this.moves.length - 1) this.gotoEnd(); //required to play the move + // To play a move, cursor must be at the end of the game: + if (!!receive && this.cursor < this.moves.length - 1) this.gotoEnd(); if (navigate) { if (this.cursor == this.moves.length - 1) return; //no more moves move = this.moves[this.cursor + 1]; @@ -433,6 +427,7 @@ export default { + + diff --git a/client/src/components/Settings.vue b/client/src/components/Settings.vue index e5a9d9c7..117133d1 100644 --- a/client/src/components/Settings.vue +++ b/client/src/components/Settings.vue @@ -1,17 +1,26 @@ - - diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index a0e264ed..9a971006 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -1,27 +1,51 @@ - - diff --git a/client/src/views/MyGames.vue b/client/src/views/MyGames.vue index 01b5264d..22f804dc 100644 --- a/client/src/views/MyGames.vue +++ b/client/src/views/MyGames.vue @@ -3,12 +3,20 @@ main .row .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 .button-group - button.tabbtn#liveGames(@click="setDisplay('live',$event)") {{ st.tr["Live games"] }} - button.tabbtn#corrGames(@click="setDisplay('corr',$event)") {{ st.tr["Correspondance games"] }} - GameList(v-show="display=='live'" :games="liveGames" - @show-game="showGame") - GameList(v-show="display=='corr'" :games="corrGames" - @show-game="showGame") + button.tabbtn#liveGames(@click="setDisplay('live',$event)") + | {{ st.tr["Live games"] }} + button.tabbtn#corrGames(@click="setDisplay('corr',$event)") + | {{ st.tr["Correspondance games"] }} + GameList( + v-show="display=='live'" + :games="liveGames" + @show-game="showGame" + ) + GameList( + v-show="display=='corr'" + :games="corrGames" + @show-game="showGame" + )