mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
optimize Reset Panels, saveSettings emit onSuccess
This commit is contained in:
@ -4650,7 +4650,7 @@ function selectKoboldGuiPreset() {
|
|||||||
|
|
||||||
async function saveSettings(type) {
|
async function saveSettings(type) {
|
||||||
//console.log('Entering settings with name1 = '+name1);
|
//console.log('Entering settings with name1 = '+name1);
|
||||||
eventSource.emit(event_types.SETTINGS_UPDATED);
|
|
||||||
return jQuery.ajax({
|
return jQuery.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/savesettings",
|
url: "/savesettings",
|
||||||
@ -4698,6 +4698,7 @@ async function saveSettings(type) {
|
|||||||
//processData: false,
|
//processData: false,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
//online_status = data.result;
|
//online_status = data.result;
|
||||||
|
eventSource.emit(event_types.SETTINGS_UPDATED);
|
||||||
if (type == "change_name") {
|
if (type == "change_name") {
|
||||||
clearChat();
|
clearChat();
|
||||||
printMessages();
|
printMessages();
|
||||||
|
@ -928,68 +928,43 @@ async function saveTheme() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetMovablePanels() {
|
function resetMovablePanels() {
|
||||||
document.getElementById("sheld").style.top = '';
|
const panelIds = [
|
||||||
document.getElementById("sheld").style.left = '';
|
'sheld',
|
||||||
document.getElementById("sheld").style.bottom = '';
|
'left-nav-panel',
|
||||||
document.getElementById("sheld").style.right = '';
|
'right-nav-panel',
|
||||||
document.getElementById("sheld").style.height = '';
|
'WorldInfo',
|
||||||
document.getElementById("sheld").style.width = '';
|
'floatingPrompt',
|
||||||
document.getElementById("sheld").style.margin = '';
|
'expression-holder',
|
||||||
|
];
|
||||||
|
|
||||||
|
const panelStyles = ['top', 'left', 'right', 'bottom', 'height', 'width', 'margin',];
|
||||||
|
|
||||||
document.getElementById("left-nav-panel").style.top = '';
|
panelIds.forEach((id) => {
|
||||||
document.getElementById("left-nav-panel").style.left = '';
|
const panel = document.getElementById(id);
|
||||||
document.getElementById("left-nav-panel").style.height = '';
|
|
||||||
document.getElementById("left-nav-panel").style.width = '';
|
|
||||||
document.getElementById("left-nav-panel").style.margin = '';
|
|
||||||
|
|
||||||
document.getElementById("right-nav-panel").style.top = '';
|
if (panel) {
|
||||||
document.getElementById("right-nav-panel").style.left = '';
|
panelStyles.forEach((style) => {
|
||||||
document.getElementById("right-nav-panel").style.right = '';
|
panel.style[style] = '';
|
||||||
document.getElementById("right-nav-panel").style.height = '';
|
});
|
||||||
document.getElementById("right-nav-panel").style.width = '';
|
}
|
||||||
document.getElementById("right-nav-panel").style.margin = '';
|
});
|
||||||
|
|
||||||
document.getElementById("WorldInfo").style.top = '';
|
const zoomedAvatar = document.querySelector('.zoomed_avatar');
|
||||||
document.getElementById("WorldInfo").style.left = '';
|
if (zoomedAvatar) {
|
||||||
document.getElementById("WorldInfo").style.right = '';
|
panelStyles.forEach((style) => {
|
||||||
document.getElementById("WorldInfo").style.bottom = '';
|
zoomedAvatar.style[style] = '';
|
||||||
document.getElementById("WorldInfo").style.height = '';
|
});
|
||||||
document.getElementById("WorldInfo").style.width = '';
|
|
||||||
document.getElementById("WorldInfo").style.margin = '';
|
|
||||||
|
|
||||||
document.getElementById("floatingPrompt").style.top = '';
|
|
||||||
document.getElementById("floatingPrompt").style.left = '';
|
|
||||||
document.getElementById("floatingPrompt").style.right = '';
|
|
||||||
document.getElementById("floatingPrompt").style.bottom = '';
|
|
||||||
document.getElementById("floatingPrompt").style.height = '';
|
|
||||||
document.getElementById("floatingPrompt").style.width = '';
|
|
||||||
document.getElementById("floatingPrompt").style.margin = '';
|
|
||||||
|
|
||||||
if ($("#expression-holder")) {
|
|
||||||
document.getElementById("expression-holder").style.top = '';
|
|
||||||
document.getElementById("expression-holder").style.left = '';
|
|
||||||
document.getElementById("expression-holder").style.right = '';
|
|
||||||
document.getElementById("expression-holder").style.bottom = '';
|
|
||||||
document.getElementById("expression-holder").style.height = '';
|
|
||||||
document.getElementById("expression-holder").style.width = '';
|
|
||||||
document.getElementById("expression-holder").style.margin = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(".zoomed_avatar")) {
|
$('[data-dragged="true"]').removeAttr('data-dragged');
|
||||||
$(".zoomed_avatar").css('top', '');
|
power_user.movingUIState = {};
|
||||||
$(".zoomed_avatar").css('left', '');
|
|
||||||
$(".zoomed_avatar").css('right', '');
|
|
||||||
$(".zoomed_avatar").css('bottom', '');
|
|
||||||
$(".zoomed_avatar").css('width', '');
|
|
||||||
$(".zoomed_avatar").css('height', '');
|
|
||||||
$(".zoomed_avatar").css('margin', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$('*[data-dragged="true"]').removeAttr('data-dragged');
|
|
||||||
power_user.movingUIState = {}
|
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
|
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
|
||||||
|
|
||||||
|
eventSource.once(event_types.SETTINGS_UPDATED, () => {
|
||||||
|
toastr.success('Panel positions reset');
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doNewChat() {
|
function doNewChat() {
|
||||||
|
Reference in New Issue
Block a user