From 1f9fb72fae70416447847476447bfbf2c2f27ee1 Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Mon, 24 Aug 2026 12:44:48 -0400 Subject: [PATCH] extract window.uid() to separate file, update shots.js and script tags to v=7 --- .../META-INF/resources/static/js/shots.js | 7 ++---- .../META-INF/resources/static/js/uid.js | 6 +++++ .../templates/PageResource/personajes.html | 1 + .../templates/PageResource/ventas.html | 22 ++++++++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 src/main/resources/META-INF/resources/static/js/uid.js diff --git a/src/main/resources/META-INF/resources/static/js/shots.js b/src/main/resources/META-INF/resources/static/js/shots.js index 8528985..01a9470 100644 --- a/src/main/resources/META-INF/resources/static/js/shots.js +++ b/src/main/resources/META-INF/resources/static/js/shots.js @@ -1,9 +1,6 @@ window.shots = { generateUid() { - if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { - return crypto.randomUUID(); - } - return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); + return window.uid(); }, WEIGHTS: { Soulshot: { D: 3, C: 3, B: 2, A: 2, S: 2 }, @@ -84,7 +81,7 @@ window.shots = { const grado = m[2].toUpperCase(); const cantidad = parseInt(m[3].replace(/[.,]/g, ''), 10); if (!this.WEIGHTS[tipo]?.[grado]) continue; - parsed.push({ uid: this.generateUid(), tipo, grado, cantidad }); + parsed.push({ uid: window.uid(), tipo, grado, cantidad }); } return parsed; }, diff --git a/src/main/resources/META-INF/resources/static/js/uid.js b/src/main/resources/META-INF/resources/static/js/uid.js new file mode 100644 index 0000000..a496ec5 --- /dev/null +++ b/src/main/resources/META-INF/resources/static/js/uid.js @@ -0,0 +1,6 @@ +window.uid = function () { + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } + return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); +}; diff --git a/src/main/resources/templates/PageResource/personajes.html b/src/main/resources/templates/PageResource/personajes.html index a248b67..b2bc5dc 100644 --- a/src/main/resources/templates/PageResource/personajes.html +++ b/src/main/resources/templates/PageResource/personajes.html @@ -205,6 +205,7 @@ + diff --git a/src/main/resources/templates/PageResource/ventas.html b/src/main/resources/templates/PageResource/ventas.html index a1501c5..a97d628 100644 --- a/src/main/resources/templates/PageResource/ventas.html +++ b/src/main/resources/templates/PageResource/ventas.html @@ -227,11 +227,12 @@

- - - - - + + + + + +