X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FAnalyze.vue;h=0c23a28b7f87959a180251237c57dd78403f9434;hb=0e16cb26f6380f57f1079ece9bdb654243073bde;hp=a1352f7c859951c1c246176253d86470a89007d7;hpb=63ca2b89cfe577efd168c6b2e26750cb01b66d64;p=vchess.git diff --git a/client/src/views/Analyze.vue b/client/src/views/Analyze.vue index a1352f7c..0c23a28b 100644 --- a/client/src/views/Analyze.vue +++ b/client/src/views/Analyze.vue @@ -2,7 +2,9 @@ main .row .col-sm-12 - #fenDiv(v-if="!!vr") {{ vr.getFen() }} + #fenDiv + input#fen(v-model="curFen" @input="adjustFenSize") + button(@click="gotoFen") Go .row .col-sm-12.col-md-10.col-md-offset-1 BaseGame(:game="game" :vr="vr" ref="basegame") @@ -31,6 +33,7 @@ export default { mode: "analyze" }, vr: null, //"variant rules" object initialized from FEN + curFen: "", //people: [], //players + observers //TODO later: interactive analyze... }; }, @@ -40,27 +43,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("Please, 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); - // fenStart initialized in the end, after definition of V, - // because it triggers a reset on BaseGame component. 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(); + }, }, }; -