diff options
author | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-12-14 08:54:45 +0000 |
---|---|---|
committer | Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> | 2023-12-14 08:54:45 +0000 |
commit | 0fb34b57b80b368f76a368c50569371c10382e12 (patch) | |
tree | cb32ad64211ac1670bae87946190c85abd40773e /javascript/ui.js | |
parent | 39ebd5684b377157eca7034feec4596707cfa9c7 (diff) | |
parent | aeaf1c510f1e7f246d892dad74122e0117a68a8c (diff) | |
download | stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.tar.gz stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.tar.bz2 stable-diffusion-webui-gfx803-0fb34b57b80b368f76a368c50569371c10382e12.zip |
Merge branch 'dev' into test-fp8
Diffstat (limited to 'javascript/ui.js')
-rw-r--r-- | javascript/ui.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index 410fc44e..18c9f891 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -215,9 +215,33 @@ function restoreProgressImg2img() { } +/** + * Configure the width and height elements on `tabname` to accept + * pasting of resolutions in the form of "width x height". + */ +function setupResolutionPasting(tabname) { + var width = gradioApp().querySelector(`#${tabname}_width input[type=number]`); + var height = gradioApp().querySelector(`#${tabname}_height input[type=number]`); + for (const el of [width, height]) { + el.addEventListener('paste', function(event) { + var pasteData = event.clipboardData.getData('text/plain'); + var parsed = pasteData.match(/^\s*(\d+)\D+(\d+)\s*$/); + if (parsed) { + width.value = parsed[1]; + height.value = parsed[2]; + updateInput(width); + updateInput(height); + event.preventDefault(); + } + }); + } +} + onUiLoaded(function() { showRestoreProgressButton('txt2img', localGet("txt2img_task_id")); showRestoreProgressButton('img2img', localGet("img2img_task_id")); + setupResolutionPasting('txt2img'); + setupResolutionPasting('img2img'); }); |