.row
.col-sm-12
.text-center
- input#fen(v-model="curFen" @input="adjustFenSize()")
- button(@click="gotoFen()") {{ st.tr["Go"] }}
- BaseGame(:game="game" :vr="vr" ref="basegame")
+ input#fen(
+ v-model="curFen"
+ @input="adjustFenSize(); tryGotoFen()"
+ )
+ BaseGame(
+ :game="game"
+ :vr="vr"
+ )
</template>
<script>
import BaseGame from "@/components/BaseGame.vue";
import { store } from "@/store";
-import { ArrayFun } from "@/utils/array";
export default {
- name: 'my-analyse',
+ name: "my-analyse",
components: {
- BaseGame,
+ BaseGame
},
// gameRef: to find the game in (potentially remote) storage
data: function() {
return {
st: store.state,
- gameRef: { //given in URL (rid = remote ID)
+ gameRef: {
+ //given in URL (rid = remote ID)
vname: "",
fen: ""
},
game: {
- players:[{name:"Analyse"},{name:"Analyse"}],
+ players: [{ name: "Analyse" }, { name: "Analyse" }],
mode: "analyze"
},
vr: null, //"variant rules" object initialized from FEN
- curFen: "",
- //people: [], //players + observers //TODO later: interactive analyze...
+ curFen: ""
};
},
watch: {
// 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) {
+ "vr.movesCount": function() {
this.curFen = this.vr.getFen();
this.adjustFenSize();
- },
+ }
},
created: function() {
this.gameRef.vname = this.$route.params["vname"];
- if (this.gameRef.vname == "Dark")
- {
- alert(this.st.tr["Analyse 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();
- }
+ this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
+ this.initialize();
},
methods: {
initialize: async function() {
let fenInput = document.getElementById("fen");
fenInput.style.width = this.curFen.length + "ch";
},
- gotoFen: function() {
- this.gameRef.fen = this.curFen;
- this.loadGame();
- },
- },
+ tryGotoFen: function() {
+ if (V.IsGoodFen(this.curFen))
+ {
+ this.gameRef.fen = this.curFen;
+ this.loadGame();
+ }
+ }
+ }
};
</script>