mirror of
https://github.com/anapnoe/stable-diffusion-webui-ux.git
synced 2026-09-19 01:05:13 +02:00
Fix issue #135 and js formatting
This commit is contained in:
+35
-30
@@ -4,46 +4,51 @@ let lastHeadImg = null;
|
||||
|
||||
let notificationButton = null;
|
||||
|
||||
onUiUpdate(function(){
|
||||
if(notificationButton == null){
|
||||
notificationButton = gradioApp().getElementById('request_notifications')
|
||||
onUiUpdate(function () {
|
||||
if (notificationButton == null) {
|
||||
notificationButton = gradioApp().getElementById("request_notifications");
|
||||
|
||||
if(notificationButton != null){
|
||||
notificationButton.addEventListener('click', () => {
|
||||
void Notification.requestPermission();
|
||||
},true);
|
||||
}
|
||||
if (notificationButton != null) {
|
||||
notificationButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
void Notification.requestPermission();
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img');
|
||||
const galleryPreviews = gradioApp().querySelectorAll(
|
||||
'div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img'
|
||||
);
|
||||
|
||||
if (galleryPreviews == null) return;
|
||||
if (galleryPreviews == null) return;
|
||||
|
||||
const headImg = galleryPreviews[0]?.src;
|
||||
const headImg = galleryPreviews[0]?.src;
|
||||
|
||||
if (headImg == null || headImg == lastHeadImg) return;
|
||||
if (headImg == null || headImg == lastHeadImg) return;
|
||||
|
||||
lastHeadImg = headImg;
|
||||
lastHeadImg = headImg;
|
||||
|
||||
// play notification sound if available
|
||||
gradioApp().querySelector('#audio_notification audio')?.play();
|
||||
// play notification sound if available
|
||||
gradioApp().querySelector("#audio_notification audio")?.play();
|
||||
|
||||
if (document.hasFocus()) return;
|
||||
if (document.hasFocus()) return;
|
||||
|
||||
// Multiple copies of the images are in the DOM when one is selected. Dedup with a Set to get the real number generated.
|
||||
const imgs = new Set(Array.from(galleryPreviews).map(img => img.src));
|
||||
// Multiple copies of the images are in the DOM when one is selected. Dedup with a Set to get the real number generated.
|
||||
const imgs = new Set(Array.from(galleryPreviews).map((img) => img.src));
|
||||
|
||||
const notification = new Notification(
|
||||
'Stable Diffusion',
|
||||
{
|
||||
body: `Generated ${imgs.size > 1 ? imgs.size - opts.return_grid : 1} image${imgs.size > 1 ? 's' : ''}`,
|
||||
icon: headImg,
|
||||
image: headImg,
|
||||
}
|
||||
);
|
||||
const notification = new Notification("Stable Diffusion", {
|
||||
body: `Generated ${imgs.size > 1 ? imgs.size - opts.return_grid : 1} image${
|
||||
imgs.size > 1 ? "s" : ""
|
||||
}`,
|
||||
icon: headImg,
|
||||
image: headImg,
|
||||
});
|
||||
|
||||
notification.onclick = function(_){
|
||||
parent.focus();
|
||||
this.close();
|
||||
};
|
||||
notification.onclick = function (_) {
|
||||
parent.focus();
|
||||
this.close();
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user