]> git.sesse.net Git - remoteglot/blobdiff - www/js/chessboard-0.3.0.js
Cheaper createId().
[remoteglot] / www / js / chessboard-0.3.0.js
index ff2bf0384d686c2a6a2f83a9aa950e59dfbcacbe..477d778d7562ba81e6726159df84ae4d7548a777 100644 (file)
@@ -243,8 +243,7 @@ var widget = {};
 // Stateful
 //------------------------------------------------------------------------------
 
-var ANIMATION_HAPPENING = false,
-  BOARD_BORDER_SIZE = 2,
+var BOARD_BORDER_SIZE = 2,
   CURRENT_ORIENTATION = 'white',
   CURRENT_POSITION = {},
   SQUARE_SIZE,
@@ -260,12 +259,9 @@ var ANIMATION_HAPPENING = false,
 // 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) {
@@ -800,8 +796,6 @@ function fadeOut(pieces, onFinish) {
 
 // execute an array of animations
 function doAnimations(a, oldPos, newPos) {
-  ANIMATION_HAPPENING = true;
-
   var numFinished = 0;
   function onFinish(e) {
     if (e && e.target) {
@@ -814,7 +808,6 @@ function doAnimations(a, oldPos, newPos) {
     if (numFinished !== a.length) return;
 
     drawPositionInstant();
-    ANIMATION_HAPPENING = false;
 
     // run their onMoveEnd function
     if (cfg.hasOwnProperty('onMoveEnd') === true &&