X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FAnalyze.vue;h=af6bface160a89ea8a98975be72984b03c9035bc;hb=602d6befd30793111d3fda6e733f73e08d8b7a30;hp=d1b669ecb164b2fa5d59587900e48e4a6c83de56;hpb=7aa548e72ba8a4af4e2c7f63e7723ad10d2cd3a4;p=vchess.git diff --git a/client/src/views/Analyze.vue b/client/src/views/Analyze.vue index d1b669ec..af6bface 100644 --- a/client/src/views/Analyze.vue +++ b/client/src/views/Analyze.vue @@ -1,5 +1,10 @@ @@ -26,6 +31,7 @@ export default { mode: "analyze" }, vr: null, //"variant rules" object initialized from FEN + curFen: "", //people: [], //players + observers //TODO later: interactive analyze... }; }, @@ -35,24 +41,51 @@ export default { this.gameRef.vname = to.params["vname"]; this.loadGame(); }, + "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") + this.initialize(this.loadGame); + else + { + alert(this.st.tr["Analyze in Dark mode makes no sense!"]); + history.back(); //or this.$router.go(-1) + } }, methods: { - loadGame: async function() { + initialize: async function(callback) { + // Obtain VariantRules object + const vModule = await import("@/variants/" + this.gameRef.vname + ".js"); + window.V = vModule.VariantRules; + callback(); + }, + 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); //TODO: Vue3... + }, + adjustFenSize: function() { + let fenInput = document.getElementById("fen"); + fenInput.style.width = this.curFen.length + "ch"; + }, + gotoFen: function() { + this.gameRef.fen = this.curFen; + this.loadGame(); }, }, }; -