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