X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBaseGame.vue;h=5c82b0b1573975e88df06dd4cf0089fb5d1e7a3d;hb=72ccbd6730241771e6ba86b6a5b62597b4c7e2f4;hp=fad599b37c2727c5067bdb81afd85fbc197cfbd4;hpb=06e79b0783d6e9962ca6b2a25f62d46f46fa5c8b;p=vchess.git diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue index fad599b3..5c82b0b1 100644 --- a/client/src/components/BaseGame.vue +++ b/client/src/components/BaseGame.vue @@ -1,27 +1,27 @@ @@ -88,6 +88,32 @@ export default { this.re_setVariables(); }, methods: { + focusBg: function() { + // TODO: small blue border appears... + document.getElementById("baseGame").focus(); + }, + handleKeys: function(e) { + if ([32,37,38,39,40].includes(e.keyCode)) + e.preventDefault(); + switch (e.keyCode) + { + case 37: + this.undo(); + break; + case 39: + this.play(); + break; + case 38: + this.gotoBegin(); + break; + case 40: + this.gotoEnd(); + break; + case 32: + this.flip(); + break; + } + }, re_setVariables: function() { this.endgameMessage = ""; this.orientation = this.game.mycolor || "w"; //default orientation for observed games @@ -299,8 +325,16 @@ export default { }, gotoBegin: function() { this.vr.re_init(this.game.fenStart); - this.cursor = -1; - this.lastMove = null; + if (this.moves.length > 0 && this.moves[0].notation == "...") + { + this.cursor = 0; + this.lastMove = this.moves[0]; + } + else + { + this.cursor = -1; + this.lastMove = null; + } }, gotoEnd: function() { this.gotoMove(this.moves.length-1); @@ -311,3 +345,29 @@ export default { }, }; + +