TODO: where to put template: in views/ or components/?
[vchess.git] / client / client_OLD / javascripts / utils / squareId.js
CommitLineData
582df349
BA
1// Get the identifier of a HTML square from its numeric coordinates o.x,o.y.
2function 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
a3ab5fdb
BA
9function getSquareFromId(id)
10{
11 const idParts = id.split('-');
582df349
BA
12 return [parseInt(idParts[1]), parseInt(idParts[2])];
13}