Improve frontend responsiveness for some buttons

This commit is contained in:
space-nuko
2023-04-03 21:27:48 -05:00
parent 22bcc7be42
commit 7201d940a4
2 changed files with 54 additions and 4 deletions

View File

@@ -361,3 +361,51 @@ function selectCheckpoint(name){
desiredCheckpointName = name;
gradioApp().getElementById('change_checkpoint').click()
}
function setRandomSeed(target_interface) {
let seed = gradioApp().querySelector(`#${target_interface}_seed input`);
if (!seed) {
return [];
}
seed.value = "-1";
seed.dispatchEvent(new Event("input"));
return [];
}
function setRandomSubseed(target_interface) {
let subseed = gradioApp().querySelector(`#${target_interface}_subseed input`);
if (!subseed) {
return [];
}
subseed.value = "-1";
subseed.dispatchEvent(new Event("input"));
return [];
}
function switchWidthHeightTxt2Img() {
let width = gradioApp().querySelector("#txt2img_width input[type=number]");
let height = gradioApp().querySelector("#txt2img_height input[type=number]");
if (!width || !height) {
return [];
}
let tmp = width.value;
width.value = height.value;
height.value = tmp;
width.dispatchEvent(new Event("input"));
height.dispatchEvent(new Event("input"));
return [];
}
function switchWidthHeightImg2Img() {
let width = gradioApp().querySelector("#img2img_width input[type=number]");
let height = gradioApp().querySelector("#img2img_height input[type=number]");
if (!width || !height) {
return [];
}
let tmp = width.value;
width.value = height.value;
height.value = tmp;
width.dispatchEvent(new Event("input"));
height.dispatchEvent(new Event("input"));
return [];
}