Script selections stored. New gradio selects handled.

pull/30/head
ilian.iliev 2023-05-08 16:22:07 +03:00
parent 6d38f7c248
commit 2ee086c3a0
3 changed files with 23 additions and 5 deletions

View File

@ -32,6 +32,7 @@ state.core = (function () {
const SELECTS = {
'sampling': 'sampling',
'hires_upscaler': 'hr_upscaler',
'script': '#script_list',
};
const MULTI_SELECTS = {
@ -198,6 +199,16 @@ state.core = (function () {
bindTabClickEvents(); // dirty hack here...
}
function getElement(id) {
for (let i = 0; i < TABS.length; i++) {
if (id.startsWith(`${TABS[i]}_#`)) {
// handle elements with same ids in different tabs...
return gradioApp().querySelector('#tab_' + id.replace(`${TABS[i]}_#`, `${TABS[i]} #`));
}
}
return gradioApp().getElementById(id);
}
function handleSavedInput(id) {
const elements = gradioApp().querySelectorAll(`#${id} textarea, #${id} input`);
@ -249,8 +260,7 @@ state.core = (function () {
}
function handleSavedSelects(id) {
const select = gradioApp().getElementById(`${id}`);
state.utils.handleSelect(select, id, store);
state.utils.handleSelect(getElement(id), id, store);
}
function handleSavedMultiSelects(id) {
@ -302,7 +312,7 @@ state.core = (function () {
el.checked = value;
state.utils.triggerEvent(el, 'change');
}
} else if (el.checked === value) {
} else if (el.checked === value) {
el.checked = !value;
state.utils.triggerEvent(el, 'change');
}

View File

@ -77,9 +77,15 @@ state.utils = {
setTimeout(() => {
state.utils.onContentChange(select, function (el) {
const selected = el.querySelector('span.single-select');
let selected = el.querySelector('span.single-select');
if (selected) {
store.set(id, selected.textContent);
} else {
// new gradio version...
let input = select.querySelector('input');
if (input) {
store.set(id, input.value);
}
}
});
}, 150);

View File

@ -36,6 +36,7 @@ def on_ui_settings():
"hires_resize_x",
"hires_resize_y",
"hires_denoising_strength",
"script"
]
}, section=section))
@ -56,7 +57,8 @@ def on_ui_settings():
"batch_size",
"cfg_scale",
"denoising_strength",
"seed"
"seed",
"script"
]
}, section=section))