diff --git a/public/index.html b/public/index.html index 125d1b6a6..8a791e489 100644 --- a/public/index.html +++ b/public/index.html @@ -5123,23 +5123,6 @@ -
-
-
-

Chat Scenario Override

- -
-
- Unique to this chat. - All group members will use the following scenario text instead of what is specified in their character cards. - The following scenario text will be used instead of the value set in the character card. - Checkpoints inherit the scenario override from their parent, and can be changed individually after that. -
-
- -
-
-
diff --git a/public/script.js b/public/script.js index 333ec43c7..5a08e7cfb 100644 --- a/public/script.js +++ b/public/script.js @@ -7184,20 +7184,23 @@ function updateFavButtonState(state) { $('#favorite_button').toggleClass('fav_off', !fav_ch_checked); } -export function setScenarioOverride() { +export async function setScenarioOverride() { if (!selected_group && !this_chid) { console.warn('setScenarioOverride() -- no selected group or character'); return; } - const template = $('#scenario_override_template .scenario_override').clone(); const metadataValue = chat_metadata['scenario'] || ''; const isGroup = !!selected_group; - template.find('[data-group="true"]').toggle(isGroup); - template.find('[data-character="true"]').toggle(!isGroup); - template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput); - template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick); - callPopup(template, 'text'); + + const $template = $(await renderTemplateAsync('scenarioOverride')); + $template.find('[data-group="true"]').toggle(isGroup); + $template.find('[data-character="true"]').toggle(!isGroup); + // TODO: Why does this save on every character input? Save on popup close + $template.find('.chat_scenario').val(metadataValue).on('input', onScenarioOverrideInput); + $template.find('.remove_scenario_override').on('click', onScenarioOverrideRemoveClick); + + await callGenericPopup($template, POPUP_TYPE.TEXT, ''); } function onScenarioOverrideInput() { @@ -10653,7 +10656,7 @@ jQuery(async function () { openCharacterWorldPopup(); break; case 'set_chat_scenario': - setScenarioOverride(); + await setScenarioOverride(); break; case 'renameCharButton': renameCharacter(); @@ -10674,7 +10677,7 @@ jQuery(async function () { const source = getCharacterSource(this_chid); if (source && isValidUrl(source)) { const url = new URL(source); - const confirm = await callPopup(`Open ${url.hostname} in a new tab?`, 'confirm'); + const confirm = await Popup.show.confirm('Open Source', `Do you want to open the link to ${url.hostname} in a new tab?${url}`); if (confirm) { window.open(source, '_blank'); } @@ -10683,7 +10686,7 @@ jQuery(async function () { } } break; case 'replace_update': { - const confirm = await callPopup('

Choose a new character card to replace this character with.

All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.

Proceed?

', 'confirm', ''); + const confirm = await Popup.show.confirm('Replace Character', '

Choose a new character card to replace this character with.

All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.
Proceed?'); if (confirm) { async function uploadReplacementCard(e) { const file = e.target.files[0]; diff --git a/public/scripts/personas.js b/public/scripts/personas.js index 3ed28b95e..701d84264 100644 --- a/public/scripts/personas.js +++ b/public/scripts/personas.js @@ -395,9 +395,8 @@ export async function convertCharacterToPersona(characterId = null) { const overwriteName = `${name} (Persona).png`; if (overwriteName in power_user.personas) { - const confirmation = await callPopup('This character exists as a persona already. Are you sure want to overwrite it?', 'confirm', '', { okButton: 'Yes' }); - - if (confirmation === false) { + const confirm = await Popup.show.confirm('Overwrite Existing Persona', 'This character exists as a persona already. Do you want to overwrite it?'); + if (!confirm) { console.log('User cancelled the overwrite of the persona'); return; } @@ -405,9 +404,8 @@ export async function convertCharacterToPersona(characterId = null) { if (description.includes('{{char}}') || description.includes('{{user}}')) { await delay(500); - const confirmation = await callPopup('This character has a description that uses {{char}} or {{user}} macros. Do you want to swap them in the persona description?', 'confirm', '', { okButton: 'Yes' }); - - if (confirmation) { + const confirm = await Popup.show.confirm('Persona Description Macros', 'This character has a description that uses {{char}} or {{user}} macros. Do you want to swap them in the persona description?'); + if (confirm) { description = description.replace(/{{char}}/gi, '{{personaChar}}').replace(/{{user}}/gi, '{{personaUser}}'); description = description.replace(/{{personaUser}}/gi, '{{char}}').replace(/{{personaChar}}/gi, '{{user}}'); } diff --git a/public/scripts/templates/scenarioOverride.html b/public/scripts/templates/scenarioOverride.html new file mode 100644 index 000000000..997ac5bf7 --- /dev/null +++ b/public/scripts/templates/scenarioOverride.html @@ -0,0 +1,17 @@ +
+
+

Chat Scenario Override

+ +
+
+ Unique to this chat. + All group members will use the following scenario text instead of what is specified in their character cards. + The following scenario text will be used instead of the value set in the character card. + Checkpoints inherit the scenario override from their parent, and can be changed individually after that. +
+
+ +
+