aboutsummaryrefslogtreecommitdiff
path: root/javascript/ui.js
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-31 07:38:34 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2023-08-31 07:38:34 +0300
commit5ef669de080814067961f28357256e8fe27544f4 (patch)
tree655f4582e692f0fc3667b3b668ad365ac3ab92ae /javascript/ui.js
parentc9c8485bc1e8720aba70f029d25cba1c4abf2b5c (diff)
parente7965a5eb804a51e949df07c66c0b7c61ab7fa7b (diff)
Merge branch 'release_candidate'
Diffstat (limited to 'javascript/ui.js')
-rw-r--r--javascript/ui.js39
1 files changed, 10 insertions, 29 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index d70a681b..bedcbf3e 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) {
@@ -152,11 +135,11 @@ function submit() {
showSubmitButtons('txt2img', false);
var id = randomId();
- localStorage.setItem("txt2img_task_id", id);
+ localSet("txt2img_task_id", id);
requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function() {
showSubmitButtons('txt2img', true);
- localStorage.removeItem("txt2img_task_id");
+ localRemove("txt2img_task_id");
showRestoreProgressButton('txt2img', false);
});
@@ -171,11 +154,11 @@ function submit_img2img() {
showSubmitButtons('img2img', false);
var id = randomId();
- localStorage.setItem("img2img_task_id", id);
+ localSet("img2img_task_id", id);
requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function() {
showSubmitButtons('img2img', true);
- localStorage.removeItem("img2img_task_id");
+ localRemove("img2img_task_id");
showRestoreProgressButton('img2img', false);
});
@@ -189,9 +172,7 @@ function submit_img2img() {
function restoreProgressTxt2img() {
showRestoreProgressButton("txt2img", false);
- var id = localStorage.getItem("txt2img_task_id");
-
- id = localStorage.getItem("txt2img_task_id");
+ var id = localGet("txt2img_task_id");
if (id) {
requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), function() {
@@ -205,7 +186,7 @@ function restoreProgressTxt2img() {
function restoreProgressImg2img() {
showRestoreProgressButton("img2img", false);
- var id = localStorage.getItem("img2img_task_id");
+ var id = localGet("img2img_task_id");
if (id) {
requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function() {
@@ -218,8 +199,8 @@ function restoreProgressImg2img() {
onUiLoaded(function() {
- showRestoreProgressButton('txt2img', localStorage.getItem("txt2img_task_id"));
- showRestoreProgressButton('img2img', localStorage.getItem("img2img_task_id"));
+ showRestoreProgressButton('txt2img', localGet("txt2img_task_id"));
+ showRestoreProgressButton('img2img', localGet("img2img_task_id"));
});