diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-05-17 20:27:06 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-05-17 20:27:06 +0000 |
commit | e5dd4b4ebf817d35285095baa2246dfc5647186e (patch) | |
tree | b8cc58b6f498d497f58ee7510ce7eae5211eae07 /javascript | |
parent | 1d1b5da4bfc6ff899146b6198464134502374e7e (diff) | |
download | stable-diffusion-webui-gfx803-e5dd4b4ebf817d35285095baa2246dfc5647186e.tar.gz stable-diffusion-webui-gfx803-e5dd4b4ebf817d35285095baa2246dfc5647186e.tar.bz2 stable-diffusion-webui-gfx803-e5dd4b4ebf817d35285095baa2246dfc5647186e.zip |
remove some code duplication from #9348
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/ui.js | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index 56ee05aa..6d4119d7 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -441,51 +441,27 @@ function updateImg2imgResizeToTextAfterChangingImage(){ } -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")); +function setRandomSeed(elem_id) { + var input = gradioApp().querySelector("#" + elem_id + " input"); + if (!input) return []; + + input.value = "-1"; + updateInput(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; +function switchWidthHeight(tabname) { + var width = gradioApp().querySelector("#" + tabname + "_width input[type=number]"); + var height = gradioApp().querySelector("#" + tabname + "_height input[type=number]"); + if (!width || !height) return []; + + var tmp = width.value; width.value = height.value; height.value = tmp; - width.dispatchEvent(new Event("input")); - height.dispatchEvent(new Event("input")); + + updateInput(width); + updateInput(height); return []; } - |