mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix A/N and CFG menus on first in the list
This commit is contained in:
@@ -389,7 +389,11 @@ export function setFloatingPrompt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onANMenuItemClick() {
|
function onANMenuItemClick() {
|
||||||
if (selected_group || this_chid) {
|
if (!selected_group && this_chid === undefined) {
|
||||||
|
toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//show AN if it's hidden
|
//show AN if it's hidden
|
||||||
if ($('#floatingPrompt').css('display') !== 'flex') {
|
if ($('#floatingPrompt').css('display') !== 'flex') {
|
||||||
$('#floatingPrompt').addClass('resizing');
|
$('#floatingPrompt').addClass('resizing');
|
||||||
@@ -416,22 +420,18 @@ function onANMenuItemClick() {
|
|||||||
$('#floatingPrompt').transition({
|
$('#floatingPrompt').transition({
|
||||||
opacity: 0.0,
|
opacity: 0.0,
|
||||||
duration: animation_duration,
|
duration: animation_duration,
|
||||||
},
|
}, async function () {
|
||||||
async function () {
|
|
||||||
await delay(50);
|
await delay(50);
|
||||||
$('#floatingPrompt').removeClass('resizing');
|
$('#floatingPrompt').removeClass('resizing');
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('#floatingPrompt').hide();
|
$('#floatingPrompt').hide();
|
||||||
}, animation_duration);
|
}, animation_duration);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//duplicate options menu close handler from script.js
|
//duplicate options menu close handler from script.js
|
||||||
//because this listener takes priority
|
//because this listener takes priority
|
||||||
$('#options').stop().fadeOut(animation_duration);
|
$('#options').stop().fadeOut(animation_duration);
|
||||||
} else {
|
|
||||||
toastr.warning(t`Select a character before trying to use Author's Note`, '', { timeOut: 2000 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onChatChanged() {
|
async function onChatChanged() {
|
||||||
|
@@ -40,7 +40,7 @@ function setCharCfg(tempValue, setting) {
|
|||||||
name: avatarName,
|
name: avatarName,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(setting) {
|
switch (setting) {
|
||||||
case settingType.guidance_scale:
|
case settingType.guidance_scale:
|
||||||
tempCharaCfg['guidance_scale'] = Number(tempValue);
|
tempCharaCfg['guidance_scale'] = Number(tempValue);
|
||||||
break;
|
break;
|
||||||
@@ -69,8 +69,7 @@ function setCharCfg(tempValue, setting) {
|
|||||||
if (!existingCharaCfg.useChara &&
|
if (!existingCharaCfg.useChara &&
|
||||||
(tempAssign.guidance_scale ?? 1.00) === 1.00 &&
|
(tempAssign.guidance_scale ?? 1.00) === 1.00 &&
|
||||||
(tempAssign.negative_prompt?.length ?? 0) === 0 &&
|
(tempAssign.negative_prompt?.length ?? 0) === 0 &&
|
||||||
(tempAssign.positive_prompt?.length ?? 0) === 0)
|
(tempAssign.positive_prompt?.length ?? 0) === 0) {
|
||||||
{
|
|
||||||
extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1);
|
extension_settings.cfg.chara.splice(existingCharaCfgIndex, 1);
|
||||||
}
|
}
|
||||||
} else if (avatarName && tempValue.length > 0) {
|
} else if (avatarName && tempValue.length > 0) {
|
||||||
@@ -92,7 +91,7 @@ function setCharCfg(tempValue, setting) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setChatCfg(tempValue, setting) {
|
function setChatCfg(tempValue, setting) {
|
||||||
switch(setting) {
|
switch (setting) {
|
||||||
case settingType.guidance_scale:
|
case settingType.guidance_scale:
|
||||||
chat_metadata[metadataKeys.guidance_scale] = tempValue;
|
chat_metadata[metadataKeys.guidance_scale] = tempValue;
|
||||||
break;
|
break;
|
||||||
@@ -113,7 +112,11 @@ function setChatCfg(tempValue, setting) {
|
|||||||
|
|
||||||
// TODO: Only change CFG when character is selected
|
// TODO: Only change CFG when character is selected
|
||||||
function onCfgMenuItemClick() {
|
function onCfgMenuItemClick() {
|
||||||
if (selected_group || this_chid) {
|
if (!selected_group && this_chid === undefined) {
|
||||||
|
toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//show CFG config if it's hidden
|
//show CFG config if it's hidden
|
||||||
if ($('#cfgConfig').css('display') !== 'flex') {
|
if ($('#cfgConfig').css('display') !== 'flex') {
|
||||||
$('#cfgConfig').addClass('resizing');
|
$('#cfgConfig').addClass('resizing');
|
||||||
@@ -140,8 +143,7 @@ function onCfgMenuItemClick() {
|
|||||||
$('#cfgConfig').transition({
|
$('#cfgConfig').transition({
|
||||||
opacity: 0.0,
|
opacity: 0.0,
|
||||||
duration: animation_duration,
|
duration: animation_duration,
|
||||||
},
|
}, async function () {
|
||||||
async function () {
|
|
||||||
await delay(50);
|
await delay(50);
|
||||||
$('#cfgConfig').removeClass('resizing');
|
$('#cfgConfig').removeClass('resizing');
|
||||||
});
|
});
|
||||||
@@ -153,9 +155,6 @@ function onCfgMenuItemClick() {
|
|||||||
//duplicate options menu close handler from script.js
|
//duplicate options menu close handler from script.js
|
||||||
//because this listener takes priority
|
//because this listener takes priority
|
||||||
$('#options').stop().fadeOut(animation_duration);
|
$('#options').stop().fadeOut(animation_duration);
|
||||||
} else {
|
|
||||||
toastr.warning('Select a character before trying to configure CFG', '', { timeOut: 2000 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onChatChanged() {
|
async function onChatChanged() {
|
||||||
@@ -288,7 +287,7 @@ export function initCfg() {
|
|||||||
setTimeout(function () { $('#cfgConfig').hide(); }, animation_duration);
|
setTimeout(function () { $('#cfgConfig').hide(); }, animation_duration);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chat_cfg_guidance_scale').on('input', function() {
|
$('#chat_cfg_guidance_scale').on('input', function () {
|
||||||
const numberValue = Number($(this).val());
|
const numberValue = Number($(this).val());
|
||||||
const success = setChatCfg(numberValue, settingType.guidance_scale);
|
const success = setChatCfg(numberValue, settingType.guidance_scale);
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -296,15 +295,15 @@ export function initCfg() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chat_cfg_negative_prompt').on('input', function() {
|
$('#chat_cfg_negative_prompt').on('input', function () {
|
||||||
setChatCfg($(this).val(), settingType.negative_prompt);
|
setChatCfg($(this).val(), settingType.negative_prompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chat_cfg_positive_prompt').on('input', function() {
|
$('#chat_cfg_positive_prompt').on('input', function () {
|
||||||
setChatCfg($(this).val(), settingType.positive_prompt);
|
setChatCfg($(this).val(), settingType.positive_prompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chara_cfg_guidance_scale').on('input', function() {
|
$('#chara_cfg_guidance_scale').on('input', function () {
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
const success = setCharCfg(value, settingType.guidance_scale);
|
const success = setCharCfg(value, settingType.guidance_scale);
|
||||||
if (success) {
|
if (success) {
|
||||||
@@ -312,34 +311,34 @@ export function initCfg() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chara_cfg_negative_prompt').on('input', function() {
|
$('#chara_cfg_negative_prompt').on('input', function () {
|
||||||
setCharCfg($(this).val(), settingType.negative_prompt);
|
setCharCfg($(this).val(), settingType.negative_prompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chara_cfg_positive_prompt').on('input', function() {
|
$('#chara_cfg_positive_prompt').on('input', function () {
|
||||||
setCharCfg($(this).val(), settingType.positive_prompt);
|
setCharCfg($(this).val(), settingType.positive_prompt);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#global_cfg_guidance_scale').on('input', function() {
|
$('#global_cfg_guidance_scale').on('input', function () {
|
||||||
extension_settings.cfg.global.guidance_scale = Number($(this).val());
|
extension_settings.cfg.global.guidance_scale = Number($(this).val());
|
||||||
$('#global_cfg_guidance_scale_counter').val(extension_settings.cfg.global.guidance_scale.toFixed(2));
|
$('#global_cfg_guidance_scale_counter').val(extension_settings.cfg.global.guidance_scale.toFixed(2));
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#global_cfg_negative_prompt').on('input', function() {
|
$('#global_cfg_negative_prompt').on('input', function () {
|
||||||
extension_settings.cfg.global.negative_prompt = $(this).val();
|
extension_settings.cfg.global.negative_prompt = $(this).val();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#global_cfg_positive_prompt').on('input', function() {
|
$('#global_cfg_positive_prompt').on('input', function () {
|
||||||
extension_settings.cfg.global.positive_prompt = $(this).val();
|
extension_settings.cfg.global.positive_prompt = $(this).val();
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input[name="cfg_prompt_combine"]').on('input', function() {
|
$('input[name="cfg_prompt_combine"]').on('input', function () {
|
||||||
const values = $('#cfgConfig').find('input[name="cfg_prompt_combine"]')
|
const values = $('#cfgConfig').find('input[name="cfg_prompt_combine"]')
|
||||||
.filter(':checked')
|
.filter(':checked')
|
||||||
.map(function() { return Number($(this).val()); })
|
.map(function () { return Number($(this).val()); })
|
||||||
.get()
|
.get()
|
||||||
.filter((e) => !Number.isNaN(e)) || [];
|
.filter((e) => !Number.isNaN(e)) || [];
|
||||||
|
|
||||||
@@ -347,17 +346,17 @@ export function initCfg() {
|
|||||||
saveMetadataDebounced();
|
saveMetadataDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cfg_prompt_insertion_depth').on('input', function() {
|
$('#cfg_prompt_insertion_depth').on('input', function () {
|
||||||
chat_metadata[metadataKeys.prompt_insertion_depth] = Number($(this).val());
|
chat_metadata[metadataKeys.prompt_insertion_depth] = Number($(this).val());
|
||||||
saveMetadataDebounced();
|
saveMetadataDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cfg_prompt_separator').on('input', function() {
|
$('#cfg_prompt_separator').on('input', function () {
|
||||||
chat_metadata[metadataKeys.prompt_separator] = $(this).val();
|
chat_metadata[metadataKeys.prompt_separator] = $(this).val();
|
||||||
saveMetadataDebounced();
|
saveMetadataDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#groupchat_cfg_use_chara').on('input', function() {
|
$('#groupchat_cfg_use_chara').on('input', function () {
|
||||||
const checked = !!$(this).prop('checked');
|
const checked = !!$(this).prop('checked');
|
||||||
chat_metadata[metadataKeys.groupchat_individual_chars] = checked;
|
chat_metadata[metadataKeys.groupchat_individual_chars] = checked;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user