* Configure the width and height elements on `tabname` to accept * pasting of resolutions in the form of "width x height".
(tabname)
| 246 | * pasting of resolutions in the form of "width x height". |
| 247 | */ |
| 248 | function setupResolutionPasting(tabname) { |
| 249 | var width = gradioApp().querySelector(`#${tabname}_width input[type=number]`); |
| 250 | var height = gradioApp().querySelector(`#${tabname}_height input[type=number]`); |
| 251 | for (const el of [width, height]) { |
| 252 | el.addEventListener('paste', function(event) { |
| 253 | var pasteData = event.clipboardData.getData('text/plain'); |
| 254 | var parsed = pasteData.match(/^\s*(\d+)\D+(\d+)\s*$/); |
| 255 | if (parsed) { |
| 256 | width.value = parsed[1]; |
| 257 | height.value = parsed[2]; |
| 258 | updateInput(width); |
| 259 | updateInput(height); |
| 260 | event.preventDefault(); |
| 261 | } |
| 262 | }); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | onUiLoaded(function() { |
| 267 | showRestoreProgressButton('txt2img', localGet("txt2img_task_id")); |
no test coverage detected