From 0dfe46a1620b3c3bd326cdd10b34d1db9e046dfc Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:56:31 +0300 Subject: [PATCH] Add WI title backfill button --- public/css/world-info.css | 2 +- public/index.html | 1 + public/scripts/world-info.js | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/css/world-info.css b/public/css/world-info.css index 6742ca8fc..f707a17ee 100644 --- a/public/css/world-info.css +++ b/public/css/world-info.css @@ -159,7 +159,7 @@ #world_info_search, #world_info_sort_order { - width: 8em; + width: 7em; } .wi-card-entry { diff --git a/public/index.html b/public/index.html index c9464d594..593325cf6 100644 --- a/public/index.html +++ b/public/index.html @@ -2745,6 +2745,7 @@
+ diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 1d66be1a8..aad1fe4e5 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -400,6 +400,23 @@ function displayWorldEntries(name, data, navigation = navigation_option.none) { await renameWorldInfo(name, data); }); + $("#world_backfill_memos").off('click').on('click', async () => { + let counter = 0; + for (const entry of Object.values(data.entries)) { + if (!entry.comment && Array.isArray(entry.key) && entry.key.length > 0) { + entry.comment = entry.key[0]; + setOriginalDataValue(data, entry.uid, "comment", entry.comment); + counter++; + } + } + + if (counter > 0) { + toastr.info(`Backfilled ${counter} titles`); + await saveWorldInfo(name, data, true); + updateEditor(navigation_option.previous); + } + }); + $("#world_popup_export").off('click').on('click', () => { if (name && data) { const jsonValue = JSON.stringify(data);