diff --git a/public/script.js b/public/script.js index 71bf545ae..f8854f162 100644 --- a/public/script.js +++ b/public/script.js @@ -4650,7 +4650,7 @@ function selectKoboldGuiPreset() { async function saveSettings(type) { //console.log('Entering settings with name1 = '+name1); - eventSource.emit(event_types.SETTINGS_UPDATED); + return jQuery.ajax({ type: "POST", url: "/savesettings", @@ -4698,6 +4698,7 @@ async function saveSettings(type) { //processData: false, success: function (data) { //online_status = data.result; + eventSource.emit(event_types.SETTINGS_UPDATED); if (type == "change_name") { clearChat(); printMessages(); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index 954d64caa..3cac3ae6a 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -928,68 +928,43 @@ async function saveTheme() { } function resetMovablePanels() { - document.getElementById("sheld").style.top = ''; - document.getElementById("sheld").style.left = ''; - document.getElementById("sheld").style.bottom = ''; - document.getElementById("sheld").style.right = ''; - document.getElementById("sheld").style.height = ''; - document.getElementById("sheld").style.width = ''; - document.getElementById("sheld").style.margin = ''; + const panelIds = [ + 'sheld', + 'left-nav-panel', + 'right-nav-panel', + 'WorldInfo', + 'floatingPrompt', + 'expression-holder', + ]; + const panelStyles = ['top', 'left', 'right', 'bottom', 'height', 'width', 'margin',]; - document.getElementById("left-nav-panel").style.top = ''; - document.getElementById("left-nav-panel").style.left = ''; - document.getElementById("left-nav-panel").style.height = ''; - document.getElementById("left-nav-panel").style.width = ''; - document.getElementById("left-nav-panel").style.margin = ''; + panelIds.forEach((id) => { + const panel = document.getElementById(id); - document.getElementById("right-nav-panel").style.top = ''; - document.getElementById("right-nav-panel").style.left = ''; - document.getElementById("right-nav-panel").style.right = ''; - document.getElementById("right-nav-panel").style.height = ''; - document.getElementById("right-nav-panel").style.width = ''; - document.getElementById("right-nav-panel").style.margin = ''; + if (panel) { + panelStyles.forEach((style) => { + panel.style[style] = ''; + }); + } + }); - document.getElementById("WorldInfo").style.top = ''; - document.getElementById("WorldInfo").style.left = ''; - document.getElementById("WorldInfo").style.right = ''; - document.getElementById("WorldInfo").style.bottom = ''; - 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 = ''; + const zoomedAvatar = document.querySelector('.zoomed_avatar'); + if (zoomedAvatar) { + panelStyles.forEach((style) => { + zoomedAvatar.style[style] = ''; + }); } - if ($(".zoomed_avatar")) { - $(".zoomed_avatar").css('top', ''); - $(".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 = {} + $('[data-dragged="true"]').removeAttr('data-dragged'); + power_user.movingUIState = {}; saveSettingsDebounced(); eventSource.emit(event_types.MOVABLE_PANELS_RESET); + + eventSource.once(event_types.SETTINGS_UPDATED, () => { + toastr.success('Panel positions reset'); + }); + } function doNewChat() {