MCPcopy Create free account
hub / github.com/DenOfEquity/ersatzForge / setupResolutionPasting

Function setupResolutionPasting

javascript/ui.js:230–246  ·  view source on GitHub ↗

* Configure the width and height elements on `tabname` to accept * pasting of resolutions in the form of "width x height".

(tabname)

Source from the content-addressed store, hash-verified

228 * pasting of resolutions in the form of "width x height".
229 */
230function 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
248var opts = {};
249onUiLoaded(function() {

Callers 1

ui.jsFile · 0.85

Calls 2

gradioAppFunction · 0.85
updateInputFunction · 0.70

Tested by

no test coverage detected