Update char submenu popups to new popup - Update 'Scenario Override' - Update 'Open Source' - Update 'Replace Character' - Update 'Convert to Persona' popups

af157942221c7aa94a0a7dba9c5223c3bc13ad99

Wolfsblvt <wolfsblvt@gmail.com>

4 files changed, +34 -33Showing whitespace changes
public/index.html+0 -17
@@ -5123,23 +5123,6 @@
51235123 </div>
51245124 </div>
51255125 <!-- templates for JS to reuse when needed -->
5126- <div id="scenario_override_template" class="template_element">
5127- <div class="scenario_override range-block flexFlowColumn flex-container">
5128- <div class="range-block-title title_restorable">
5129- <h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3>
5130- <div title="Remove" data-i18n="[title]Remove" class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
5131- </div>
5132- <div class="range-block-counter justifyLeft flex-container flexFlowColumn">
5133- <strong>Unique to this chat.</strong>
5134- <span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span>
5135- <span data-character="true">The following scenario text will be used instead of the value set in the character card.</span>
5136- Checkpoints inherit the scenario override from their parent, and can be changed individually after that.
5137- </div>
5138- <div class="range-block-range wide100p">
5139- <textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..." placeholder="Type here..."></textarea>
5140- </div>
5141- </div>
5142- </div>
51435126 <div id="chat_world_template" class="template_element">
51445127 <div class="chat_world range-block flexFlowColumn flex-container">
51455128 <div class="range-block-title">
public/script.js+13 -10
@@ -7184,20 +7184,23 @@ function updateFavButtonState(state) {
71847184 $('#favorite_button').toggleClass('fav_off', !fav_ch_checked);
71857185}
71867186
71877187export async function setScenarioOverride() {
71887188 if (!selected_group && !this_chid) {
71897189 console.warn('setScenarioOverride() -- no selected group or character');
71907190 return;
71917191 }
71927192
7193- const template = $('#scenario_override_template .scenario_override').clone();
71947193 const metadataValue = chat_metadata['scenario'] || '';
71957194 const isGroup = !!selected_group;
7196- template.find('[data-group="true"]').toggle(isGroup);
7195+
7197- template.find('[data-character="true"]').toggle(!isGroup);
7196+ const $template = $(await renderTemplateAsync('scenarioOverride'));
7198- template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput);
7197+ $template.find('[data-group="true"]').toggle(isGroup);
71997198 $template.find('.remove_scenario_override[data-character="true"]').ontoggle('click', onScenarioOverrideRemoveClick!isGroup);
7200- callPopup(template, 'text');
7199+ // TODO: Why does this save on every character input? Save on popup close
7200+ $template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput);
7201+ $template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick);
7202+
7203+ await callGenericPopup($template, POPUP_TYPE.TEXT, '');
72017204}
72027205
72037206function onScenarioOverrideInput() {
@@ -10653,7 +10656,7 @@ jQuery(async function () {
1065310656 openCharacterWorldPopup();
1065410657 break;
1065510658 case 'set_chat_scenario':
1065610659 await setScenarioOverride();
1065710660 break;
1065810661 case 'renameCharButton':
1065910662 renameCharacter();
@@ -10674,7 +10677,7 @@ jQuery(async function () {
1067410677 const source = getCharacterSource(this_chid);
1067510678 if (source && isValidUrl(source)) {
1067610679 const url = new URL(source);
1067710680 const confirm = await callPopupPopup.show.confirm(`'Open Source', `<span>Do you want to open the link to ${url.hostname} in a new tab?</span><var>${url}</var>`, 'confirm');
1067810681 if (confirm) {
1067910682 window.open(source, '_blank');
1068010683 }
@@ -10683,7 +10686,7 @@ jQuery(async function () {
1068310686 }
1068410687 } break;
1068510688 case 'replace_update': {
1068610689 const confirm = await callPopupPopup.show.confirm('Replace Character', '<p><b>Choose a new character card to replace this character with.</b></p><p>All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.<br /p><p>Proceed?</p>', 'confirm', '');
1068710690 if (confirm) {
1068810691 async function uploadReplacementCard(e) {
1068910692 const file = e.target.files[0];
public/scripts/personas.js+4 -6
@@ -395,9 +395,8 @@ export async function convertCharacterToPersona(characterId = null) {
395395 const overwriteName = `${name} (Persona).png`;
396396
397397 if (overwriteName in power_user.personas) {
398398 const confirmationconfirm = await callPopupPopup.show.confirm('Overwrite Existing Persona', 'This character exists as a persona already. AreDo you sure want to overwrite it?', 'confirm', '', { okButton: 'Yes' });
399-
399+ if (!confirm) {
400- if (confirmation === false) {
401400 console.log('User cancelled the overwrite of the persona');
402401 return;
403402 }
@@ -405,9 +404,8 @@ export async function convertCharacterToPersona(characterId = null) {
405404
406405 if (description.includes('{{char}}') || description.includes('{{user}}')) {
407406 await delay(500);
408407 const confirmationconfirm = await callPopupPopup.show.confirm('Persona Description Macros', 'This character has a description that uses <code>{{char}}</code> or <code>{{user}}</code> macros. Do you want to swap them in the persona description?', 'confirm', '', { okButton: 'Yes' });
409-
408+ if (confirm) {
410- if (confirmation) {
411409 description = description.replace(/{{char}}/gi, '{{personaChar}}').replace(/{{user}}/gi, '{{personaUser}}');
412410 description = description.replace(/{{personaUser}}/gi, '{{char}}').replace(/{{personaChar}}/gi, '{{user}}');
413411 }
public/scripts/templates/scenarioOverride.html+17 -0
@@ -0,0 +1,17 @@
1+<div class="scenario_override range-block flexFlowColumn flex-container">
2+ <div class="range-block-title title_restorable">
3+ <h3><span data-i18n="Chat Scenario Override" class="margin0">Chat Scenario Override</span></h3>
4+ <div title="Remove" data-i18n="[title]Remove"
5+ class="menu_button fa-solid fa-trash-can remove_scenario_override"></div>
6+ </div>
7+ <div class="range-block-counter justifyLeft flex-container flexFlowColumn">
8+ <strong>Unique to this chat.</strong>
9+ <span data-group="true">All group members will use the following scenario text instead of what is specified in their character cards.</span>
10+ <span data-character="true">The following scenario text will be used instead of the value set in the character card.</span>
11+ Checkpoints inherit the scenario override from their parent, and can be changed individually after that.
12+ </div>
13+ <div class="range-block-range wide100p">
14+ <textarea class="wide100p chat_scenario" class="text_pole" rows="15" data-i18n="[placeholder]Type here..."
15+ placeholder="Type here..."></textarea>
16+ </div>
17+</div>