update options

This commit is contained in:
Vladimir Mandic
2023-04-28 22:01:29 -04:00
parent 3b6effe4a9
commit d3f0294bde
4 changed files with 9 additions and 29 deletions
+1
View File
@@ -103,6 +103,7 @@ svg.feather.feather-image, .feather .feather-image { display: none }
#txt2img_tools, #img2img_tools { margin-top: 54px; scale: 120%; margin-left: 26px; }
#txtimg_hr_finalres { max-width: 200px; }
#pnginfo_html2_info { margin-top: -18px; background-color: var(--input-background-fill); padding: var(--input-padding) }
#txt2img_extra_refresh, #txt2img_extra_close { height: 1.7em }
/* custom elements overrides */
#steps-animation, #controlnet { border-width: 0; }
+4 -24
View File
@@ -1,52 +1,32 @@
// Monitors the gallery and sends a browser notification when the leading image is new.
let lastHeadImg = null;
let notificationButton = null;
const regExpTempImage = /(?<=\/|\\)tmp[\w\d]{8}\.png$/gm;
onUiUpdate(function(){
if(notificationButton == null){
notificationButton = gradioApp().getElementById('request_notifications')
if(notificationButton != null){
notificationButton.addEventListener('click', function (evt) {
Notification.requestPermission();
},true);
}
if (notificationButton != null) notificationButton.addEventListener('click', (evt) => Notification.requestPermission(), true);
}
const galleryPreviews = gradioApp().querySelectorAll('div[id^="tab_"][style*="display: block"] div[id$="_results"] .thumbnail-item > img');
if (galleryPreviews == null) return;
const headImg = galleryPreviews[0]?.src;
if (headImg == null || headImg == lastHeadImg) return;
if (headImg.search(regExpTempImage) != -1) return;
lastHeadImg = headImg;
// play notification sound if available
gradioApp().querySelector('#audio_notification audio')?.play();
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));
const notification = new Notification(
'Stable Diffusion',
{
'Stable Diffusion', {
body: `Generated ${imgs.size > 1 ? imgs.size - opts.return_grid : 1} image${imgs.size > 1 ? 's' : ''}`,
icon: headImg,
image: headImg,
}
image: headImg }
);
notification.onclick = function(_){
notification.onclick = function(_) {
parent.focus();
this.close();
};