// Stateful
//------------------------------------------------------------------------------
-var ANIMATION_HAPPENING = false,
- BOARD_BORDER_SIZE = 2,
+var BOARD_BORDER_SIZE = 2,
CURRENT_ORIENTATION = 'white',
CURRENT_POSITION = {},
SQUARE_SIZE,
// JS Util Functions
//------------------------------------------------------------------------------
-// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
+let id_counter = 0;
function createId() {
- return 'xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/x/g, function(c) {
- var r = Math.random() * 16 | 0;
- return r.toString(16);
- });
+ return 'chesspiece-id-' + (id_counter++);
}
function deepCopy(thing) {
// execute an array of animations
function doAnimations(a, oldPos, newPos) {
- ANIMATION_HAPPENING = true;
-
var numFinished = 0;
function onFinish(e) {
if (e && e.target) {
if (numFinished !== a.length) return;
drawPositionInstant();
- ANIMATION_HAPPENING = false;
// run their onMoveEnd function
if (cfg.hasOwnProperty('onMoveEnd') === true &&