refactor: Use jQuery-wrapped HTML object for settings UI element lookups.

This commit is contained in:
CPTN Cosmo 2025-12-19 01:09:54 +01:00
parent 3612afc928
commit 44368a974f

View file

@ -97,16 +97,17 @@ Hooks.once('init', () => {
* Handle Settings UI Visibility * Handle Settings UI Visibility
*/ */
Hooks.on('renderSettingsConfig', (app, html, data) => { Hooks.on('renderSettingsConfig', (app, html, data) => {
const iconTypeSelect = html.find(`select[name="${MODULE_ID}.iconType"]`); const $html = $(html);
const themeSelect = html.find(`select[name="${MODULE_ID}.colorTheme"]`); const iconTypeSelect = $html.find(`select[name="${MODULE_ID}.iconType"]`);
const themeSelect = $html.find(`select[name="${MODULE_ID}.colorTheme"]`);
const updateVisibility = () => { const updateVisibility = () => {
const iconType = iconTypeSelect.val(); const iconType = iconTypeSelect.val();
const theme = themeSelect.val(); const theme = themeSelect.val();
// Icon Inputs // Icon Inputs
const presetGroup = html.find(`select[name="${MODULE_ID}.presetIcon"]`).closest('.form-group'); const presetGroup = $html.find(`select[name="${MODULE_ID}.presetIcon"]`).closest('.form-group');
const customIconGroup = html.find(`input[name="${MODULE_ID}.customIcon"]`).closest('.form-group'); const customIconGroup = $html.find(`input[name="${MODULE_ID}.customIcon"]`).closest('.form-group');
if (iconType === 'preset') { if (iconType === 'preset') {
presetGroup.show(); presetGroup.show();
@ -117,8 +118,8 @@ Hooks.on('renderSettingsConfig', (app, html, data) => {
} }
// Color Inputs // Color Inputs
const fullColorGroup = html.find(`input[name="${MODULE_ID}.fullColor"]`).closest('.form-group'); const fullColorGroup = $html.find(`input[name="${MODULE_ID}.fullColor"]`).closest('.form-group');
const emptyColorGroup = html.find(`input[name="${MODULE_ID}.emptyColor"]`).closest('.form-group'); const emptyColorGroup = $html.find(`input[name="${MODULE_ID}.emptyColor"]`).closest('.form-group');
if (theme === 'custom') { if (theme === 'custom') {
fullColorGroup.show(); fullColorGroup.show();