add duplicate world info button

This commit is contained in:
LenAnderson
2024-01-09 14:24:26 +00:00
parent 023cbf3cff
commit 1bf1f56b38
2 changed files with 19 additions and 0 deletions

View File

@ -558,6 +558,7 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
$('#world_popup_name_button').off('click').on('click', nullWorldInfo);
$('#world_popup_export').off('click').on('click', nullWorldInfo);
$('#world_popup_delete').off('click').on('click', nullWorldInfo);
$('#world_duplicate').off('click').on('click', nullWorldInfo);
$('#world_popup_entries_list').hide();
$('#world_info_pagination').html('');
return;
@ -695,6 +696,23 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) {
}
});
$('#world_duplicate').off('click').on('click', async () => {
const tempName = getFreeWorldName();
const finalName = await callPopup('<h3>Create a new World Info?</h3>Enter a name for the new file:', 'input', tempName);
if (finalName) {
await saveWorldInfo(finalName, data, true);
await updateWorldInfoList();
const selectedIndex = world_names.indexOf(finalName);
if (selectedIndex !== -1) {
$('#world_editor_select').val(selectedIndex).trigger('change');
} else {
hideWorldEditor();
}
}
});
$('#world_popup_delete').off('click').on('click', async () => {
const confirmation = await callPopup(`<h3>Delete the World/Lorebook: "${name}"?</h3>This action is irreversible!`, 'confirm');