Fix parseInt() usage, rename Doubleorda --> Ordamirror, implement Clorange variant
[vchess.git] / client / src / utils / squareId.js
1 // Get the identifier of a HTML square from its numeric coordinates o.x,o.y.
2 export function getSquareId(o) {
3 // NOTE: a separator is required to allow any size of board
4 return "sq-" + o.x + "-" + o.y;
5 }
6
7 // Inverse function
8 export function getSquareFromId(id) {
9 const idParts = id.split("-");
10 return [parseInt(idParts[1], 10), parseInt(idParts[2], 10)];
11 }