diff options
author | yfszzx <yfszzx@gmail.com> | 2022-10-21 17:23:00 +0000 |
---|---|---|
committer | yfszzx <yfszzx@gmail.com> | 2022-10-21 17:23:00 +0000 |
commit | bb0f1a2cdae3410a41d06ae878f56e29b8154c41 (patch) | |
tree | b76c3f206290928a2430f5ba1b6d15bb108a7d13 /javascript | |
parent | dc66540629975a2a92128833e39702bfc955b15b (diff) | |
download | stable-diffusion-webui-gfx803-bb0f1a2cdae3410a41d06ae878f56e29b8154c41.tar.gz stable-diffusion-webui-gfx803-bb0f1a2cdae3410a41d06ae878f56e29b8154c41.tar.bz2 stable-diffusion-webui-gfx803-bb0f1a2cdae3410a41d06ae878f56e29b8154c41.zip |
inspiration finished
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/inspiration.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/javascript/inspiration.js b/javascript/inspiration.js index e1c0e114..791a80c9 100644 --- a/javascript/inspiration.js +++ b/javascript/inspiration.js @@ -1,25 +1,31 @@ function public_image_index_in_gallery(item, gallery){ + var imgs = gallery.querySelectorAll("img.h-full") var index; var i = 0; - gallery.querySelectorAll("img").forEach(function(e){ + imgs.forEach(function(e){ if (e == item) index = i; i += 1; }); + var num = imgs.length / 2 + index = (index < num) ? index : (index - num) return index; } -function inspiration_selected(name, types, name_list){ +function inspiration_selected(name, name_list){ var btn = gradioApp().getElementById("inspiration_select_button") - return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index"), types]; -} + return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index")]; +} +function inspiration_click_get_button(){ + gradioApp().getElementById("inspiration_get_button").click(); +} 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) + 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") @@ -27,11 +33,10 @@ document.addEventListener("DOMContentLoaded", function() { 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 - }) + }); } |