diff options
author | bluelovers <codelovers@users.sourceforge.net> | 2023-08-19 02:38:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-19 02:38:43 +0000 |
commit | 1631e96a98e519a1f2a0d24553622304c6d63523 (patch) | |
tree | a1ff16f4ffb55f12ca13a933dafc4eceb5eacece /javascript | |
parent | 68f336bd994bed5442ad95bad6b6ad5564a5409a (diff) | |
download | stable-diffusion-webui-gfx803-1631e96a98e519a1f2a0d24553622304c6d63523.tar.gz stable-diffusion-webui-gfx803-1631e96a98e519a1f2a0d24553622304c6d63523.tar.bz2 stable-diffusion-webui-gfx803-1631e96a98e519a1f2a0d24553622304c6d63523.zip |
refactor: Update ui.js
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/ui.js | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index d70a681b..cbd6b44e 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -19,28 +19,11 @@ function all_gallery_buttons() { } function selected_gallery_button() { - var allCurrentButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnail-item.thumbnail-small.selected'); - var visibleCurrentButton = null; - allCurrentButtons.forEach(function(elem) { - if (elem.parentElement.offsetParent) { - visibleCurrentButton = elem; - } - }); - return visibleCurrentButton; + return all_gallery_buttons().find(elem => elem.classList.contains('selected')) ?? null; } function selected_gallery_index() { - var buttons = all_gallery_buttons(); - var button = selected_gallery_button(); - - var result = -1; - buttons.forEach(function(v, i) { - if (v == button) { - result = i; - } - }); - - return result; + return all_gallery_buttons().findIndex(elem => elem.classList.contains('selected')); } function extract_image_from_gallery(gallery) { |