This commit is contained in:
SillyLossy
2023-05-16 16:28:42 +03:00
6 changed files with 147 additions and 79 deletions

View File

@ -2477,6 +2477,7 @@
<div id="typing_indicator_template" class="template_element">
<div class="typing_indicator"><span class="typing_indicator_name">CHAR</span> is typing</div>
</div>
<div id="movingDivs"></div>
<div id="sheld">
<div id="sheldheader" class="fa-solid fa-grip drag-grabber"></div>
<!-- <div class="pull-tab"></div> -->
@ -2516,6 +2517,10 @@
<i class="fa-lg fa-solid fa-bookmark"></i>
<span>Save bookmark</span>
</a>
<a id="option_toggle_AN">
<i class="fa-lg fa-solid fa-note-sticky"></i>
<span>Open Author's Note</span>
</a>
<a id="option_convert_to_group">
<i class="fa-lg fa-solid fa-people-arrows"></i>
<span>Convert to group</span>

View File

@ -5578,6 +5578,27 @@ $(document).ready(function () {
$("#options [id]").on("click", function () {
var id = $(this).attr("id");
if (id == "option_toggle_AN") {
if (selected_group || this_chid !== undefined && $("#floatingPrompt").css("display") === 'none') {
$("#floatingPrompt").css("display", "flex");
$("#floatingPrompt").css("opacity", 0.0);
$("#floatingPrompt").transition({
opacity: 1.0,
duration: animation_duration,
easing: animation_easing,
});
$("#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();

View File

@ -106,10 +106,20 @@ function waitForElement(querySelector, timeout) {
waitForElement("#expression-image", 10000).then(function () {
dragElement(document.getElementById("expression-holder"));
dragElement(document.getElementById("floatingPrompt"));
}).catch(() => {
console.log("expression holder not loaded yet");
});
waitForElement("#floatingPrompt", 10000).then(function () {
dragElement(document.getElementById("floatingPrompt"));
}).catch(() => {
console.log("floating prompt box not loaded yet");
});
// Device detection
const deviceInfo = await getDeviceInfo();
@ -443,6 +453,7 @@ dragElement(document.getElementById("WorldInfo"));
function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
if (document.getElementById(elmnt.id + "header")) { //ex: id="sheldheader"
// if present, the header is where you move the DIV from, but this overrides everything else:
@ -453,6 +464,7 @@ function dragElement(elmnt) {
}
function dragMouseDown(e) {
//console.log(e);
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:

View File

@ -100,7 +100,7 @@ async function moduleWorker() {
if (lastMessageNumber <= 0 || chat_metadata[metadata_keys.interval] <= 0) {
context.setExtensionPrompt(MODULE_NAME, '');
$('#extension_floating_counter').text('No');
$('#extension_floating_counter').text('(disabled)');
return;
}
@ -110,25 +110,28 @@ async function moduleWorker() {
const shouldAddPrompt = messagesTillInsertion == 0;
const prompt = shouldAddPrompt ? $('#extension_floating_prompt').val() : '';
context.setExtensionPrompt(MODULE_NAME, prompt, chat_metadata[metadata_keys.position], chat_metadata[metadata_keys.depth]);
$('#extension_floating_counter').text(shouldAddPrompt ? 'This' : messagesTillInsertion);
$('#extension_floating_counter').text(shouldAddPrompt ? '0' : messagesTillInsertion);
}
(function () {
function addExtensionsSettings() {
const settingsHtml = `
<div class="floating_prompt_settings">
<div id="floatingPrompt" class="drawer-content flexGap5">
<div id="floatingPromptheader" class="fa-solid fa-grip drag-grabber"></div>
<div name="floatingPromptHolder">
<div class="inline-drawer">
<div class="inline-drawer-toggle inline-drawer-header">
<b>Author's Note / Character Bias</b>
<div id="ANBlockToggle" class="inline-drawer-toggle inline-drawer-header">
<b>Author's Note</b>
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div>
<div class="inline-drawer-content">
<small>
Your notes are saved <b>PER CHAT</b>. When you start a new chat, you'll see the default / empty note.<br>
Saving a bookmark will copy your note to a bookmark chat. Making changes to it won't update the note in a parent chat.<br>
<b>Unique to this chat</b>.<br>
Bookmarks inherit the Note from their parent, and can be changed individually after that.<br>
</small>
<label for="extension_floating_prompt">Append the following text:</label>
<textarea id="extension_floating_prompt" class="text_pole" rows="8"></textarea>
<div class="floating_prompt_radio_group">
<label>
<input type="radio" name="extension_floating_position" value="0" />
@ -136,31 +139,38 @@ async function moduleWorker() {
</label>
<label>
<input type="radio" name="extension_floating_position" value="1" />
In-chat
In-chat @ Depth <input id="extension_floating_depth" class="text_pole" type="number" min="0" max="99" />
</label>
</div>
<label for="extension_floating_interval">Every N messages <b>you</b> send (set to 0 to disable):</label>
<input id="extension_floating_interval" class="text_pole" type="number" min="0" max="999" />
<label for="extension_floating_interval">Insertion depth (for in-chat positioning):</label>
<input id="extension_floating_depth" class="text_pole" type="number" min="0" max="99" />
<span>Appending to the prompt in next: <span id="extension_floating_counter">No</span> message(s)</span>
<!--<label for="extension_floating_interval">In-Chat Insertion Depth</label>-->
<label for="extension_floating_interval">Insertion Frequency</label>
<input id="extension_floating_interval" class="text_pole" type="number" min="0" max="999" /><small> (0 = Disable)</small>
<br>
<span>User inputs until next insertion: <span id="extension_floating_counter">(disabled)</span></span>
</div>
</div>
<hr class="sysHR">
<div class="inline-drawer">
<div class="inline-drawer-toggle inline-drawer-header">
<b>Default note for new chats</b>
<div id="defaultANBlockToggle" class="inline-drawer-toggle inline-drawer-header">
<b>Default Author's Note</b>
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
</div>
<div class="inline-drawer-content">
<label for="extension_floating_default">Default Author's Note</label>
<small>Will be automatically added as the Author's Note for all new chats.</small>
<textarea id="extension_floating_default" class="text_pole" rows="8"
placeholder="Example:\n[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
</div>
</div>
</div>
</div>
`;
$('#extensions_settings').append(settingsHtml);
$('#movingDivs').append(settingsHtml);
$('#extension_floating_prompt').on('input', onExtensionFloatingPromptInput);
$('#extension_floating_interval').on('input', onExtensionFloatingIntervalInput);
$('#extension_floating_depth').on('input', onExtensionFloatingDepthInput);

View File

@ -1,4 +1,26 @@
.floating_prompt_settings {
#floatingPrompt {
overflow-y: auto;
max-width: 90svw;
max-height: 90svh;
min-width: 100px;
min-height: 100px;
border-radius: 10px;
border: 1px solid var(--white30a);
position: fixed;
padding: 10px;
display: none;
flex-direction: column;
box-shadow: 0 0 10px var(--black70a);
z-index: 3000;
left: 0;
top: 0;
margin: 0;
right: unset;
width: calc(((100svw - var(--sheldWidth)) / 2) - 1px);
}
.floating_prompt_radio_group {
display: flex;
flex-direction: column;
}
@ -12,8 +34,3 @@
font-size: calc(var(--mainFontSize) * 0.9);
line-height: 1.2;
}
.floating_prompt_radio_group {
display: flex;
flex-direction: column;
}

View File

@ -845,7 +845,7 @@ select {
font-family: "Noto Sans", "Noto Color Emoji", sans-serif;
padding: 7px;
width: 100%;
/* width: 100%; */
margin: 5px 0;
}
@ -3526,11 +3526,13 @@ label[for="extensions_autoconnect"] {
backdrop-filter: blur(calc(var(--SmartThemeBlurStrength)));
-webkit-backdrop-filter: blur(calc(var(--SmartThemeBlurStrength)));
z-index: 9999 !important;
border: 1px solid var(--white30a);
}
.fillRight,
.fillLeft,
#WorldInfo {
#WorldInfo,
#floatingPrompt {
min-width: unset;
position: fixed;
}
@ -3887,7 +3889,8 @@ body.movingUI .drag-grabber {
body.movingUI #sheld,
body.movingUI .drawer-content,
body.movingUI #expression-holder,
body.movingUI #avatar_zoom_popup {
body.movingUI #avatar_zoom_popup,
body.movingUI #floatingPrompt {
resize: both;
}