- analyzePosition: function() {
- let newUrl =
- "/analyse/" +
- this.game.vname +
- "/?fen=" +
- this.vr.getFen().replace(/ /g, "_");
- if (this.game.mycolor)
- newUrl += "&side=" + this.game.mycolor;
- // Open in same tab in live games (against cheating)
- if (this.game.type == "live") this.$router.push(newUrl);
- else window.open("#" + newUrl);
+ toggleAnalyze: function() {
+ // Freeze while choices are shown (and autoplay has priority)
+ if (this.$refs["board"].choices.length > 0 || this.autoplay) return;
+ if (this.mode != "analyze") {
+ // Enter analyze mode:
+ if (this.inMultimove) this.cancelCurrentMultimove();
+ this.gameMode = this.mode; //was not 'analyze'
+ this.mode = "analyze";
+ this.gameCursor = this.cursor;
+ this.gameMoves = JSON.parse(JSON.stringify(this.moves));
+ document.getElementById("analyzeBtn").classList.add("active");
+ }
+ else {
+ // Exit analyze mode:
+ this.mode = this.gameMode ;
+ this.cursor = this.gameCursor;
+ this.moves = this.gameMoves;
+ let fen = this.game.fenStart;
+ if (this.cursor >= 0) {
+ let mv = this.moves[this.cursor];
+ if (!Array.isArray(mv)) mv = [mv];
+ fen = mv[mv.length-1].fen;
+ }
+ this.vr = new V(fen);
+ this.inMultimove = false; //in case of
+ this.$refs["board"].resetCurrentAttempt(); //also in case of
+ this.incheck = this.vr.getCheckSquares();
+ if (this.cursor >= 0) this.lastMove = this.moves[this.cursor];
+ else this.lastMove = null;
+ document.getElementById("analyzeBtn").classList.remove("active");
+ }