ACCC1380's picture
download
raw
1.81 kB
// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes
let txt2img_gallery = undefined;
let img2img_gallery = undefined;
let modal = undefined;
onUiLoaded(setupListeners);
function setupListeners() {
if (!txt2img_gallery) {
txt2img_gallery = attachGalleryListeners("txt2img");
}
if (!img2img_gallery) {
img2img_gallery = attachGalleryListeners("img2img");
}
if (!modal) {
modal = gradioApp().getElementById("lightboxModal");
modalObserver.observe(modal, {
attributes: true,
attributeFilter: ["style"],
});
}
if (!txt2img_gallery || !img2img_gallery || !modal) setTimeout(setupListeners, 50);
}
let modalObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (mutationRecord) {
let selectedTab = gradioApp().querySelector("#tabs div button.selected")?.innerText;
if (mutationRecord.target.style.display === "none" && (selectedTab === "txt2img" || selectedTab === "img2img")) {
gradioApp()
.getElementById(selectedTab + "_generation_info_button")
?.click();
}
});
});
function attachGalleryListeners(tab_name) {
let gallery = gradioApp().querySelector("#" + tab_name + "_gallery");
gallery?.addEventListener("click", () =>
gradioApp()
.getElementById(tab_name + "_generation_info_button")
.click(),
);
gallery?.addEventListener("keydown", (e) => {
if (e.keyCode == 37 || e.keyCode == 39) {
// left or right arrow
gradioApp()
.getElementById(tab_name + "_generation_info_button")
.click();
}
});
return gallery;
}

Xet Storage Details

Size:
1.81 kB
·
Xet hash:
5dee93bd3321ca11baffd88d055d11ab6f1b14fbcfbb4ccd4cb6bb94ac0e8853

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.