* Configure the width and height elements on `tabname` to accept * pasting of resolutions in the form of "width x height".
(tabname)
| 228 | * pasting of resolutions in the form of "width x height". |
| 229 | */ |
| 230 | function setupResolutionPasting(tabname) { |
| 231 | var width = gradioApp().querySelector("#" + tabname + "_width input[type=number]"); |
| 232 | var height = gradioApp().querySelector("#" + tabname + "_height input[type=number]"); |
| 233 | for (const el of [width, height]) { |
| 234 | el.addEventListener("paste", function(event) { |
| 235 | var pasteData = event.clipboardData.getData("text/plain"); |
| 236 | var parsed = pasteData.match(/^\s*(\d+)\D+(\d+)\s*$/); |
| 237 | if (parsed) { |
| 238 | width.value = parsed[1]; |
| 239 | height.value = parsed[2]; |
| 240 | updateInput(width); |
| 241 | updateInput(height); |
| 242 | event.preventDefault(); |
| 243 | } |
| 244 | }); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | var opts = {}; |
| 249 | onUiLoaded(function() { |
no test coverage detected