extract window.uid() to separate file, update shots.js and script tags to v=7
CI / Build Native (push) Successful in 7m10s
CI / Build Native (push) Successful in 7m10s
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
window.shots = {
|
window.shots = {
|
||||||
generateUid() {
|
generateUid() {
|
||||||
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
return window.uid();
|
||||||
return crypto.randomUUID();
|
|
||||||
}
|
|
||||||
return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10);
|
|
||||||
},
|
},
|
||||||
WEIGHTS: {
|
WEIGHTS: {
|
||||||
Soulshot: { D: 3, C: 3, B: 2, A: 2, S: 2 },
|
Soulshot: { D: 3, C: 3, B: 2, A: 2, S: 2 },
|
||||||
@@ -84,7 +81,7 @@ window.shots = {
|
|||||||
const grado = m[2].toUpperCase();
|
const grado = m[2].toUpperCase();
|
||||||
const cantidad = parseInt(m[3].replace(/[.,]/g, ''), 10);
|
const cantidad = parseInt(m[3].replace(/[.,]/g, ''), 10);
|
||||||
if (!this.WEIGHTS[tipo]?.[grado]) continue;
|
if (!this.WEIGHTS[tipo]?.[grado]) continue;
|
||||||
parsed.push({ uid: this.generateUid(), tipo, grado, cantidad });
|
parsed.push({ uid: window.uid(), tipo, grado, cantidad });
|
||||||
}
|
}
|
||||||
return parsed;
|
return parsed;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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);
|
||||||
|
};
|
||||||
@@ -205,6 +205,7 @@
|
|||||||
|
|
||||||
<script src="/static/js/defaults.js?v=7"></script>
|
<script src="/static/js/defaults.js?v=7"></script>
|
||||||
<script src="/static/js/api.js?v=7"></script>
|
<script src="/static/js/api.js?v=7"></script>
|
||||||
|
<script src="/static/js/uid.js?v=7"></script>
|
||||||
<script src="/static/js/shots.js?v=7"></script>
|
<script src="/static/js/shots.js?v=7"></script>
|
||||||
<script src="/static/js/app.js?v=7"></script>
|
<script src="/static/js/app.js?v=7"></script>
|
||||||
<script defer src="/static/js/alpine.min.js?v=7"></script>
|
<script defer src="/static/js/alpine.min.js?v=7"></script>
|
||||||
|
|||||||
@@ -227,11 +227,12 @@
|
|||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="/static/js/defaults.js?v=6"></script>
|
<script src="/static/js/defaults.js?v=7"></script>
|
||||||
<script src="/static/js/api.js?v=6"></script>
|
<script src="/static/js/api.js?v=7"></script>
|
||||||
<script src="/static/js/shots.js?v=6"></script>
|
<script src="/static/js/uid.js?v=7"></script>
|
||||||
<script src="/static/js/app.js?v=6"></script>
|
<script src="/static/js/shots.js?v=7"></script>
|
||||||
<script defer src="/static/js/alpine.min.js?v=6"></script>
|
<script src="/static/js/app.js?v=7"></script>
|
||||||
|
<script defer src="/static/js/alpine.min.js?v=7"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('alpine:init', () => {
|
document.addEventListener('alpine:init', () => {
|
||||||
@@ -265,8 +266,13 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
if (!window.shots || !window.uid) {
|
||||||
|
this.error = 'Error cargando utilidades de la pagina (shots/uid). Recarga con Ctrl+Shift+R.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
await Promise.all([this.loadSales(), this.loadCharacters()]);
|
await Promise.all([this.loadSales(), this.loadCharacters()]);
|
||||||
document.addEventListener('visibilitychange', this.visibilityHandler);
|
this._boundVisibility = this.visibilityHandler.bind(this);
|
||||||
|
document.addEventListener('visibilitychange', this._boundVisibility);
|
||||||
this.tick();
|
this.tick();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -283,7 +289,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
document.removeEventListener('visibilitychange', this.visibilityHandler);
|
document.removeEventListener('visibilitychange', this._boundVisibility);
|
||||||
if (this.timer) clearTimeout(this.timer);
|
if (this.timer) clearTimeout(this.timer);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -305,7 +311,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
addItem() {
|
addItem() {
|
||||||
this.form.items.push({ uid: window.shots.generateUid(), tipo: '', grado: '', cantidad: null });
|
this.form.items.push({ uid: window.uid(), tipo: '', grado: '', cantidad: null });
|
||||||
},
|
},
|
||||||
|
|
||||||
removeItem(idx) {
|
removeItem(idx) {
|
||||||
|
|||||||
Reference in New Issue
Block a user