From 38312204f04624996e251fbc1d1ad21ba3c3c5b7 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 27 Dec 2022 18:08:42 +0100 Subject: [PATCH] Cheaper createId(). --- www/js/chessboard-0.3.0.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/www/js/chessboard-0.3.0.js b/www/js/chessboard-0.3.0.js index b979617..477d778 100644 --- a/www/js/chessboard-0.3.0.js +++ b/www/js/chessboard-0.3.0.js @@ -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) { -- 2.39.2