diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-20 15:58:52 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-20 15:58:52 +0000 |
commit | d07cb46f34b3d9fe7a78b102f899ebef352ea56b (patch) | |
tree | 5f64790fd3e3060892f6120033ac822ac37d3345 /javascript/inspiration.js | |
parent | 604620a7f08d1126a8689f9f4bec8ade0801a69b (diff) | |
download | stable-diffusion-webui-gfx803-d07cb46f34b3d9fe7a78b102f899ebef352ea56b.tar.gz stable-diffusion-webui-gfx803-d07cb46f34b3d9fe7a78b102f899ebef352ea56b.tar.bz2 stable-diffusion-webui-gfx803-d07cb46f34b3d9fe7a78b102f899ebef352ea56b.zip |
inspiration pull request
Diffstat (limited to 'javascript/inspiration.js')
-rw-r--r-- | javascript/inspiration.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/javascript/inspiration.js b/javascript/inspiration.js new file mode 100644 index 00000000..e1c0e114 --- /dev/null +++ b/javascript/inspiration.js @@ -0,0 +1,42 @@ +function public_image_index_in_gallery(item, gallery){ + var index; + var i = 0; + gallery.querySelectorAll("img").forEach(function(e){ + if (e == item) + index = i; + i += 1; + }); + return index; +} + +function inspiration_selected(name, types, name_list){ + var btn = gradioApp().getElementById("inspiration_select_button") + return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index"), types]; +} +var inspiration_image_click = function(){ + var index = public_image_index_in_gallery(this, gradioApp().getElementById("inspiration_gallery")); + var btn = gradioApp().getElementById("inspiration_select_button") + btn.setAttribute("img-index", index) + setTimeout(function(btn){btn.click();}, 10, btn) +} + +document.addEventListener("DOMContentLoaded", function() { + var mutationObserver = new MutationObserver(function(m){ + var gallery = gradioApp().getElementById("inspiration_gallery") + if (gallery) { + var node = gallery.querySelector(".absolute.backdrop-blur.h-full") + if (node) { + node.style.display = "None"; //parentNode.removeChild(node) + } + + gallery.querySelectorAll('img').forEach(function(e){ + e.onclick = inspiration_image_click + }) + + } + + + }); + mutationObserver.observe( gradioApp(), { childList:true, subtree:true }); + +}); |