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