diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-05-19 13:34:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-19 13:34:27 +0000 |
commit | d41a31a50805fa70f7299f5c0384ad41db7142e5 (patch) | |
tree | 52c960e60d3fa4f5b59edf4eb9a41da4277b5805 /javascript/ui.js | |
parent | a6bf4aae309db608b4ea974559df711047992478 (diff) | |
parent | 67d4360453e0316b494a43320e2e5df53a93d5ea (diff) | |
download | stable-diffusion-webui-gfx803-d41a31a50805fa70f7299f5c0384ad41db7142e5.tar.gz stable-diffusion-webui-gfx803-d41a31a50805fa70f7299f5c0384ad41db7142e5.tar.bz2 stable-diffusion-webui-gfx803-d41a31a50805fa70f7299f5c0384ad41db7142e5.zip |
Merge pull request #10552 from akx/eslint-moar
More Eslint fixes
Diffstat (limited to 'javascript/ui.js')
-rw-r--r-- | javascript/ui.js | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/javascript/ui.js b/javascript/ui.js index c7316ddb..648a5290 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -61,18 +61,12 @@ function extract_image_from_gallery(gallery) { return [gallery[index]]; } -function args_to_array(args) { - var res = []; - for (var i = 0; i < args.length; i++) { - res.push(args[i]); - } - return res; -} +window.args_to_array = Array.from; // Compatibility with e.g. extensions that may expect this to be around function switch_to_txt2img() { gradioApp().querySelector('#tabs').querySelectorAll('button')[0].click(); - return args_to_array(arguments); + return Array.from(arguments); } function switch_to_img2img_tab(no) { @@ -81,65 +75,55 @@ function switch_to_img2img_tab(no) { } function switch_to_img2img() { switch_to_img2img_tab(0); - return args_to_array(arguments); + return Array.from(arguments); } function switch_to_sketch() { switch_to_img2img_tab(1); - return args_to_array(arguments); + return Array.from(arguments); } function switch_to_inpaint() { switch_to_img2img_tab(2); - return args_to_array(arguments); + return Array.from(arguments); } function switch_to_inpaint_sketch() { switch_to_img2img_tab(3); - return args_to_array(arguments); + return Array.from(arguments); } function switch_to_extras() { gradioApp().querySelector('#tabs').querySelectorAll('button')[2].click(); - return args_to_array(arguments); + return Array.from(arguments); } function get_tab_index(tabId) { - var res = 0; - - gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button').forEach(function(button, i) { - if (button.className.indexOf('selected') != -1) { - res = i; + let buttons = gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button'); + for (let i = 0; i < buttons.length; i++) { + if (buttons[i].classList.contains('selected')) { + return i; } - }); - - return res; + } + return 0; } function create_tab_index_args(tabId, args) { - var res = []; - for (var i = 0; i < args.length; i++) { - res.push(args[i]); - } - + var res = Array.from(args); res[0] = get_tab_index(tabId); - return res; } function get_img2img_tab_index() { - let res = args_to_array(arguments); + let res = Array.from(arguments); res.splice(-2); res[0] = get_tab_index('mode_img2img'); return res; } function create_submit_args(args) { - var res = []; - for (var i = 0; i < args.length; i++) { - res.push(args[i]); - } + var res = Array.from(args); // As it is currently, txt2img and img2img send back the previous output args (txt2img_gallery, generation_info, html_info) whenever you generate a new image. // This can lead to uploading a huge gallery of previously generated images, which leads to an unnecessary delay between submitting and beginning to generate. @@ -275,13 +259,13 @@ function recalculatePromptTokens(name) { function recalculate_prompts_txt2img() { recalculatePromptTokens('txt2img_prompt'); recalculatePromptTokens('txt2img_neg_prompt'); - return args_to_array(arguments); + return Array.from(arguments); } function recalculate_prompts_img2img() { recalculatePromptTokens('img2img_prompt'); recalculatePromptTokens('img2img_neg_prompt'); - return args_to_array(arguments); + return Array.from(arguments); } |