2022-09-18 06:00:06 +00:00
|
|
|
// code related to showing and updating progressbar shown as the image is being made
|
2022-09-23 17:46:02 +00:00
|
|
|
global_progressbars = {}
|
2022-09-05 23:09:01 +00:00
|
|
|
|
2022-10-05 03:56:30 +00:00
|
|
|
function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip, id_interrupt, id_preview, id_gallery){
|
2022-09-23 17:46:02 +00:00
|
|
|
var progressbar = gradioApp().getElementById(id_progressbar)
|
2022-10-05 03:56:30 +00:00
|
|
|
var skip = id_skip ? gradioApp().getElementById(id_skip) : null
|
2022-09-23 17:46:02 +00:00
|
|
|
var interrupt = gradioApp().getElementById(id_interrupt)
|
2022-10-05 03:44:22 +00:00
|
|
|
|
2022-10-06 00:10:38 +00:00
|
|
|
if(opts.show_progress_in_title && progressbar && progressbar.offsetParent){
|
2022-10-05 03:44:22 +00:00
|
|
|
if(progressbar.innerText){
|
|
|
|
let newtitle = 'Stable Diffusion - ' + progressbar.innerText
|
|
|
|
if(document.title != newtitle){
|
|
|
|
document.title = newtitle;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
let newtitle = 'Stable Diffusion'
|
|
|
|
if(document.title != newtitle){
|
|
|
|
document.title = newtitle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-23 17:46:02 +00:00
|
|
|
if(progressbar!= null && progressbar != global_progressbars[id_progressbar]){
|
|
|
|
global_progressbars[id_progressbar] = progressbar
|
2022-09-05 23:09:01 +00:00
|
|
|
|
|
|
|
var mutationObserver = new MutationObserver(function(m){
|
2022-09-23 17:46:02 +00:00
|
|
|
preview = gradioApp().getElementById(id_preview)
|
|
|
|
gallery = gradioApp().getElementById(id_gallery)
|
2022-09-06 16:33:51 +00:00
|
|
|
|
2022-09-23 17:46:02 +00:00
|
|
|
if(preview != null && gallery != null){
|
|
|
|
preview.style.width = gallery.clientWidth + "px"
|
|
|
|
preview.style.height = gallery.clientHeight + "px"
|
|
|
|
|
|
|
|
var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0;
|
2022-09-20 18:05:25 +00:00
|
|
|
if(!progressDiv){
|
2022-10-05 03:56:30 +00:00
|
|
|
if (skip) {
|
|
|
|
skip.style.display = "none"
|
|
|
|
}
|
2022-09-22 01:11:53 +00:00
|
|
|
interrupt.style.display = "none"
|
2022-09-20 18:05:25 +00:00
|
|
|
}
|
2022-09-06 16:33:51 +00:00
|
|
|
}
|
2022-09-18 05:51:11 +00:00
|
|
|
|
2022-10-05 03:56:30 +00:00
|
|
|
window.setTimeout(function() { requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt) }, 500)
|
2022-09-05 23:09:01 +00:00
|
|
|
});
|
|
|
|
mutationObserver.observe( progressbar, { childList:true, subtree:true })
|
|
|
|
}
|
2022-09-23 17:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onUiUpdate(function(){
|
2022-10-05 03:56:30 +00:00
|
|
|
check_progressbar('txt2img', 'txt2img_progressbar', 'txt2img_progress_span', 'txt2img_skip', 'txt2img_interrupt', 'txt2img_preview', 'txt2img_gallery')
|
|
|
|
check_progressbar('img2img', 'img2img_progressbar', 'img2img_progress_span', 'img2img_skip', 'img2img_interrupt', 'img2img_preview', 'img2img_gallery')
|
|
|
|
check_progressbar('ti', 'ti_progressbar', 'ti_progress_span', '', 'ti_interrupt', 'ti_preview', 'ti_gallery')
|
2022-09-18 05:51:11 +00:00
|
|
|
})
|
2022-09-23 17:46:02 +00:00
|
|
|
|
2022-10-05 03:56:30 +00:00
|
|
|
function requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt){
|
2022-09-23 17:46:02 +00:00
|
|
|
btn = gradioApp().getElementById(id_part+"_check_progress");
|
2022-09-18 06:00:06 +00:00
|
|
|
if(btn==null) return;
|
|
|
|
|
|
|
|
btn.click();
|
2022-09-23 17:46:02 +00:00
|
|
|
var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0;
|
2022-10-05 03:56:30 +00:00
|
|
|
var skip = id_skip ? gradioApp().getElementById(id_skip) : null
|
2022-09-23 17:46:02 +00:00
|
|
|
var interrupt = gradioApp().getElementById(id_interrupt)
|
|
|
|
if(progressDiv && interrupt){
|
2022-10-05 03:56:30 +00:00
|
|
|
if (skip) {
|
|
|
|
skip.style.display = "block"
|
|
|
|
}
|
2022-09-22 01:11:53 +00:00
|
|
|
interrupt.style.display = "block"
|
2022-09-20 18:05:25 +00:00
|
|
|
}
|
2022-09-18 06:00:06 +00:00
|
|
|
}
|
2022-09-18 08:14:42 +00:00
|
|
|
|
2022-09-23 17:46:02 +00:00
|
|
|
function requestProgress(id_part){
|
|
|
|
btn = gradioApp().getElementById(id_part+"_check_progress_initial");
|
2022-09-18 08:14:42 +00:00
|
|
|
if(btn==null) return;
|
|
|
|
|
|
|
|
btn.click();
|
|
|
|
}
|