Commit | Line | Data |
---|---|---|
582df349 | 1 | // Get the identifier of a HTML square from its numeric coordinates o.x,o.y. |
6808d7a1 | 2 | export function getSquareId(o) { |
dac39588 | 3 | // NOTE: a separator is required to allow any size of board |
6808d7a1 | 4 | return "sq-" + o.x + "-" + o.y; |
582df349 BA |
5 | } |
6 | ||
7 | // Inverse function | |
6808d7a1 BA |
8 | export function getSquareFromId(id) { |
9 | const idParts = id.split("-"); | |
dac39588 | 10 | return [parseInt(idParts[1]), parseInt(idParts[2])]; |
582df349 | 11 | } |