forked from extern/easydiffusion
updated to make autosaving on by default and updated some of the new logic
This commit is contained in:
parent
0922349344
commit
48222ce44c
@ -43,7 +43,7 @@
|
|||||||
<li><input id="use_cpu" name="use_cpu" type="checkbox"> <label for="use_cpu">Use CPU instead of GPU <small>(warning: this will be *very* slow)</small></label></li>
|
<li><input id="use_cpu" name="use_cpu" type="checkbox"> <label for="use_cpu">Use CPU instead of GPU <small>(warning: this will be *very* slow)</small></label></li>
|
||||||
<li><input id="use_full_precision" name="use_full_precision" type="checkbox"> <label for="use_full_precision">Use full precision <small>(for GPU-only. warning: this will consume more VRAM)</small></label></li>
|
<li><input id="use_full_precision" name="use_full_precision" type="checkbox"> <label for="use_full_precision">Use full precision <small>(for GPU-only. warning: this will consume more VRAM)</small></label></li>
|
||||||
<li>
|
<li>
|
||||||
<input id="auto_save_settings" name="auto_save_settings" type="checkbox">
|
<input id="auto_save_settings" name="auto_save_settings" checked type="checkbox">
|
||||||
<label for="auto_save_settings">Automatically save settings <small>(settings restored on browser load)</small></label>
|
<label for="auto_save_settings">Automatically save settings <small>(settings restored on browser load)</small></label>
|
||||||
<br/>
|
<br/>
|
||||||
<button id="configureSettingsSaveBtn">Configure</button>
|
<button id="configureSettingsSaveBtn">Configure</button>
|
||||||
|
@ -62,6 +62,9 @@ function getSetting(element) {
|
|||||||
return element.value
|
return element.value
|
||||||
}
|
}
|
||||||
function setSetting(element, value) {
|
function setSetting(element, value) {
|
||||||
|
if (typeof element === "string" || element instanceof String) {
|
||||||
|
element = SETTINGS_TO_SAVE.find(e => e.id == element);
|
||||||
|
}
|
||||||
if (getSetting(element) == value) {
|
if (getSetting(element) == value) {
|
||||||
return // no setting necessary
|
return // no setting necessary
|
||||||
}
|
}
|
||||||
@ -85,10 +88,11 @@ function saveSettings() {
|
|||||||
|
|
||||||
var CURRENTLY_LOADING_SETTINGS = false
|
var CURRENTLY_LOADING_SETTINGS = false
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
if (!saveSettingsCheckbox.checked) {
|
var saved_settings = JSON.parse(localStorage.getItem(SETTINGS_KEY))
|
||||||
|
if (!saved_settings.values["auto_save_settings"]) {
|
||||||
|
setSetting("auto_save_settings", false);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var saved_settings = JSON.parse(localStorage.getItem(SETTINGS_KEY))
|
|
||||||
if (saved_settings) {
|
if (saved_settings) {
|
||||||
var values = saved_settings.values
|
var values = saved_settings.values
|
||||||
var should_save = saved_settings.should_save
|
var should_save = saved_settings.should_save
|
||||||
|
@ -26,7 +26,7 @@ const COLLAPSIBLE_PANELS = []; // filled in by createCollapsibles with all the e
|
|||||||
// on-init call this for any panels that are marked open
|
// on-init call this for any panels that are marked open
|
||||||
function toggleCollapsible(element) {
|
function toggleCollapsible(element) {
|
||||||
var collapsibleHeader = element.querySelector(".collapsible");
|
var collapsibleHeader = element.querySelector(".collapsible");
|
||||||
var handle = element.firstChild;
|
var handle = element.querySelector(".collapsible-handle");
|
||||||
collapsibleHeader.classList.toggle("active")
|
collapsibleHeader.classList.toggle("active")
|
||||||
let content = getNextSibling(collapsibleHeader, '.collapsible-content')
|
let content = getNextSibling(collapsibleHeader, '.collapsible-content')
|
||||||
if (content.style.display === "block") {
|
if (content.style.display === "block") {
|
||||||
@ -37,16 +37,16 @@ function toggleCollapsible(element) {
|
|||||||
handle.innerHTML = '➖' // minus
|
handle.innerHTML = '➖' // minus
|
||||||
}
|
}
|
||||||
|
|
||||||
if (COLLAPSIBLES_INITIALIZED && COLLAPSIBLE_PANELS.includes(element.parentElement)) {
|
if (COLLAPSIBLES_INITIALIZED && COLLAPSIBLE_PANELS.includes(element)) {
|
||||||
saveCollapsibles();
|
saveCollapsibles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveCollapsibles() {
|
function saveCollapsibles() {
|
||||||
var values = {};
|
var values = {};
|
||||||
console.log(COLLAPSIBLE_PANELS);
|
|
||||||
COLLAPSIBLE_PANELS.forEach(element => {
|
COLLAPSIBLE_PANELS.forEach(element => {
|
||||||
values[element.id] = element.querySelector(".collapsible").className.indexOf("active") !== -1;
|
var value = element.querySelector(".collapsible").className.indexOf("active") !== -1;
|
||||||
|
values[element.id] = value;
|
||||||
});
|
});
|
||||||
localStorage.setItem(COLLAPSIBLES_KEY, JSON.stringify(values));
|
localStorage.setItem(COLLAPSIBLES_KEY, JSON.stringify(values));
|
||||||
}
|
}
|
||||||
@ -57,10 +57,6 @@ function createCollapsibles(node) {
|
|||||||
node = document;
|
node = document;
|
||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
// FIX: problem here is that the elements we're getting in c are the buttons, and they are the children of the things with collapsible stuff
|
|
||||||
// FIX: gotta get parent
|
|
||||||
|
|
||||||
// default closed.
|
|
||||||
let collapsibles = node.querySelectorAll(".collapsible")
|
let collapsibles = node.querySelectorAll(".collapsible")
|
||||||
collapsibles.forEach(function(c) {
|
collapsibles.forEach(function(c) {
|
||||||
if (save && c.parentElement.id) {
|
if (save && c.parentElement.id) {
|
||||||
@ -87,12 +83,12 @@ function createCollapsibles(node) {
|
|||||||
saved = localStorage.getItem(COLLAPSIBLES_KEY);
|
saved = localStorage.getItem(COLLAPSIBLES_KEY);
|
||||||
}
|
}
|
||||||
var values = JSON.parse(saved);
|
var values = JSON.parse(saved);
|
||||||
Object.keys(values).forEach(element_id => {
|
COLLAPSIBLE_PANELS.forEach(element => {
|
||||||
if (values[element_id]) {
|
var value = element.querySelector(".collapsible").className.indexOf("active") !== -1;
|
||||||
var element = COLLAPSIBLE_PANELS.find(e => e.id == element_id);
|
if (values[element.id] != value) {
|
||||||
toggleCollapsible(element);
|
toggleCollapsible(element);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
COLLAPSIBLES_INITIALIZED = true;
|
COLLAPSIBLES_INITIALIZED = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user