X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fboard.js;h=5a75f298be6655545c157c517a0114aa41ed5b86;hp=0399410f5049f39b3b5038200ead5db38e4bd60f;hb=582df3497b0f91dd4b645386a059eac9e98da1bb;hpb=59d58d7da742c937bca80c2102c2e72cc7d6e840 diff --git a/public/javascripts/components/board.js b/public/javascripts/components/board.js index 0399410f..5a75f298 100644 --- a/public/javascripts/components/board.js +++ b/public/javascripts/components/board.js @@ -142,7 +142,7 @@ Vue.component('my-board', { 'incheck': showLight && incheckSq[ci][cj], }, attrs: { - id: this.getSquareId({x:ci,y:cj}), + id: getSquareId({x:ci,y:cj}), }, }, elems @@ -161,7 +161,7 @@ Vue.component('my-board', { myReservePiecesArray.push(h('div', { 'class': {'board':true, ['board'+sizeY]:true}, - attrs: { id: this.getSquareId({x:sizeX+shiftIdx,y:i}) } + attrs: { id: getSquareId({x:sizeX+shiftIdx,y:i}) } }, [ h('img', @@ -185,7 +185,7 @@ Vue.component('my-board', { oppReservePiecesArray.push(h('div', { 'class': {'board':true, ['board'+sizeY]:true}, - attrs: { id: this.getSquareId({x:sizeX+(1-shiftIdx),y:i}) } + attrs: { id: getSquareId({x:sizeX+(1-shiftIdx),y:i}) } }, [ h('img', @@ -251,16 +251,6 @@ Vue.component('my-board', { ); }, methods: { - // Get the identifier of a HTML square from its numeric coordinates o.x,o.y. - getSquareId: function(o) { - // NOTE: a separator is required to allow any size of board - return "sq-" + o.x + "-" + o.y; - }, - // Inverse function - getSquareFromId: function(id) { - let idParts = id.split('-'); - return [parseInt(idParts[1]), parseInt(idParts[2])]; - }, mousedown: function(e) { e = e || window.event; let ingame = false; @@ -291,7 +281,7 @@ Vue.component('my-board', { this.selectedPiece.style.top = 0; this.selectedPiece.style.display = "inline-block"; this.selectedPiece.style.zIndex = 3000; - const startSquare = this.getSquareFromId(e.target.parentNode.id); + const startSquare = getSquareFromId(e.target.parentNode.id); this.possibleMoves = []; const color = this.mode=="analyze" || this.gameOver ? this.vr.turn @@ -337,7 +327,7 @@ Vue.component('my-board', { return; } // OK: process move attempt - let endSquare = this.getSquareFromId(landing.id); + let endSquare = getSquareFromId(landing.id); let moves = this.findMatchingMoves(endSquare); this.possibleMoves = []; if (moves.length > 1)