X-Git-Url: https://git.auder.net/assets/icon_infos.svg?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FAnalyze.vue;h=96ecdad9081ff84712ad6bc4b70ca7b0964ba538;hb=f44fd3bf754c113aa6b9ab241cbf24933877ae31;hp=d1b669ecb164b2fa5d59587900e48e4a6c83de56;hpb=7aa548e72ba8a4af4e2c7f63e7723ad10d2cd3a4;p=vchess.git
diff --git a/client/src/views/Analyze.vue b/client/src/views/Analyze.vue
index d1b669ec..96ecdad9 100644
--- a/client/src/views/Analyze.vue
+++ b/client/src/views/Analyze.vue
@@ -1,5 +1,10 @@
main
+ .row
+ .col-sm-12
+ #fenDiv
+ input#fen(v-model="curFen" @input="adjustFenSize")
+ button(@click="gotoFen") {{ st.tr["Go"] }}
BaseGame(:game="game" :vr="vr" ref="basegame")
@@ -26,33 +31,60 @@ export default {
mode: "analyze"
},
vr: null, //"variant rules" object initialized from FEN
+ curFen: "",
//people: [], //players + observers //TODO later: interactive analyze...
};
},
watch: {
- "$route": function(to, from) {
- this.gameRef.fen = to.query["fen"].replace(/_/g, " ");
- this.gameRef.vname = to.params["vname"];
- this.loadGame();
+ // NOTE: no watcher for $route change, because if fenStart doesn't change
+ // then it doesn't trigger BaseGame.re_init() and the result is weird.
+ "vr.movesCount": function(fen) {
+ this.curFen = this.vr.getFen();
+ this.adjustFenSize();
},
},
created: function() {
- this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
this.gameRef.vname = this.$route.params["vname"];
- this.loadGame();
+ if (this.gameRef.vname == "Dark")
+ {
+ alert(this.st.tr["Analyze in Dark mode makes no sense!"]);
+ history.back(); //or this.$router.go(-1)
+ }
+ else
+ {
+ this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
+ this.initialize();
+ }
},
methods: {
- loadGame: async function() {
+ initialize: async function() {
+ // Obtain VariantRules object
+ const vModule = await import("@/variants/" + this.gameRef.vname + ".js");
+ window.V = vModule.VariantRules;
+ this.loadGame();
+ },
+ loadGame: function() {
+ // NOTE: no need to set score (~unused)
this.game.vname = this.gameRef.vname;
this.game.fen = this.gameRef.fen;
- const vModule = await import("@/variants/" + this.game.vname + ".js");
- window.V = vModule.VariantRules;
+ this.curFen = this.game.fen;
+ this.adjustFenSize();
this.vr = new V(this.game.fen);
+ this.$set(this.game, "fenStart", this.gameRef.fen);
+ },
+ adjustFenSize: function() {
+ let fenInput = document.getElementById("fen");
+ fenInput.style.width = this.curFen.length + "ch";
+ },
+ gotoFen: function() {
+ this.gameRef.fen = this.curFen;
+ this.loadGame();
},
},
};
-