]> git.sesse.net Git - remoteglot/commitdiff
Cheaper createId().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 27 Dec 2022 17:08:42 +0000 (18:08 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 27 Dec 2022 17:08:42 +0000 (18:08 +0100)
www/js/chessboard-0.3.0.js

index b97961720e66dbd17c34b88be360c10b60883e8d..477d778d7562ba81e6726159df84ae4d7548a777 100644 (file)
@@ -259,12 +259,9 @@ var BOARD_BORDER_SIZE = 2,
 // 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) {