diff options
author | catalpaaa <89681913+catalpaaa@users.noreply.github.com> | 2023-05-01 18:59:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 18:59:21 +0000 |
commit | 9eb5b3e90f1775af81c828f19e7caded70ba8884 (patch) | |
tree | 4630848311b90277462842669274852f7f6a972a /javascript/ui.js | |
parent | ecdc6471e7d694ef9ecec96e8c3128237efe069a (diff) | |
parent | 72cd27a13587c9579942577e9e3880778be195f6 (diff) | |
download | stable-diffusion-webui-gfx803-9eb5b3e90f1775af81c828f19e7caded70ba8884.tar.gz stable-diffusion-webui-gfx803-9eb5b3e90f1775af81c828f19e7caded70ba8884.tar.bz2 stable-diffusion-webui-gfx803-9eb5b3e90f1775af81c828f19e7caded70ba8884.zip |
Merge branch 'experimental' into subpath-support
Diffstat (limited to 'javascript/ui.js')
-rw-r--r-- | javascript/ui.js | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index 4a440193..bfe31525 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -159,14 +159,24 @@ function showSubmitButtons(tabname, show){ gradioApp().getElementById(tabname+'_skip').style.display = show ? "none" : "block" } +function showRestoreProgressButton(tabname, show){ + button = gradioApp().getElementById(tabname + "_restore_progress") + if(! button) return + + button.style.display = show ? "flex" : "none" +} + function submit(){ rememberGallerySelection('txt2img_gallery') showSubmitButtons('txt2img', false) var id = randomId() + localStorage.setItem("txt2img_task_id", id); + requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function(){ showSubmitButtons('txt2img', true) - + localStorage.removeItem("txt2img_task_id") + showRestoreProgressButton('txt2img', false) }) var res = create_submit_args(arguments) @@ -181,8 +191,12 @@ function submit_img2img(){ showSubmitButtons('img2img', false) var id = randomId() + localStorage.setItem("img2img_task_id", id); + requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){ showSubmitButtons('img2img', true) + localStorage.removeItem("img2img_task_id") + showRestoreProgressButton('img2img', false) }) var res = create_submit_args(arguments) @@ -193,6 +207,40 @@ function submit_img2img(){ return res } +function restoreProgressTxt2img(x){ + showRestoreProgressButton("txt2img", false) + + id = localStorage.getItem("txt2img_task_id") + + if(id) { + requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function(){ + showSubmitButtons('txt2img', true) + }, null, 0) + } + + return id +} +function restoreProgressImg2img(x){ + showRestoreProgressButton("img2img", false) + + id = localStorage.getItem("img2img_task_id") + + if(id) { + requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){ + showSubmitButtons('img2img', true) + }, null, 0) + } + + return id +} + + +onUiLoaded(function () { + showRestoreProgressButton('txt2img', localStorage.getItem("txt2img_task_id")) + showRestoreProgressButton('img2img', localStorage.getItem("img2img_task_id")) +}); + + function modelmerger(){ var id = randomId() requestProgress(id, gradioApp().getElementById('modelmerger_results_panel'), null, function(){}) @@ -361,3 +409,19 @@ function selectCheckpoint(name){ desiredCheckpointName = name; gradioApp().getElementById('change_checkpoint').click() } + +function currentImg2imgSourceResolution(_, _, scaleBy){ + var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] img') + return img ? [img.naturalWidth, img.naturalHeight, scaleBy] : [0, 0, scaleBy] +} + +function updateImg2imgResizeToTextAfterChangingImage(){ + // At the time this is called from gradio, the image has no yet been replaced. + // There may be a better solution, but this is simple and straightforward so I'm going with it. + + setTimeout(function() { + gradioApp().getElementById('img2img_update_resize_to').click() + }, 500); + + return [] +} |