diff --git a/public/index.html b/public/index.html index adc975d69..00290a46a 100644 --- a/public/index.html +++ b/public/index.html @@ -2994,10 +2994,6 @@ Save bookmark - - - Author's Note - Convert to group diff --git a/public/script.js b/public/script.js index 8be370225..b268ba659 100644 --- a/public/script.js +++ b/public/script.js @@ -6221,36 +6221,6 @@ $(document).ready(function () { $("#options [id]").on("click", function () { var id = $(this).attr("id"); - if (id == "option_toggle_AN") { - if (selected_group || this_chid) { - if ($("#floatingPrompt").css("display") !== 'flex') { - $("#floatingPrompt").css("display", "flex"); - $("#floatingPrompt").css("opacity", 0.0); - $("#floatingPrompt").transition({ - opacity: 1.0, - duration: 250, - easing: animation_easing, - }); - - if ($("#ANBlockToggle") - .siblings('.inline-drawer-content') - .css('display') !== 'block') { - $("#ANBlockToggle").click(); - } - } else { - $("#floatingPrompt").transition({ - opacity: 0.0, - duration: 250, - easing: animation_easing, - }); - setTimeout(function () { - $("#floatingPrompt").hide(); - }, 250); - - } - } - } - if (id == "option_select_chat") { if ((selected_group && !is_group_generating) || (this_chid !== undefined && !is_send_press)) { displayPastChats(); diff --git a/public/scripts/extensions/floating-prompt/index.js b/public/scripts/extensions/floating-prompt/index.js index 2e4f30537..29debda8c 100644 --- a/public/scripts/extensions/floating-prompt/index.js +++ b/public/scripts/extensions/floating-prompt/index.js @@ -1,4 +1,5 @@ -import { chat_metadata, saveSettingsDebounced } from "../../../script.js"; +import { chat_metadata, saveSettingsDebounced, this_chid } from "../../../script.js"; +import { selected_group } from "../../group-chats.js"; import { ModuleWorkerWrapper, extension_settings, getContext, saveMetadataDebounced } from "../../extensions.js"; import { registerSlashCommand } from "../../slash-commands.js"; export { MODULE_NAME }; @@ -139,6 +140,36 @@ async function moduleWorker() { $('#extension_floating_counter').text(shouldAddPrompt ? '0' : messagesTillInsertion); } +function onANMenuItemClick() { + if (selected_group || this_chid) { + if ($("#floatingPrompt").css("display") !== 'flex') { + $("#floatingPrompt").css("display", "flex"); + $("#floatingPrompt").css("opacity", 0.0); + $("#floatingPrompt").transition({ + opacity: 1.0, + duration: 250, + }); + + if ($("#ANBlockToggle") + .siblings('.inline-drawer-content') + .css('display') !== 'block') { + $("#ANBlockToggle").click(); + } + } else { + $("#floatingPrompt").transition({ + opacity: 0.0, + duration: 250, + }); + setTimeout(function () { + $("#floatingPrompt").hide(); + }, 250); + + } + } else { + toastr.warning(`Select a character before trying to use Author's Note`, '', { timeOut: 2000 }); + } +} + (function () { function addExtensionsSettings() { const settingsHtml = ` @@ -200,6 +231,13 @@ async function moduleWorker() { `; + const ANButtonHtml = ` + + + Author's Note + + `; + $('.options-content').prepend(ANButtonHtml); $('#movingDivs').append(settingsHtml); $('#extension_floating_prompt').on('input', onExtensionFloatingPromptInput); $('#extension_floating_interval').on('input', onExtensionFloatingIntervalInput); @@ -214,6 +252,7 @@ async function moduleWorker() { }); setTimeout(function () { $('#floatingPrompt').hide() }, 200); }) + $("#option_toggle_AN").on('click', onANMenuItemClick); } addExtensionsSettings();