From 2398a17dda114096cc7d1c8c4747877c6e5672c4 Mon Sep 17 00:00:00 2001 From: Joaquin Pereyra Date: Sat, 5 Jul 2025 11:27:52 -0300 Subject: [PATCH] REFACTOR: remove unnecessary handlebars --- module/helpers/handlebarsHelper.mjs | 91 ------------------- templates/characterCreation/tabs/setup.hbs | 2 +- templates/levelup/tabs/selections.hbs | 2 +- templates/levelup/tabs/summary.hbs | 4 +- .../sheets/actors/companion/tempMain.hbs | 2 +- 5 files changed, 5 insertions(+), 96 deletions(-) diff --git a/module/helpers/handlebarsHelper.mjs b/module/helpers/handlebarsHelper.mjs index 6200b690..99c1ec84 100644 --- a/module/helpers/handlebarsHelper.mjs +++ b/module/helpers/handlebarsHelper.mjs @@ -7,49 +7,11 @@ export default class RegisterHandlebarsHelpers { join: this.join, add: this.add, subtract: this.subtract, - objectSelector: this.objectSelector, includes: this.includes, - debug: this.debug, - signedNumber: this.signedNumber, - length: this.length, - switch: this.switch, case: this.case, - eq: this.eq, - ne: this.ne, - lt: this.lt, - gt: this.gt, - lte: this.lte, - gte: this.gte, - and: this.and, - or: this.or }); } - static eq(v1, v2) { - return v1 === v2; - } - static ne(v1, v2) { - return v1 !== v2; - } - static lt(v1, v2) { - return v1 < v2; - } - static gt(v1, v2) { - return v1 > v2; - } - static lte(v1, v2) { - return v1 <= v2; - } - static gte(v1, v2) { - return v1 >= v2; - } - static and() { - return Array.prototype.every.call(arguments, Boolean); - } - static or() { - return Array.prototype.slice.call(arguments, 0, -1).some(Boolean); - } - static times(nr, block) { var accum = ''; for (var i = 0; i < nr; ++i) accum += block.fn(i); @@ -72,59 +34,11 @@ export default class RegisterHandlebarsHelpers { return (Number.isNaN(aNum) ? 0 : aNum) - (Number.isNaN(bNum) ? 0 : bNum); } - static objectSelector(options) { - let { title, values, titleFontSize, ids, style } = options.hash; - - const titleLength = getWidthOfText(title, titleFontSize, true, true); - const margins = 12; - - const buttons = options.fn(); - const nrButtons = Math.max($(buttons).length - 1, 1); - const iconWidth = 26; - - const texts = values - .reduce((acc, x, index) => { - if (x) { - acc.push( - `${x}` - ); - } - - return acc; - }, []) - .join(' '); - - const html = `
-
- ${title} -
- ${texts} -
- ${buttons} -
-
- `; - - return new Handlebars.SafeString(html); - } static includes(list, item) { return list.includes(item); } - static signedNumber(number) { - return number >= 0 ? `+${number}` : number; - } - - static length(obj) { - return Object.keys(obj).length; - } - - static switch(value, options) { - this.switch_value = value; - this.switch_break = false; - return options.fn(this); - } static case(value, options) { if (value == this.switch_value) { @@ -132,9 +46,4 @@ export default class RegisterHandlebarsHelpers { return options.fn(this); } } - - static debug(a) { - console.log(a); - return a; - } } diff --git a/templates/characterCreation/tabs/setup.hbs b/templates/characterCreation/tabs/setup.hbs index 4d6e638c..6dd04345 100644 --- a/templates/characterCreation/tabs/setup.hbs +++ b/templates/characterCreation/tabs/setup.hbs @@ -74,7 +74,7 @@ {{#each experience.values as |experience id|}}
-
{{signedNumber this.value}}
+
{{numberFormat this.value sign=true}}
{{/each}} diff --git a/templates/levelup/tabs/selections.hbs b/templates/levelup/tabs/selections.hbs index d397fa80..9d1d00b8 100644 --- a/templates/levelup/tabs/selections.hbs +++ b/templates/levelup/tabs/selections.hbs @@ -12,7 +12,7 @@
-
{{signedNumber this.modifier}}
+
{{numberFormat this.modifier sign=true}}
{{#if this.name}}{{/if}} diff --git a/templates/levelup/tabs/summary.hbs b/templates/levelup/tabs/summary.hbs index 4ed4438f..dc7e2a47 100644 --- a/templates/levelup/tabs/summary.hbs +++ b/templates/levelup/tabs/summary.hbs @@ -48,7 +48,7 @@
{{localize "DAGGERHEART.Application.LevelUp.summary.newExperiences"}}
{{#each this.achievements.experiences.values}} -
{{this.name}} {{signedNumber this.modifier}}
+
{{this.name}} {{numberFormat this.modifier sign=true}}
{{/each}}
@@ -125,7 +125,7 @@
{{localize "DAGGERHEART.Application.LevelUp.summary.experienceIncreases"}}
{{#each this.advancements.experiences}} -
{{this.name}} {{signedNumber this.modifier}}
+
{{this.name}} {{numberFormat this.modifier sign=true}}
{{/each}}
diff --git a/templates/sheets/actors/companion/tempMain.hbs b/templates/sheets/actors/companion/tempMain.hbs index 810d48db..f1f315ed 100644 --- a/templates/sheets/actors/companion/tempMain.hbs +++ b/templates/sheets/actors/companion/tempMain.hbs @@ -17,7 +17,7 @@ {{#each source.system.experiences as |experience key|}}
-
{{signedNumber experience.value}}
+
{{numberFormat experience.value sign=true}}
{{/each}}