+ focusBg: function() {
+ document.getElementById("baseGame").focus();
+ },
+ adjustBoard: function() {
+ const boardContainer = document.getElementById("boardContainer");
+ if (!boardContainer) return; //no board on page
+ const k = document.getElementById("boardSize").value;
+ const movesWidth = window.innerWidth >= 768 ? 280 : 0;
+ const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary...
+ // Value of 0 is board min size; 100 is window.width [- movesWidth]
+ const boardSize =
+ minBoardWidth +
+ (k * (window.innerWidth - (movesWidth + minBoardWidth))) / 100;
+ localStorage.setItem("boardSize", boardSize);
+ boardContainer.style.width = boardSize + "px";
+ document.getElementById("gameContainer").style.width =
+ boardSize + movesWidth + "px";
+ },
+ 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;
+ }
+ },
+ handleScroll: function(e) {
+ // NOTE: since game.mode=="analyze" => no score, next condition is enough
+ if (this.game.score != "*") {
+ e.preventDefault();
+ if (e.deltaY < 0) this.undo();
+ else if (e.deltaY > 0) this.play();
+ }
+ },
+ showRules: function() {
+ //this.$router.push("/variants/" + this.game.vname);
+ window.open("#/variants/" + this.game.vname, "_blank"); //better
+ },