aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
authorspace-nuko <24979496+space-nuko@users.noreply.github.com>2023-04-03 21:27:48 -0500
committerspace-nuko <24979496+space-nuko@users.noreply.github.com>2023-04-03 21:27:48 -0500
commit7201d940a4fe664beb9662fadbeade4ee1d788f7 (patch)
treedca1c11810ba979d7439c54d9595745e3798e3d6 /javascript
parent22bcc7be428c94e9408f589966c2040187245d81 (diff)
Improve frontend responsiveness for some buttons
Diffstat (limited to 'javascript')
-rw-r--r--javascript/ui.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index 4a440193..5311e7bc 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -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 [];
+}