diff options
author | papuSpartan <30642826+papuSpartan@users.noreply.github.com> | 2022-11-06 21:05:28 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-06 21:05:28 -0600 |
commit | 00ebc26c4e2962a31e067539d89cd695d999539a (patch) | |
tree | 4c2d46e00ffcc5b606f4841926b3a61fed903f00 /javascript | |
parent | 86d35526a13a0e2432ab71d1d40b191615d3e343 (diff) | |
parent | 804d9fb83d0c63ca3acd36378707ce47b8f12599 (diff) |
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/edit-attention.js | 3 | ||||
-rw-r--r-- | javascript/progressbar.js | 30 | ||||
-rw-r--r-- | javascript/ui.js | 2 |
3 files changed, 27 insertions, 8 deletions
diff --git a/javascript/edit-attention.js b/javascript/edit-attention.js index c0d29a74..b947cbec 100644 --- a/javascript/edit-attention.js +++ b/javascript/edit-attention.js @@ -1,7 +1,6 @@ addEventListener('keydown', (event) => {
let target = event.originalTarget || event.composedPath()[0];
- if (!target.hasAttribute("placeholder")) return;
- if (!target.placeholder.toLowerCase().includes("prompt")) return;
+ if (!target.matches("#toprow textarea.gr-text-input[placeholder]")) return;
if (! (event.metaKey || event.ctrlKey)) return;
diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 7a05726e..671fde34 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -3,8 +3,21 @@ global_progressbars = {} galleries = {} galleryObservers = {} +// this tracks laumnches of window.setTimeout for progressbar to prevent starting a new timeout when the previous is still running +timeoutIds = {} + function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip, id_interrupt, id_preview, id_gallery){ - var progressbar = gradioApp().getElementById(id_progressbar) + // gradio 3.8's enlightened approach allows them to create two nested div elements inside each other with same id + // every time you use gr.HTML(elem_id='xxx'), so we handle this here + var progressbar = gradioApp().querySelector("#"+id_progressbar+" #"+id_progressbar) + var progressbarParent + if(progressbar){ + progressbarParent = gradioApp().querySelector("#"+id_progressbar) + } else{ + progressbar = gradioApp().getElementById(id_progressbar) + progressbarParent = null + } + var skip = id_skip ? gradioApp().getElementById(id_skip) : null var interrupt = gradioApp().getElementById(id_interrupt) @@ -26,18 +39,26 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip global_progressbars[id_progressbar] = progressbar var mutationObserver = new MutationObserver(function(m){ + if(timeoutIds[id_part]) return; + preview = gradioApp().getElementById(id_preview) gallery = gradioApp().getElementById(id_gallery) if(preview != null && gallery != null){ preview.style.width = gallery.clientWidth + "px" preview.style.height = gallery.clientHeight + "px" + if(progressbarParent) progressbar.style.width = progressbarParent.clientWidth + "px" //only watch gallery if there is a generation process going on check_gallery(id_gallery); var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0; - if(!progressDiv){ + if(progressDiv){ + timeoutIds[id_part] = window.setTimeout(function() { + timeoutIds[id_part] = null + requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt) + }, 500) + } else{ if (skip) { skip.style.display = "none" } @@ -47,13 +68,10 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip if (galleryObservers[id_gallery]) { galleryObservers[id_gallery].disconnect(); galleries[id_gallery] = null; - } + } } - - } - window.setTimeout(function() { requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt) }, 500) }); mutationObserver.observe( progressbar, { childList:true, subtree:true }) } diff --git a/javascript/ui.js b/javascript/ui.js index 00e80fd6..51d112cd 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -248,4 +248,6 @@ function update_token_counter(button_id) { function restart_reload(){ document.body.innerHTML='<h1 style="font-family:monospace;margin-top:20%;color:lightgray;text-align:center;">Reloading...</h1>'; setTimeout(function(){location.reload()},2000) + + return [] } |