From 6bc9535040bb8f5cab64a4c7c0bfb86dcbc5acb7 Mon Sep 17 00:00:00 2001 From: kingbri Date: Sun, 2 Jul 2023 23:14:23 -0400 Subject: [PATCH] Popups: Allow substitution of primary button This allows for more flexible popups with options rather than implementing a brand new popup just to change button text. Signed-off-by: kingbri --- public/script.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/script.js b/public/script.js index ff21505ee..332bf7c43 100644 --- a/public/script.js +++ b/public/script.js @@ -5330,7 +5330,7 @@ function onScenarioOverrideRemoveClick() { $(this).closest('.scenario_override').find('.chat_scenario').val('').trigger('input'); } -function callPopup(text, type, inputValue = '') { +function callPopup(text, type, inputValue = '', okButton) { if (type) { popup_type = type; } @@ -5338,30 +5338,30 @@ function callPopup(text, type, inputValue = '') { $("#dialogue_popup_cancel").css("display", "inline-block"); switch (popup_type) { case "avatarToCrop": - $("#dialogue_popup_ok").text("Accept"); + $("#dialogue_popup_ok").text(okButton ?? "Accept"); break; case "text": case "alternate_greeting": case "char_not_selected": - $("#dialogue_popup_ok").text("Ok"); + $("#dialogue_popup_ok").text(okButton ?? "Ok"); $("#dialogue_popup_cancel").css("display", "none"); break; case "new_chat": case "confirm": - $("#dialogue_popup_ok").text("Yes"); + $("#dialogue_popup_ok").text(okButton ?? "Yes"); break; case "del_group": case "rename_chat": case "del_chat": default: - $("#dialogue_popup_ok").text("Delete"); + $("#dialogue_popup_ok").text(okButton ?? "Delete"); } $("#dialogue_popup_input").val(inputValue); if (popup_type == 'input') { $("#dialogue_popup_input").css("display", "block"); - $("#dialogue_popup_ok").text("Save"); + $("#dialogue_popup_ok").text(okButton ?? "Save"); } else { $("#dialogue_popup_input").css("display", "none");