소스 검색

return progress percentage to title bar

AUTOMATIC 2 년 전
부모
커밋
dac59b9b07
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      javascript/progressbar.js

+ 15 - 0
javascript/progressbar.js

@@ -106,6 +106,19 @@ function formatTime(secs){
     }
     }
 }
 }
 
 
+function setTitle(progress){
+    var title = 'Stable Diffusion'
+
+    if(opts.show_progress_in_title && progress){
+        title = '[' + progress.trim() + '] ' + title;
+    }
+
+    if(document.title != title){
+        document.title =  title;
+    }
+}
+
+
 function randomId(){
 function randomId(){
     return "task(" + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7)+")"
     return "task(" + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7) + Math.random().toString(36).slice(2, 7)+")"
 }
 }
@@ -133,6 +146,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
     parentGallery.insertBefore(livePreview, gallery)
     parentGallery.insertBefore(livePreview, gallery)
 
 
     var removeProgressBar = function(){
     var removeProgressBar = function(){
+        setTitle("")
         parentProgressbar.removeChild(divProgress)
         parentProgressbar.removeChild(divProgress)
         parentGallery.removeChild(livePreview)
         parentGallery.removeChild(livePreview)
         atEnd()
         atEnd()
@@ -165,6 +179,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
                 progressText += " " + res.textinfo
                 progressText += " " + res.textinfo
             }
             }
 
 
+            setTitle(progressText)
             divInner.textContent = progressText
             divInner.textContent = progressText
 
 
             var elapsedFromStart = (new Date() - dateStart) / 1000
             var elapsedFromStart = (new Date() - dateStart) / 1000