Explicitly use async for saveWorldInfo
| @@ -1848,7 +1848,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl | |||
| 1848 | nextText: '>', | 1848 | nextText: '>', |
| 1849 | formatNavigator: PAGINATION_TEMPLATE, | 1849 | formatNavigator: PAGINATION_TEMPLATE, |
| 1850 | showNavigator: true, | 1850 | showNavigator: true, |
| 1851 | callback: function (/** @type {object[]} */ page) { | 1851 | callback: async function (/** @type {object[]} */ page) { |
| 1852 | // We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements | 1852 | // We save costly performance by removing all events before emptying. Because we know there are no relevant event handlers reacting on removing elements |
| 1853 | // This prevents jQuery from actually going through all registered events on the controls for each entry when removing it | 1853 | // This prevents jQuery from actually going through all registered events on the controls for each entry when removing it |
| 1854 | worldEntriesList.find('*').off(); | 1854 | worldEntriesList.find('*').off(); |
| @@ -1875,7 +1875,8 @@ function displayWorldEntries(name, data, navigation = navigation_option.none, fl | |||
| 1875 | Trigger % | 1875 | Trigger % |
| 1876 | </small> | 1876 | </small> |
| 1877 | </div>`; | 1877 | </div>`; |
| 1878 | const blocks = page.map(entry => getWorldEntry(name, data, entry)).filter(x => x); | 1878 | const mappedEntryBlocksPromises = page.map(async entry => await getWorldEntry(name, data, entry)).filter(x => x); |
| 1879 | const blocks = await Promise.all(mappedEntryBlocksPromises); | ||
| 1879 | const isCustomOrder = $('#world_info_sort_order').find(':selected').data('rule') === 'custom'; | 1880 | const isCustomOrder = $('#world_info_sort_order').find(':selected').data('rule') === 'custom'; |
| 1880 | if (!isCustomOrder) { | 1881 | if (!isCustomOrder) { |
| 1881 | blocks.forEach(block => { | 1882 | blocks.forEach(block => { |
| @@ -2215,7 +2216,7 @@ function parseRegexFromString(input) { | |||
| 2215 | } | 2216 | } |
| 2216 | } | 2217 | } |
| 2217 | 2218 | ||
| 2218 | function getWorldEntry(name, data, entry) { | 2219 | async function getWorldEntry(name, data, entry) { |
| 2219 | if (!data.entries[entry.uid]) { | 2220 | if (!data.entries[entry.uid]) { |
| 2220 | return; | 2221 | return; |
| 2221 | } | 2222 | } |
| @@ -2266,7 +2267,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2266 | templateResult: item => templateStyling(item, { searchStyle: true }), | 2267 | templateResult: item => templateStyling(item, { searchStyle: true }), |
| 2267 | templateSelection: item => templateStyling(item), | 2268 | templateSelection: item => templateStyling(item), |
| 2268 | }); | 2269 | }); |
| 2269 | input.on('change', function (_, { skipReset, noSave } = {}) { | 2270 | input.on('change', async function (_, { skipReset, noSave } = {}) { |
| 2270 | const uid = $(this).data('uid'); | 2271 | const uid = $(this).data('uid'); |
| 2271 | /** @type {string[]} */ | 2272 | /** @type {string[]} */ |
| 2272 | const keys = ($(this).select2('data')).map(x => x.text); | 2273 | const keys = ($(this).select2('data')).map(x => x.text); |
| @@ -2275,7 +2276,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2275 | if (!noSave) { | 2276 | if (!noSave) { |
| 2276 | data.entries[uid][entryPropName] = keys; | 2277 | data.entries[uid][entryPropName] = keys; |
| 2277 | setOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]); | 2278 | setOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]); |
| 2278 | saveWorldInfo(name, data); | 2279 | await saveWorldInfo(name, data); |
| 2279 | } | 2280 | } |
| 2280 | }); | 2281 | }); |
| 2281 | input.on('select2:select', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data])); | 2282 | input.on('select2:select', /** @type {function(*):void} */ event => updateWorldEntryKeyOptionsCache([event.params.data])); |
| @@ -2306,14 +2307,14 @@ function getWorldEntry(name, data, entry) { | |||
| 2306 | template.find(`select[name="${entryPropName}"]`).hide(); | 2307 | template.find(`select[name="${entryPropName}"]`).hide(); |
| 2307 | input.show(); | 2308 | input.show(); |
| 2308 | 2309 | ||
| 2309 | input.on('input', function (_, { skipReset, noSave } = {}) { | 2310 | input.on('input', async function (_, { skipReset, noSave } = {}) { |
| 2310 | const uid = $(this).data('uid'); | 2311 | const uid = $(this).data('uid'); |
| 2311 | const value = String($(this).val()); | 2312 | const value = String($(this).val()); |
| 2312 | !skipReset && resetScrollHeight(this); | 2313 | !skipReset && resetScrollHeight(this); |
| 2313 | if (!noSave) { | 2314 | if (!noSave) { |
| 2314 | data.entries[uid][entryPropName] = splitKeywordsAndRegexes(value); | 2315 | data.entries[uid][entryPropName] = splitKeywordsAndRegexes(value); |
| 2315 | setOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]); | 2316 | setOriginalDataValue(data, uid, originalDataValueName, data.entries[uid][entryPropName]); |
| 2316 | saveWorldInfo(name, data); | 2317 | await saveWorldInfo(name, data); |
| 2317 | } | 2318 | } |
| 2318 | }); | 2319 | }); |
| 2319 | input.val(entry[entryPropName].join(', ')).trigger('input', { skipReset: true }); | 2320 | input.val(entry[entryPropName].join(', ')).trigger('input', { skipReset: true }); |
| @@ -2352,12 +2353,12 @@ function getWorldEntry(name, data, entry) { | |||
| 2352 | event.stopPropagation(); | 2353 | event.stopPropagation(); |
| 2353 | }); | 2354 | }); |
| 2354 | 2355 | ||
| 2355 | selectiveLogicDropdown.on('input', function () { | 2356 | selectiveLogicDropdown.on('input', async function () { |
| 2356 | const uid = $(this).data('uid'); | 2357 | const uid = $(this).data('uid'); |
| 2357 | const value = Number($(this).val()); | 2358 | const value = Number($(this).val()); |
| 2358 | data.entries[uid].selectiveLogic = !isNaN(value) ? value : world_info_logic.AND_ANY; | 2359 | data.entries[uid].selectiveLogic = !isNaN(value) ? value : world_info_logic.AND_ANY; |
| 2359 | setOriginalDataValue(data, uid, 'selectiveLogic', data.entries[uid].selectiveLogic); | 2360 | setOriginalDataValue(data, uid, 'selectiveLogic', data.entries[uid].selectiveLogic); |
| 2360 | saveWorldInfo(name, data); | 2361 | await saveWorldInfo(name, data); |
| 2361 | }); | 2362 | }); |
| 2362 | 2363 | ||
| 2363 | template | 2364 | template |
| @@ -2372,7 +2373,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2372 | // exclude characters checkbox | 2373 | // exclude characters checkbox |
| 2373 | const characterExclusionInput = template.find('input[name="character_exclusion"]'); | 2374 | const characterExclusionInput = template.find('input[name="character_exclusion"]'); |
| 2374 | characterExclusionInput.data('uid', entry.uid); | 2375 | characterExclusionInput.data('uid', entry.uid); |
| 2375 | characterExclusionInput.on('input', function () { | 2376 | characterExclusionInput.on('input', async function () { |
| 2376 | const uid = $(this).data('uid'); | 2377 | const uid = $(this).data('uid'); |
| 2377 | const value = $(this).prop('checked'); | 2378 | const value = $(this).prop('checked'); |
| 2378 | characterFilterLabel.text(value ? 'Exclude Character(s)' : 'Filter to Character(s)'); | 2379 | characterFilterLabel.text(value ? 'Exclude Character(s)' : 'Filter to Character(s)'); |
| @@ -2406,7 +2407,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2406 | } | 2407 | } |
| 2407 | 2408 | ||
| 2408 | setOriginalDataValue(data, uid, 'character_filter', data.entries[uid].characterFilter); | 2409 | setOriginalDataValue(data, uid, 'character_filter', data.entries[uid].characterFilter); |
| 2409 | saveWorldInfo(name, data); | 2410 | await saveWorldInfo(name, data); |
| 2410 | }); | 2411 | }); |
| 2411 | characterExclusionInput.prop('checked', entry.characterFilter?.isExclude ?? false).trigger('input'); | 2412 | characterExclusionInput.prop('checked', entry.characterFilter?.isExclude ?? false).trigger('input'); |
| 2412 | 2413 | ||
| @@ -2468,24 +2469,24 @@ function getWorldEntry(name, data, entry) { | |||
| 2468 | ); | 2469 | ); |
| 2469 | } | 2470 | } |
| 2470 | setOriginalDataValue(data, uid, 'character_filter', data.entries[uid].characterFilter); | 2471 | setOriginalDataValue(data, uid, 'character_filter', data.entries[uid].characterFilter); |
| 2471 | saveWorldInfo(name, data); | 2472 | await saveWorldInfo(name, data); |
| 2472 | }); | 2473 | }); |
| 2473 | 2474 | ||
| 2474 | // comment | 2475 | // comment |
| 2475 | const commentInput = template.find('textarea[name="comment"]'); | 2476 | const commentInput = template.find('textarea[name="comment"]'); |
| 2476 | const commentToggle = template.find('input[name="addMemo"]'); | 2477 | const commentToggle = template.find('input[name="addMemo"]'); |
| 2477 | commentInput.data('uid', entry.uid); | 2478 | commentInput.data('uid', entry.uid); |
| 2478 | commentInput.on('input', function (_, { skipReset } = {}) { | 2479 | commentInput.on('input', async function (_, { skipReset } = {}) { |
| 2479 | const uid = $(this).data('uid'); | 2480 | const uid = $(this).data('uid'); |
| 2480 | const value = $(this).val(); | 2481 | const value = $(this).val(); |
| 2481 | !skipReset && resetScrollHeight(this); | 2482 | !skipReset && resetScrollHeight(this); |
| 2482 | data.entries[uid].comment = value; | 2483 | data.entries[uid].comment = value; |
| 2483 | 2484 | ||
| 2484 | setOriginalDataValue(data, uid, 'comment', data.entries[uid].comment); | 2485 | setOriginalDataValue(data, uid, 'comment', data.entries[uid].comment); |
| 2485 | saveWorldInfo(name, data); | 2486 | await saveWorldInfo(name, data); |
| 2486 | }); | 2487 | }); |
| 2487 | commentToggle.data('uid', entry.uid); | 2488 | commentToggle.data('uid', entry.uid); |
| 2488 | commentToggle.on('input', function () { | 2489 | commentToggle.on('input', async function () { |
| 2489 | const uid = $(this).data('uid'); | 2490 | const uid = $(this).data('uid'); |
| 2490 | const value = $(this).prop('checked'); | 2491 | const value = $(this).prop('checked'); |
| 2491 | //console.log(value) | 2492 | //console.log(value) |
| @@ -2493,7 +2494,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2493 | .closest('.world_entry') | 2494 | .closest('.world_entry') |
| 2494 | .find('.commentContainer'); | 2495 | .find('.commentContainer'); |
| 2495 | data.entries[uid].addMemo = value; | 2496 | data.entries[uid].addMemo = value; |
| 2496 | saveWorldInfo(name, data); | 2497 | await saveWorldInfo(name, data); |
| 2497 | value ? commentContainer.show() : commentContainer.hide(); | 2498 | value ? commentContainer.show() : commentContainer.hide(); |
| 2498 | }); | 2499 | }); |
| 2499 | 2500 | ||
| @@ -2511,13 +2512,13 @@ function getWorldEntry(name, data, entry) { | |||
| 2511 | 2512 | ||
| 2512 | const contentInput = template.find('textarea[name="content"]'); | 2513 | const contentInput = template.find('textarea[name="content"]'); |
| 2513 | contentInput.data('uid', entry.uid); | 2514 | contentInput.data('uid', entry.uid); |
| 2514 | contentInput.on('input', function (_, { skipCount } = {}) { | 2515 | contentInput.on('input', async function (_, { skipCount } = {}) { |
| 2515 | const uid = $(this).data('uid'); | 2516 | const uid = $(this).data('uid'); |
| 2516 | const value = $(this).val(); | 2517 | const value = $(this).val(); |
| 2517 | data.entries[uid].content = value; | 2518 | data.entries[uid].content = value; |
| 2518 | 2519 | ||
| 2519 | setOriginalDataValue(data, uid, 'content', data.entries[uid].content); | 2520 | setOriginalDataValue(data, uid, 'content', data.entries[uid].content); |
| 2520 | saveWorldInfo(name, data); | 2521 | await saveWorldInfo(name, data); |
| 2521 | 2522 | ||
| 2522 | if (skipCount) { | 2523 | if (skipCount) { |
| 2523 | return; | 2524 | return; |
| @@ -2541,13 +2542,13 @@ function getWorldEntry(name, data, entry) { | |||
| 2541 | // selective | 2542 | // selective |
| 2542 | const selectiveInput = template.find('input[name="selective"]'); | 2543 | const selectiveInput = template.find('input[name="selective"]'); |
| 2543 | selectiveInput.data('uid', entry.uid); | 2544 | selectiveInput.data('uid', entry.uid); |
| 2544 | selectiveInput.on('input', function () { | 2545 | selectiveInput.on('input', async function () { |
| 2545 | const uid = $(this).data('uid'); | 2546 | const uid = $(this).data('uid'); |
| 2546 | const value = $(this).prop('checked'); | 2547 | const value = $(this).prop('checked'); |
| 2547 | data.entries[uid].selective = value; | 2548 | data.entries[uid].selective = value; |
| 2548 | 2549 | ||
| 2549 | setOriginalDataValue(data, uid, 'selective', data.entries[uid].selective); | 2550 | setOriginalDataValue(data, uid, 'selective', data.entries[uid].selective); |
| 2550 | saveWorldInfo(name, data); | 2551 | await saveWorldInfo(name, data); |
| 2551 | 2552 | ||
| 2552 | const keysecondary = $(this) | 2553 | const keysecondary = $(this) |
| 2553 | .closest('.world_entry') | 2554 | .closest('.world_entry') |
| @@ -2576,12 +2577,12 @@ function getWorldEntry(name, data, entry) { | |||
| 2576 | /* | 2577 | /* |
| 2577 | const constantInput = template.find('input[name="constant"]'); | 2578 | const constantInput = template.find('input[name="constant"]'); |
| 2578 | constantInput.data("uid", entry.uid); | 2579 | constantInput.data("uid", entry.uid); |
| 2579 | constantInput.on("input", function () { | 2580 | constantInput.on("input", async function () { |
| 2580 | const uid = $(this).data("uid"); | 2581 | const uid = $(this).data("uid"); |
| 2581 | const value = $(this).prop("checked"); | 2582 | const value = $(this).prop("checked"); |
| 2582 | data.entries[uid].constant = value; | 2583 | data.entries[uid].constant = value; |
| 2583 | setOriginalDataValue(data, uid, "constant", data.entries[uid].constant); | 2584 | setOriginalDataValue(data, uid, "constant", data.entries[uid].constant); |
| 2584 | saveWorldInfo(name, data); | 2585 | await saveWorldInfo(name, data); |
| 2585 | }); | 2586 | }); |
| 2586 | constantInput.prop("checked", entry.constant).trigger("input"); | 2587 | constantInput.prop("checked", entry.constant).trigger("input"); |
| 2587 | */ | 2588 | */ |
| @@ -2589,14 +2590,14 @@ function getWorldEntry(name, data, entry) { | |||
| 2589 | // order | 2590 | // order |
| 2590 | const orderInput = template.find('input[name="order"]'); | 2591 | const orderInput = template.find('input[name="order"]'); |
| 2591 | orderInput.data('uid', entry.uid); | 2592 | orderInput.data('uid', entry.uid); |
| 2592 | orderInput.on('input', function () { | 2593 | orderInput.on('input', async function () { |
| 2593 | const uid = $(this).data('uid'); | 2594 | const uid = $(this).data('uid'); |
| 2594 | const value = Number($(this).val()); | 2595 | const value = Number($(this).val()); |
| 2595 | 2596 | ||
| 2596 | data.entries[uid].order = !isNaN(value) ? value : 0; | 2597 | data.entries[uid].order = !isNaN(value) ? value : 0; |
| 2597 | updatePosOrdDisplay(uid); | 2598 | updatePosOrdDisplay(uid); |
| 2598 | setOriginalDataValue(data, uid, 'insertion_order', data.entries[uid].order); | 2599 | setOriginalDataValue(data, uid, 'insertion_order', data.entries[uid].order); |
| 2599 | saveWorldInfo(name, data); | 2600 | await saveWorldInfo(name, data); |
| 2600 | }); | 2601 | }); |
| 2601 | orderInput.val(entry.order).trigger('input'); | 2602 | orderInput.val(entry.order).trigger('input'); |
| 2602 | orderInput.css('width', 'calc(3em + 15px)'); | 2603 | orderInput.css('width', 'calc(3em + 15px)'); |
| @@ -2604,13 +2605,13 @@ function getWorldEntry(name, data, entry) { | |||
| 2604 | // group | 2605 | // group |
| 2605 | const groupInput = template.find('input[name="group"]'); | 2606 | const groupInput = template.find('input[name="group"]'); |
| 2606 | groupInput.data('uid', entry.uid); | 2607 | groupInput.data('uid', entry.uid); |
| 2607 | groupInput.on('input', function () { | 2608 | groupInput.on('input', async function () { |
| 2608 | const uid = $(this).data('uid'); | 2609 | const uid = $(this).data('uid'); |
| 2609 | const value = String($(this).val()).trim(); | 2610 | const value = String($(this).val()).trim(); |
| 2610 | 2611 | ||
| 2611 | data.entries[uid].group = value; | 2612 | data.entries[uid].group = value; |
| 2612 | setOriginalDataValue(data, uid, 'extensions.group', data.entries[uid].group); | 2613 | setOriginalDataValue(data, uid, 'extensions.group', data.entries[uid].group); |
| 2613 | saveWorldInfo(name, data); | 2614 | await saveWorldInfo(name, data); |
| 2614 | }); | 2615 | }); |
| 2615 | groupInput.val(entry.group ?? '').trigger('input'); | 2616 | groupInput.val(entry.group ?? '').trigger('input'); |
| 2616 | setTimeout(() => createEntryInputAutocomplete(groupInput, getInclusionGroupCallback(data), { allowMultiple: true }), 1); | 2617 | setTimeout(() => createEntryInputAutocomplete(groupInput, getInclusionGroupCallback(data), { allowMultiple: true }), 1); |
| @@ -2618,19 +2619,19 @@ function getWorldEntry(name, data, entry) { | |||
| 2618 | // inclusion priority | 2619 | // inclusion priority |
| 2619 | const groupOverrideInput = template.find('input[name="groupOverride"]'); | 2620 | const groupOverrideInput = template.find('input[name="groupOverride"]'); |
| 2620 | groupOverrideInput.data('uid', entry.uid); | 2621 | groupOverrideInput.data('uid', entry.uid); |
| 2621 | groupOverrideInput.on('input', function () { | 2622 | groupOverrideInput.on('input', async function () { |
| 2622 | const uid = $(this).data('uid'); | 2623 | const uid = $(this).data('uid'); |
| 2623 | const value = $(this).prop('checked'); | 2624 | const value = $(this).prop('checked'); |
| 2624 | data.entries[uid].groupOverride = value; | 2625 | data.entries[uid].groupOverride = value; |
| 2625 | setOriginalDataValue(data, uid, 'extensions.group_override', data.entries[uid].groupOverride); | 2626 | setOriginalDataValue(data, uid, 'extensions.group_override', data.entries[uid].groupOverride); |
| 2626 | saveWorldInfo(name, data); | 2627 | await saveWorldInfo(name, data); |
| 2627 | }); | 2628 | }); |
| 2628 | groupOverrideInput.prop('checked', entry.groupOverride).trigger('input'); | 2629 | groupOverrideInput.prop('checked', entry.groupOverride).trigger('input'); |
| 2629 | 2630 | ||
| 2630 | // group weight | 2631 | // group weight |
| 2631 | const groupWeightInput = template.find('input[name="groupWeight"]'); | 2632 | const groupWeightInput = template.find('input[name="groupWeight"]'); |
| 2632 | groupWeightInput.data('uid', entry.uid); | 2633 | groupWeightInput.data('uid', entry.uid); |
| 2633 | groupWeightInput.on('input', function () { | 2634 | groupWeightInput.on('input', async function () { |
| 2634 | const uid = $(this).data('uid'); | 2635 | const uid = $(this).data('uid'); |
| 2635 | let value = Number($(this).val()); | 2636 | let value = Number($(this).val()); |
| 2636 | const min = Number($(this).attr('min')); | 2637 | const min = Number($(this).attr('min')); |
| @@ -2647,46 +2648,46 @@ function getWorldEntry(name, data, entry) { | |||
| 2647 | 2648 | ||
| 2648 | data.entries[uid].groupWeight = !isNaN(value) ? Math.abs(value) : 1; | 2649 | data.entries[uid].groupWeight = !isNaN(value) ? Math.abs(value) : 1; |
| 2649 | setOriginalDataValue(data, uid, 'extensions.group_weight', data.entries[uid].groupWeight); | 2650 | setOriginalDataValue(data, uid, 'extensions.group_weight', data.entries[uid].groupWeight); |
| 2650 | saveWorldInfo(name, data); | 2651 | await saveWorldInfo(name, data); |
| 2651 | }); | 2652 | }); |
| 2652 | groupWeightInput.val(entry.groupWeight ?? DEFAULT_WEIGHT).trigger('input'); | 2653 | groupWeightInput.val(entry.groupWeight ?? DEFAULT_WEIGHT).trigger('input'); |
| 2653 | 2654 | ||
| 2654 | // sticky | 2655 | // sticky |
| 2655 | const sticky = template.find('input[name="sticky"]'); | 2656 | const sticky = template.find('input[name="sticky"]'); |
| 2656 | sticky.data('uid', entry.uid); | 2657 | sticky.data('uid', entry.uid); |
| 2657 | sticky.on('input', function () { | 2658 | sticky.on('input', async function () { |
| 2658 | const uid = $(this).data('uid'); | 2659 | const uid = $(this).data('uid'); |
| 2659 | const value = Number($(this).val()); | 2660 | const value = Number($(this).val()); |
| 2660 | data.entries[uid].sticky = !isNaN(value) ? value : null; | 2661 | data.entries[uid].sticky = !isNaN(value) ? value : null; |
| 2661 | 2662 | ||
| 2662 | setOriginalDataValue(data, uid, 'extensions.sticky', data.entries[uid].sticky); | 2663 | setOriginalDataValue(data, uid, 'extensions.sticky', data.entries[uid].sticky); |
| 2663 | saveWorldInfo(name, data); | 2664 | await saveWorldInfo(name, data); |
| 2664 | }); | 2665 | }); |
| 2665 | sticky.val(entry.sticky > 0 ? entry.sticky : '').trigger('input'); | 2666 | sticky.val(entry.sticky > 0 ? entry.sticky : '').trigger('input'); |
| 2666 | 2667 | ||
| 2667 | // cooldown | 2668 | // cooldown |
| 2668 | const cooldown = template.find('input[name="cooldown"]'); | 2669 | const cooldown = template.find('input[name="cooldown"]'); |
| 2669 | cooldown.data('uid', entry.uid); | 2670 | cooldown.data('uid', entry.uid); |
| 2670 | cooldown.on('input', function () { | 2671 | cooldown.on('input', async function () { |
| 2671 | const uid = $(this).data('uid'); | 2672 | const uid = $(this).data('uid'); |
| 2672 | const value = Number($(this).val()); | 2673 | const value = Number($(this).val()); |
| 2673 | data.entries[uid].cooldown = !isNaN(value) ? value : null; | 2674 | data.entries[uid].cooldown = !isNaN(value) ? value : null; |
| 2674 | 2675 | ||
| 2675 | setOriginalDataValue(data, uid, 'extensions.cooldown', data.entries[uid].cooldown); | 2676 | setOriginalDataValue(data, uid, 'extensions.cooldown', data.entries[uid].cooldown); |
| 2676 | saveWorldInfo(name, data); | 2677 | await saveWorldInfo(name, data); |
| 2677 | }); | 2678 | }); |
| 2678 | cooldown.val(entry.cooldown > 0 ? entry.cooldown : '').trigger('input'); | 2679 | cooldown.val(entry.cooldown > 0 ? entry.cooldown : '').trigger('input'); |
| 2679 | 2680 | ||
| 2680 | // delay | 2681 | // delay |
| 2681 | const delay = template.find('input[name="delay"]'); | 2682 | const delay = template.find('input[name="delay"]'); |
| 2682 | delay.data('uid', entry.uid); | 2683 | delay.data('uid', entry.uid); |
| 2683 | delay.on('input', function () { | 2684 | delay.on('input', async function () { |
| 2684 | const uid = $(this).data('uid'); | 2685 | const uid = $(this).data('uid'); |
| 2685 | const value = Number($(this).val()); | 2686 | const value = Number($(this).val()); |
| 2686 | data.entries[uid].delay = !isNaN(value) ? value : null; | 2687 | data.entries[uid].delay = !isNaN(value) ? value : null; |
| 2687 | 2688 | ||
| 2688 | setOriginalDataValue(data, uid, 'extensions.delay', data.entries[uid].delay); | 2689 | setOriginalDataValue(data, uid, 'extensions.delay', data.entries[uid].delay); |
| 2689 | saveWorldInfo(name, data); | 2690 | await saveWorldInfo(name, data); |
| 2690 | }); | 2691 | }); |
| 2691 | delay.val(entry.delay > 0 ? entry.delay : '').trigger('input'); | 2692 | delay.val(entry.delay > 0 ? entry.delay : '').trigger('input'); |
| 2692 | 2693 | ||
| @@ -2699,14 +2700,14 @@ function getWorldEntry(name, data, entry) { | |||
| 2699 | const depthInput = template.find('input[name="depth"]'); | 2700 | const depthInput = template.find('input[name="depth"]'); |
| 2700 | depthInput.data('uid', entry.uid); | 2701 | depthInput.data('uid', entry.uid); |
| 2701 | 2702 | ||
| 2702 | depthInput.on('input', function () { | 2703 | depthInput.on('input', async function () { |
| 2703 | const uid = $(this).data('uid'); | 2704 | const uid = $(this).data('uid'); |
| 2704 | const value = Number($(this).val()); | 2705 | const value = Number($(this).val()); |
| 2705 | 2706 | ||
| 2706 | data.entries[uid].depth = !isNaN(value) ? value : 0; | 2707 | data.entries[uid].depth = !isNaN(value) ? value : 0; |
| 2707 | updatePosOrdDisplay(uid); | 2708 | updatePosOrdDisplay(uid); |
| 2708 | setOriginalDataValue(data, uid, 'extensions.depth', data.entries[uid].depth); | 2709 | setOriginalDataValue(data, uid, 'extensions.depth', data.entries[uid].depth); |
| 2709 | saveWorldInfo(name, data); | 2710 | await saveWorldInfo(name, data); |
| 2710 | }); | 2711 | }); |
| 2711 | depthInput.val(entry.depth ?? DEFAULT_DEPTH).trigger('input'); | 2712 | depthInput.val(entry.depth ?? DEFAULT_DEPTH).trigger('input'); |
| 2712 | depthInput.css('width', 'calc(3em + 15px)'); | 2713 | depthInput.css('width', 'calc(3em + 15px)'); |
| @@ -2718,7 +2719,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2718 | 2719 | ||
| 2719 | const probabilityInput = template.find('input[name="probability"]'); | 2720 | const probabilityInput = template.find('input[name="probability"]'); |
| 2720 | probabilityInput.data('uid', entry.uid); | 2721 | probabilityInput.data('uid', entry.uid); |
| 2721 | probabilityInput.on('input', function () { | 2722 | probabilityInput.on('input', async function () { |
| 2722 | const uid = $(this).data('uid'); | 2723 | const uid = $(this).data('uid'); |
| 2723 | const value = Number($(this).val()); | 2724 | const value = Number($(this).val()); |
| 2724 | 2725 | ||
| @@ -2734,7 +2735,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2734 | } | 2735 | } |
| 2735 | 2736 | ||
| 2736 | setOriginalDataValue(data, uid, 'extensions.probability', data.entries[uid].probability); | 2737 | setOriginalDataValue(data, uid, 'extensions.probability', data.entries[uid].probability); |
| 2737 | saveWorldInfo(name, data); | 2738 | await saveWorldInfo(name, data); |
| 2738 | }); | 2739 | }); |
| 2739 | probabilityInput.val(entry.probability).trigger('input'); | 2740 | probabilityInput.val(entry.probability).trigger('input'); |
| 2740 | probabilityInput.css('width', 'calc(3em + 15px)'); | 2741 | probabilityInput.css('width', 'calc(3em + 15px)'); |
| @@ -2746,14 +2747,14 @@ function getWorldEntry(name, data, entry) { | |||
| 2746 | 2747 | ||
| 2747 | const probabilityToggle = template.find('input[name="useProbability"]'); | 2748 | const probabilityToggle = template.find('input[name="useProbability"]'); |
| 2748 | probabilityToggle.data('uid', entry.uid); | 2749 | probabilityToggle.data('uid', entry.uid); |
| 2749 | probabilityToggle.on('input', function () { | 2750 | probabilityToggle.on('input', async function () { |
| 2750 | const uid = $(this).data('uid'); | 2751 | const uid = $(this).data('uid'); |
| 2751 | const value = $(this).prop('checked'); | 2752 | const value = $(this).prop('checked'); |
| 2752 | data.entries[uid].useProbability = value; | 2753 | data.entries[uid].useProbability = value; |
| 2753 | const probabilityContainer = $(this) | 2754 | const probabilityContainer = $(this) |
| 2754 | .closest('.world_entry') | 2755 | .closest('.world_entry') |
| 2755 | .find('.probabilityContainer'); | 2756 | .find('.probabilityContainer'); |
| 2756 | saveWorldInfo(name, data); | 2757 | await saveWorldInfo(name, data); |
| 2757 | value ? probabilityContainer.show() : probabilityContainer.hide(); | 2758 | value ? probabilityContainer.show() : probabilityContainer.hide(); |
| 2758 | 2759 | ||
| 2759 | if (value && data.entries[uid].probability === null) { | 2760 | if (value && data.entries[uid].probability === null) { |
| @@ -2782,7 +2783,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2782 | // Prevent closing the drawer on clicking the input | 2783 | // Prevent closing the drawer on clicking the input |
| 2783 | event.stopPropagation(); | 2784 | event.stopPropagation(); |
| 2784 | }); | 2785 | }); |
| 2785 | positionInput.on('input', function () { | 2786 | positionInput.on('input', async function () { |
| 2786 | const uid = $(this).data('uid'); | 2787 | const uid = $(this).data('uid'); |
| 2787 | const value = Number($(this).val()); | 2788 | const value = Number($(this).val()); |
| 2788 | data.entries[uid].position = !isNaN(value) ? value : 0; | 2789 | data.entries[uid].position = !isNaN(value) ? value : 0; |
| @@ -2804,7 +2805,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2804 | // Write the original value as extensions field | 2805 | // Write the original value as extensions field |
| 2805 | setOriginalDataValue(data, uid, 'extensions.position', data.entries[uid].position); | 2806 | setOriginalDataValue(data, uid, 'extensions.position', data.entries[uid].position); |
| 2806 | setOriginalDataValue(data, uid, 'extensions.role', data.entries[uid].role); | 2807 | setOriginalDataValue(data, uid, 'extensions.role', data.entries[uid].role); |
| 2807 | saveWorldInfo(name, data); | 2808 | await saveWorldInfo(name, data); |
| 2808 | }); | 2809 | }); |
| 2809 | 2810 | ||
| 2810 | const roleValue = entry.position === world_info_position.atDepth ? String(entry.role ?? extension_prompt_roles.SYSTEM) : ''; | 2811 | const roleValue = entry.position === world_info_position.atDepth ? String(entry.role ?? extension_prompt_roles.SYSTEM) : ''; |
| @@ -2820,12 +2821,12 @@ function getWorldEntry(name, data, entry) { | |||
| 2820 | /* | 2821 | /* |
| 2821 | const disableInput = template.find('input[name="disable"]'); | 2822 | const disableInput = template.find('input[name="disable"]'); |
| 2822 | disableInput.data("uid", entry.uid); | 2823 | disableInput.data("uid", entry.uid); |
| 2823 | disableInput.on("input", function () { | 2824 | disableInput.on("input", async function () { |
| 2824 | const uid = $(this).data("uid"); | 2825 | const uid = $(this).data("uid"); |
| 2825 | const value = $(this).prop("checked"); | 2826 | const value = $(this).prop("checked"); |
| 2826 | data.entries[uid].disable = value; | 2827 | data.entries[uid].disable = value; |
| 2827 | setOriginalDataValue(data, uid, "enabled", !data.entries[uid].disable); | 2828 | setOriginalDataValue(data, uid, "enabled", !data.entries[uid].disable); |
| 2828 | saveWorldInfo(name, data); | 2829 | await saveWorldInfo(name, data); |
| 2829 | }); | 2830 | }); |
| 2830 | disableInput.prop("checked", entry.disable).trigger("input"); | 2831 | disableInput.prop("checked", entry.disable).trigger("input"); |
| 2831 | */ | 2832 | */ |
| @@ -2837,7 +2838,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2837 | // Prevent closing the drawer on clicking the input | 2838 | // Prevent closing the drawer on clicking the input |
| 2838 | event.stopPropagation(); | 2839 | event.stopPropagation(); |
| 2839 | }); | 2840 | }); |
| 2840 | entryStateSelector.on('input', function () { | 2841 | entryStateSelector.on('input', async function () { |
| 2841 | const uid = entry.uid; | 2842 | const uid = entry.uid; |
| 2842 | const value = $(this).val(); | 2843 | const value = $(this).val(); |
| 2843 | switch (value) { | 2844 | switch (value) { |
| @@ -2878,7 +2879,7 @@ function getWorldEntry(name, data, entry) { | |||
| 2878 | template.addClass('disabledWIEntry'); | 2879 | template.addClass('disabledWIEntry'); |
| 2879 | break; | 2880 | break; |
| 2880 | } | 2881 | } |
| 2881 | saveWorldInfo(name, data); | 2882 | await saveWorldInfo(name, data); |
| 2882 | 2883 | ||
| 2883 | }); | 2884 | }); |
| 2884 | 2885 | ||
| @@ -2898,52 +2899,52 @@ function getWorldEntry(name, data, entry) { | |||
| 2898 | .prop('selected', true) | 2899 | .prop('selected', true) |
| 2899 | .trigger('input'); | 2900 | .trigger('input'); |
| 2900 | 2901 | ||
| 2901 | saveWorldInfo(name, data); | 2902 | await saveWorldInfo(name, data); |
| 2902 | 2903 | ||
| 2903 | // exclude recursion | 2904 | // exclude recursion |
| 2904 | const excludeRecursionInput = template.find('input[name="exclude_recursion"]'); | 2905 | const excludeRecursionInput = template.find('input[name="exclude_recursion"]'); |
| 2905 | excludeRecursionInput.data('uid', entry.uid); | 2906 | excludeRecursionInput.data('uid', entry.uid); |
| 2906 | excludeRecursionInput.on('input', function () { | 2907 | excludeRecursionInput.on('input', async function () { |
| 2907 | const uid = $(this).data('uid'); | 2908 | const uid = $(this).data('uid'); |
| 2908 | const value = $(this).prop('checked'); | 2909 | const value = $(this).prop('checked'); |
| 2909 | data.entries[uid].excludeRecursion = value; | 2910 | data.entries[uid].excludeRecursion = value; |
| 2910 | setOriginalDataValue(data, uid, 'extensions.exclude_recursion', data.entries[uid].excludeRecursion); | 2911 | setOriginalDataValue(data, uid, 'extensions.exclude_recursion', data.entries[uid].excludeRecursion); |
| 2911 | saveWorldInfo(name, data); | 2912 | await saveWorldInfo(name, data); |
| 2912 | }); | 2913 | }); |
| 2913 | excludeRecursionInput.prop('checked', entry.excludeRecursion).trigger('input'); | 2914 | excludeRecursionInput.prop('checked', entry.excludeRecursion).trigger('input'); |
| 2914 | 2915 | ||
| 2915 | // prevent recursion | 2916 | // prevent recursion |
| 2916 | const preventRecursionInput = template.find('input[name="prevent_recursion"]'); | 2917 | const preventRecursionInput = template.find('input[name="prevent_recursion"]'); |
| 2917 | preventRecursionInput.data('uid', entry.uid); | 2918 | preventRecursionInput.data('uid', entry.uid); |
| 2918 | preventRecursionInput.on('input', function () { | 2919 | preventRecursionInput.on('input', async function () { |
| 2919 | const uid = $(this).data('uid'); | 2920 | const uid = $(this).data('uid'); |
| 2920 | const value = $(this).prop('checked'); | 2921 | const value = $(this).prop('checked'); |
| 2921 | data.entries[uid].preventRecursion = value; | 2922 | data.entries[uid].preventRecursion = value; |
| 2922 | setOriginalDataValue(data, uid, 'extensions.prevent_recursion', data.entries[uid].preventRecursion); | 2923 | setOriginalDataValue(data, uid, 'extensions.prevent_recursion', data.entries[uid].preventRecursion); |
| 2923 | saveWorldInfo(name, data); | 2924 | await saveWorldInfo(name, data); |
| 2924 | }); | 2925 | }); |
| 2925 | preventRecursionInput.prop('checked', entry.preventRecursion).trigger('input'); | 2926 | preventRecursionInput.prop('checked', entry.preventRecursion).trigger('input'); |
| 2926 | 2927 | ||
| 2927 | // delay until recursion | 2928 | // delay until recursion |
| 2928 | const delayUntilRecursionInput = template.find('input[name="delay_until_recursion"]'); | 2929 | const delayUntilRecursionInput = template.find('input[name="delay_until_recursion"]'); |
| 2929 | delayUntilRecursionInput.data('uid', entry.uid); | 2930 | delayUntilRecursionInput.data('uid', entry.uid); |
| 2930 | delayUntilRecursionInput.on('input', function () { | 2931 | delayUntilRecursionInput.on('input', async function () { |
| 2931 | const uid = $(this).data('uid'); | 2932 | const uid = $(this).data('uid'); |
| 2932 | const value = $(this).prop('checked'); | 2933 | const value = $(this).prop('checked'); |
| 2933 | data.entries[uid].delayUntilRecursion = value; | 2934 | data.entries[uid].delayUntilRecursion = value; |
| 2934 | setOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion); | 2935 | setOriginalDataValue(data, uid, 'extensions.delay_until_recursion', data.entries[uid].delayUntilRecursion); |
| 2935 | saveWorldInfo(name, data); | 2936 | await saveWorldInfo(name, data); |
| 2936 | }); | 2937 | }); |
| 2937 | delayUntilRecursionInput.prop('checked', entry.delayUntilRecursion).trigger('input'); | 2938 | delayUntilRecursionInput.prop('checked', entry.delayUntilRecursion).trigger('input'); |
| 2938 | 2939 | ||
| 2939 | // duplicate button | 2940 | // duplicate button |
| 2940 | const duplicateButton = template.find('.duplicate_entry_button'); | 2941 | const duplicateButton = template.find('.duplicate_entry_button'); |
| 2941 | duplicateButton.data('uid', entry.uid); | 2942 | duplicateButton.data('uid', entry.uid); |
| 2942 | duplicateButton.on('click', function () { | 2943 | duplicateButton.on('click', async function () { |
| 2943 | const uid = $(this).data('uid'); | 2944 | const uid = $(this).data('uid'); |
| 2944 | const entry = duplicateWorldInfoEntry(data, uid); | 2945 | const entry = duplicateWorldInfoEntry(data, uid); |
| 2945 | if (entry) { | 2946 | if (entry) { |
| 2946 | saveWorldInfo(name, data); | 2947 | await saveWorldInfo(name, data); |
| 2947 | updateEditor(entry.uid); | 2948 | updateEditor(entry.uid); |
| 2948 | } | 2949 | } |
| 2949 | }); | 2950 | }); |
| @@ -2951,18 +2952,18 @@ function getWorldEntry(name, data, entry) { | |||
| 2951 | // delete button | 2952 | // delete button |
| 2952 | const deleteButton = template.find('.delete_entry_button'); | 2953 | const deleteButton = template.find('.delete_entry_button'); |
| 2953 | deleteButton.data('uid', entry.uid); | 2954 | deleteButton.data('uid', entry.uid); |
| 2954 | deleteButton.on('click', function () { | 2955 | deleteButton.on('click', async function () { |
| 2955 | const uid = $(this).data('uid'); | 2956 | const uid = $(this).data('uid'); |
| 2956 | deleteWorldInfoEntry(data, uid); | 2957 | deleteWorldInfoEntry(data, uid); |
| 2957 | deleteOriginalDataValue(data, uid); | 2958 | deleteOriginalDataValue(data, uid); |
| 2958 | saveWorldInfo(name, data); | 2959 | await saveWorldInfo(name, data); |
| 2959 | updateEditor(navigation_option.previous); | 2960 | updateEditor(navigation_option.previous); |
| 2960 | }); | 2961 | }); |
| 2961 | 2962 | ||
| 2962 | // scan depth | 2963 | // scan depth |
| 2963 | const scanDepthInput = template.find('input[name="scanDepth"]'); | 2964 | const scanDepthInput = template.find('input[name="scanDepth"]'); |
| 2964 | scanDepthInput.data('uid', entry.uid); | 2965 | scanDepthInput.data('uid', entry.uid); |
| 2965 | scanDepthInput.on('input', function () { | 2966 | scanDepthInput.on('input', async function () { |
| 2966 | const uid = $(this).data('uid'); | 2967 | const uid = $(this).data('uid'); |
| 2967 | const isEmpty = $(this).val() === ''; | 2968 | const isEmpty = $(this).val() === ''; |
| 2968 | const value = Number($(this).val()); | 2969 | const value = Number($(this).val()); |
| @@ -2982,59 +2983,59 @@ function getWorldEntry(name, data, entry) { | |||
| 2982 | 2983 | ||
| 2983 | data.entries[uid].scanDepth = !isEmpty && !isNaN(value) && value >= 0 && value <= MAX_SCAN_DEPTH ? Math.floor(value) : null; | 2984 | data.entries[uid].scanDepth = !isEmpty && !isNaN(value) && value >= 0 && value <= MAX_SCAN_DEPTH ? Math.floor(value) : null; |
| 2984 | setOriginalDataValue(data, uid, 'extensions.scan_depth', data.entries[uid].scanDepth); | 2985 | setOriginalDataValue(data, uid, 'extensions.scan_depth', data.entries[uid].scanDepth); |
| 2985 | saveWorldInfo(name, data); | 2986 | await saveWorldInfo(name, data); |
| 2986 | }); | 2987 | }); |
| 2987 | scanDepthInput.val(entry.scanDepth ?? null).trigger('input'); | 2988 | scanDepthInput.val(entry.scanDepth ?? null).trigger('input'); |
| 2988 | 2989 | ||
| 2989 | // case sensitive select | 2990 | // case sensitive select |
| 2990 | const caseSensitiveSelect = template.find('select[name="caseSensitive"]'); | 2991 | const caseSensitiveSelect = template.find('select[name="caseSensitive"]'); |
| 2991 | caseSensitiveSelect.data('uid', entry.uid); | 2992 | caseSensitiveSelect.data('uid', entry.uid); |
| 2992 | caseSensitiveSelect.on('input', function () { | 2993 | caseSensitiveSelect.on('input', async function () { |
| 2993 | const uid = $(this).data('uid'); | 2994 | const uid = $(this).data('uid'); |
| 2994 | const value = $(this).val(); | 2995 | const value = $(this).val(); |
| 2995 | 2996 | ||
| 2996 | data.entries[uid].caseSensitive = value === 'null' ? null : value === 'true'; | 2997 | data.entries[uid].caseSensitive = value === 'null' ? null : value === 'true'; |
| 2997 | setOriginalDataValue(data, uid, 'extensions.case_sensitive', data.entries[uid].caseSensitive); | 2998 | setOriginalDataValue(data, uid, 'extensions.case_sensitive', data.entries[uid].caseSensitive); |
| 2998 | saveWorldInfo(name, data); | 2999 | await saveWorldInfo(name, data); |
| 2999 | }); | 3000 | }); |
| 3000 | caseSensitiveSelect.val((entry.caseSensitive === null || entry.caseSensitive === undefined) ? 'null' : entry.caseSensitive ? 'true' : 'false').trigger('input'); | 3001 | caseSensitiveSelect.val((entry.caseSensitive === null || entry.caseSensitive === undefined) ? 'null' : entry.caseSensitive ? 'true' : 'false').trigger('input'); |
| 3001 | 3002 | ||
| 3002 | // match whole words select | 3003 | // match whole words select |
| 3003 | const matchWholeWordsSelect = template.find('select[name="matchWholeWords"]'); | 3004 | const matchWholeWordsSelect = template.find('select[name="matchWholeWords"]'); |
| 3004 | matchWholeWordsSelect.data('uid', entry.uid); | 3005 | matchWholeWordsSelect.data('uid', entry.uid); |
| 3005 | matchWholeWordsSelect.on('input', function () { | 3006 | matchWholeWordsSelect.on('input', async function () { |
| 3006 | const uid = $(this).data('uid'); | 3007 | const uid = $(this).data('uid'); |
| 3007 | const value = $(this).val(); | 3008 | const value = $(this).val(); |
| 3008 | 3009 | ||
| 3009 | data.entries[uid].matchWholeWords = value === 'null' ? null : value === 'true'; | 3010 | data.entries[uid].matchWholeWords = value === 'null' ? null : value === 'true'; |
| 3010 | setOriginalDataValue(data, uid, 'extensions.match_whole_words', data.entries[uid].matchWholeWords); | 3011 | setOriginalDataValue(data, uid, 'extensions.match_whole_words', data.entries[uid].matchWholeWords); |
| 3011 | saveWorldInfo(name, data); | 3012 | await saveWorldInfo(name, data); |
| 3012 | }); | 3013 | }); |
| 3013 | matchWholeWordsSelect.val((entry.matchWholeWords === null || entry.matchWholeWords === undefined) ? 'null' : entry.matchWholeWords ? 'true' : 'false').trigger('input'); | 3014 | matchWholeWordsSelect.val((entry.matchWholeWords === null || entry.matchWholeWords === undefined) ? 'null' : entry.matchWholeWords ? 'true' : 'false').trigger('input'); |
| 3014 | 3015 | ||
| 3015 | // use group scoring select | 3016 | // use group scoring select |
| 3016 | const useGroupScoringSelect = template.find('select[name="useGroupScoring"]'); | 3017 | const useGroupScoringSelect = template.find('select[name="useGroupScoring"]'); |
| 3017 | useGroupScoringSelect.data('uid', entry.uid); | 3018 | useGroupScoringSelect.data('uid', entry.uid); |
| 3018 | useGroupScoringSelect.on('input', function () { | 3019 | useGroupScoringSelect.on('input', async function () { |
| 3019 | const uid = $(this).data('uid'); | 3020 | const uid = $(this).data('uid'); |
| 3020 | const value = $(this).val(); | 3021 | const value = $(this).val(); |
| 3021 | 3022 | ||
| 3022 | data.entries[uid].useGroupScoring = value === 'null' ? null : value === 'true'; | 3023 | data.entries[uid].useGroupScoring = value === 'null' ? null : value === 'true'; |
| 3023 | setOriginalDataValue(data, uid, 'extensions.use_group_scoring', data.entries[uid].useGroupScoring); | 3024 | setOriginalDataValue(data, uid, 'extensions.use_group_scoring', data.entries[uid].useGroupScoring); |
| 3024 | saveWorldInfo(name, data); | 3025 | await saveWorldInfo(name, data); |
| 3025 | }); | 3026 | }); |
| 3026 | useGroupScoringSelect.val((entry.useGroupScoring === null || entry.useGroupScoring === undefined) ? 'null' : entry.useGroupScoring ? 'true' : 'false').trigger('input'); | 3027 | useGroupScoringSelect.val((entry.useGroupScoring === null || entry.useGroupScoring === undefined) ? 'null' : entry.useGroupScoring ? 'true' : 'false').trigger('input'); |
| 3027 | 3028 | ||
| 3028 | // automation id | 3029 | // automation id |
| 3029 | const automationIdInput = template.find('input[name="automationId"]'); | 3030 | const automationIdInput = template.find('input[name="automationId"]'); |
| 3030 | automationIdInput.data('uid', entry.uid); | 3031 | automationIdInput.data('uid', entry.uid); |
| 3031 | automationIdInput.on('input', function () { | 3032 | automationIdInput.on('input', async function () { |
| 3032 | const uid = $(this).data('uid'); | 3033 | const uid = $(this).data('uid'); |
| 3033 | const value = $(this).val(); | 3034 | const value = $(this).val(); |
| 3034 | 3035 | ||
| 3035 | data.entries[uid].automationId = value; | 3036 | data.entries[uid].automationId = value; |
| 3036 | setOriginalDataValue(data, uid, 'extensions.automation_id', data.entries[uid].automationId); | 3037 | setOriginalDataValue(data, uid, 'extensions.automation_id', data.entries[uid].automationId); |
| 3037 | saveWorldInfo(name, data); | 3038 | await saveWorldInfo(name, data); |
| 3038 | }); | 3039 | }); |
| 3039 | automationIdInput.val(entry.automationId ?? '').trigger('input'); | 3040 | automationIdInput.val(entry.automationId ?? '').trigger('input'); |
| 3040 | setTimeout(() => createEntryInputAutocomplete(automationIdInput, getAutomationIdCallback(data)), 1); | 3041 | setTimeout(() => createEntryInputAutocomplete(automationIdInput, getAutomationIdCallback(data)), 1); |