mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
New character renaming logic
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
api_server_textgenerationwebui,
|
||||
is_send_press,
|
||||
getTokenCount,
|
||||
max_context,
|
||||
selected_button,
|
||||
|
||||
} from "../script.js";
|
||||
|
||||
@@ -148,7 +148,7 @@ $("#character_popup").on("input", function () { RA_CountCharTokens(); });
|
||||
function RA_CountCharTokens() {
|
||||
$("#result_info").html("");
|
||||
//console.log('RA_TC -- starting with this_chid = ' + this_chid);
|
||||
if (document.getElementById('name_div').style.display == "block") { //if new char
|
||||
if (selected_button === "create") { //if new char
|
||||
function saveFormVariables() {
|
||||
create_save_name = $("#character_name_pole").val();
|
||||
create_save_description = $("#description_textarea").val();
|
||||
|
@@ -9,6 +9,8 @@ export {
|
||||
isElementTagged,
|
||||
getTagsList,
|
||||
appendTagToList,
|
||||
createTagMapFromList,
|
||||
renameTagKey,
|
||||
};
|
||||
|
||||
const random_id = () => Math.round(Date.now() * Math.random()).toString();
|
||||
@@ -30,6 +32,19 @@ function loadTagsSettings(settings) {
|
||||
tag_map = settings.tag_map !== undefined ? settings.tag_map : Object.create(null);
|
||||
}
|
||||
|
||||
function renameTagKey(oldKey, newKey) {
|
||||
const value = tag_map[oldKey];
|
||||
tag_map[newKey] = value || [];
|
||||
delete tag_map[oldKey];
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function createTagMapFromList(listElement, key) {
|
||||
const tagIds = [...($(listElement).find(".tag").map((_, el) => $(el).attr("id")))];
|
||||
tag_map[key] = tagIds;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
function getTagsList(key) {
|
||||
if (!Array.isArray(tag_map[key])) {
|
||||
tag_map[key] = [];
|
||||
|
Reference in New Issue
Block a user