diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-10 07:39:39 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-10 07:39:39 +0000 |
commit | 8a7c07a2140c98bceca858087525d77fd0352fda (patch) | |
tree | 2624207c02f779b4e6bc3f94ef5cb827d363a103 /javascript/images_history.js | |
parent | 2995107fa24cfd72b0a991e18271dcde148c2807 (diff) | |
download | stable-diffusion-webui-gfx803-8a7c07a2140c98bceca858087525d77fd0352fda.tar.gz stable-diffusion-webui-gfx803-8a7c07a2140c98bceca858087525d77fd0352fda.tar.bz2 stable-diffusion-webui-gfx803-8a7c07a2140c98bceca858087525d77fd0352fda.zip |
show image history
Diffstat (limited to 'javascript/images_history.js')
-rw-r--r-- | javascript/images_history.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/javascript/images_history.js b/javascript/images_history.js new file mode 100644 index 00000000..f30b7eff --- /dev/null +++ b/javascript/images_history.js @@ -0,0 +1,66 @@ +function init_images_history(){ + if (gradioApp().getElementById('txt2img_images_history_first_page') == null) { + setTimeout(init_images_history, 1000) + } else { + tab_list = ["txt2img", "img2img"] + for (i in tab_list){ + tab = tab_list[i] + gradioApp().getElementById(tab + "_images_history_first_page").click() + $(gradioApp().getElementById(tab + '_images_history')).addClass("images_history_gallery") + item = $(gradioApp().getElementById(tab + '_images_history_set_index')) + item.addClass("images_history_set_index") + item.hide() + } + } + +} +setTimeout(init_images_history, 1000) +onUiUpdate(function(){ + fullImg_preview = gradioApp().querySelectorAll('#txt2img_images_history img.w-full') + if(fullImg_preview.length > 0){ + fullImg_preview.forEach(set_history_index_from_img); + } + fullImg_preview = gradioApp().querySelectorAll('#img2img_images_history img.w-full') + if(fullImg_preview.length > 0){ + fullImg_preview.forEach(set_history_index_from_img); + } +}) + +function set_history_gallery_index(item){ + buttons = item.find(".gallery-item") + // alert(item.attr("id") + " " + buttons.length) + index = -1 + i = 0 + buttons.each(function(){ + if($(this).hasClass("!ring-2")){ index = i } + i += 1 + }) + if (index == -1){ + setTimeout(set_history_gallery_index, 10, item) + } else { + item = item.find(".images_history_set_index").first() + item.attr("img_index", index) + item.click() + } +} +function set_history_index_from_img(e){ + if(e && e.parentElement.tagName == 'BUTTON'){ + bnt = $(e).parent() + if (bnt.hasClass("transform")){ + bnt.off("click").on("click",function(){ + set_history_gallery_index($(this).parents(".images_history_gallery").first()) + }) + } else { + bnt.off("mousedown").on("mousedown", function(){ + set_history_gallery_index($(this).parents(".images_history_gallery").first()) + }) + + } + } +} +function images_history_get_current_img(is_image2image){ + head = is_image2image?"img2img":"txt2img" + s = $(gradioApp().getElementById(head + '_images_history_set_index')).attr("img_index") + return s +} + |