Script selections stored. New gradio selects handled.
parent
6d38f7c248
commit
2ee086c3a0
|
|
@ -32,6 +32,7 @@ state.core = (function () {
|
||||||
const SELECTS = {
|
const SELECTS = {
|
||||||
'sampling': 'sampling',
|
'sampling': 'sampling',
|
||||||
'hires_upscaler': 'hr_upscaler',
|
'hires_upscaler': 'hr_upscaler',
|
||||||
|
'script': '#script_list',
|
||||||
};
|
};
|
||||||
|
|
||||||
const MULTI_SELECTS = {
|
const MULTI_SELECTS = {
|
||||||
|
|
@ -198,6 +199,16 @@ state.core = (function () {
|
||||||
bindTabClickEvents(); // dirty hack here...
|
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) {
|
function handleSavedInput(id) {
|
||||||
|
|
||||||
const elements = gradioApp().querySelectorAll(`#${id} textarea, #${id} input`);
|
const elements = gradioApp().querySelectorAll(`#${id} textarea, #${id} input`);
|
||||||
|
|
@ -249,8 +260,7 @@ state.core = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSavedSelects(id) {
|
function handleSavedSelects(id) {
|
||||||
const select = gradioApp().getElementById(`${id}`);
|
state.utils.handleSelect(getElement(id), id, store);
|
||||||
state.utils.handleSelect(select, id, store);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSavedMultiSelects(id) {
|
function handleSavedMultiSelects(id) {
|
||||||
|
|
@ -302,7 +312,7 @@ state.core = (function () {
|
||||||
el.checked = value;
|
el.checked = value;
|
||||||
state.utils.triggerEvent(el, 'change');
|
state.utils.triggerEvent(el, 'change');
|
||||||
}
|
}
|
||||||
} else if (el.checked === value) {
|
} else if (el.checked === value) {
|
||||||
el.checked = !value;
|
el.checked = !value;
|
||||||
state.utils.triggerEvent(el, 'change');
|
state.utils.triggerEvent(el, 'change');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,15 @@ state.utils = {
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
state.utils.onContentChange(select, function (el) {
|
state.utils.onContentChange(select, function (el) {
|
||||||
const selected = el.querySelector('span.single-select');
|
let selected = el.querySelector('span.single-select');
|
||||||
if (selected) {
|
if (selected) {
|
||||||
store.set(id, selected.textContent);
|
store.set(id, selected.textContent);
|
||||||
|
} else {
|
||||||
|
// new gradio version...
|
||||||
|
let input = select.querySelector('input');
|
||||||
|
if (input) {
|
||||||
|
store.set(id, input.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 150);
|
}, 150);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ def on_ui_settings():
|
||||||
"hires_resize_x",
|
"hires_resize_x",
|
||||||
"hires_resize_y",
|
"hires_resize_y",
|
||||||
"hires_denoising_strength",
|
"hires_denoising_strength",
|
||||||
|
"script"
|
||||||
]
|
]
|
||||||
}, section=section))
|
}, section=section))
|
||||||
|
|
||||||
|
|
@ -56,7 +57,8 @@ def on_ui_settings():
|
||||||
"batch_size",
|
"batch_size",
|
||||||
"cfg_scale",
|
"cfg_scale",
|
||||||
"denoising_strength",
|
"denoising_strength",
|
||||||
"seed"
|
"seed",
|
||||||
|
"script"
|
||||||
]
|
]
|
||||||
}, section=section))
|
}, section=section))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue