diff --git a/public/index.html b/public/index.html index da02e79c6..b44205f12 100644 --- a/public/index.html +++ b/public/index.html @@ -3662,8 +3662,8 @@ - + + diff --git a/public/script.js b/public/script.js index 08b6aeee0..05ee60f50 100644 --- a/public/script.js +++ b/public/script.js @@ -10822,7 +10822,7 @@ jQuery(async function () { //newSlider.val(manualInput) //handleSlideEvent.call(newSlider, null, { value: parseFloat(manualInput) }, 'manual'); valueBeforeManualInput = manualInput; - $(masterElement).val($(this).val()).trigger('input'); + $(masterElement).val($(this).val()).trigger('input', { forced: true }); } else { //if value not ok, warn and reset to last known valid value toastr.warning(`Invalid value. Must be between ${$(this).attr('min')} and ${$(this).attr('max')}`); @@ -10848,7 +10848,7 @@ jQuery(async function () { if (manualInput >= Number($(this).attr('min')) && manualInput <= Number($(this).attr('max'))) { valueBeforeManualInput = manualInput; //set the slider value to input value - $(masterElement).val($(this).val()).trigger('input'); + $(masterElement).val($(this).val()).trigger('input', { forced: true }); } else { //if value not ok, warn and reset to last known valid value toastr.warning(`Invalid value. Must be between ${$(this).attr('min')} and ${$(this).attr('max')}`); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 05cb5d85d..5babc0542 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -3328,10 +3328,11 @@ $(document).ready(() => { }); - $('#chat_width_slider').on('input', function (e) { + $('#chat_width_slider').on('input', function (e, data) { + const applyMode = data?.forced ? 'forced' : 'normal'; power_user.chat_width = Number(e.target.value); localStorage.setItem(storage_keys.chat_width, power_user.chat_width); - applyChatWidth(); + applyChatWidth(applyMode); setHotswapsDebounced(); }); @@ -3357,11 +3358,12 @@ $(document).ready(() => { saveSettingsDebounced(); }); - $('input[name="font_scale"]').on('input', async function (e) { + $('input[name="font_scale"]').on('input', async function (e, data) { + const applyMode = data?.forced ? 'forced' : 'normal'; power_user.font_scale = Number(e.target.value); $('#font_scale_counter').val(power_user.font_scale); localStorage.setItem(storage_keys.font_scale, power_user.font_scale); - await applyFontScale(); + await applyFontScale(applyMode); saveSettingsDebounced(); }); diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 5813e84be..70cbc069a 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -1931,39 +1931,43 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl } }); - $('#world_apply_custom_sorting').off('click').on('click', async () => { + $('#world_apply_current_sorting').off('click').on('click', async () => { const entryCount = Object.keys(data.entries).length; const moreThan100 = entryCount > 100; - let content = 'Apply your custom sorting to the "Order" field. The Order values will go down from the chosen number.'; + let content = 'Apply your current sorting to the "Order" field. The Order values will go down from the chosen number.'; if (moreThan100) { content += `
More than 100 entries in this world. If you don't choose a number higher than that, the lower entries will default to 0.
(Usual default: 100)
Minimum: ${entryCount}
`; } - const result = await Popup.show.input('Apply Custom Sorting', content, '100', { okButton: 'Apply', cancelButton: 'Cancel' }); + const result = await Popup.show.input('Apply Current Sorting', content, '100', { okButton: 'Apply', cancelButton: 'Cancel' }); if (!result) return; const start = Number(result); if (isNaN(start) || start < 0) { - toastr.error('Invalid number: ' + result, 'Apply Custom Sorting'); + toastr.error('Invalid number: ' + result, 'Apply Current Sorting'); return; } if (start < entryCount) { - toastr.warning('A number lower than the entry count has been chosen. All entries below that will default to 0.', 'Apply Custom Sorting'); + toastr.warning('A number lower than the entry count has been chosen. All entries below that will default to 0.', 'Apply Current Sorting'); } - let counter = 0; - for (const entry of Object.values(data.entries)) { - const newOrder = Math.max(start - (entry.displayIndex ?? 0), 0); + // We need to sort the entries here, as the data source isn't sorted + const entries = Object.values(data.entries); + sortEntries(entries); + + let updated = 0, current = start; + for (const entry of entries) { + const newOrder = Math.max(current--, 0); if (entry.order === newOrder) continue; entry.order = newOrder; setOriginalDataValue(data, entry.order, 'order', entry.order); - counter++; + updated++; } - if (counter > 0) { - toastr.info(`Updated ${counter} Order values`, 'Apply Custom Sorting'); + if (updated > 0) { + toastr.info(`Updated ${updated} Order values`, 'Apply Custom Sorting'); await saveWorldInfo(name, data, true); updateEditor(navigation_option.previous); } else {