mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-17 11:50:18 +08:00
revert IIFE
This commit is contained in:
parent
fbc51fa210
commit
8bf30e3c42
@ -3,14 +3,13 @@
|
||||
// Counts open and closed brackets (round, square, curly) in the prompt and negative prompt text boxes in the txt2img and img2img tabs.
|
||||
// If there's a mismatch, the keyword counter turns red, and if you hover on it, a tooltip tells you what's wrong.
|
||||
|
||||
(function() {
|
||||
function checkBrackets(textArea, counterElem) {
|
||||
const pairs = [
|
||||
['(', ')', 'round brackets'],
|
||||
['[', ']', 'square brackets'],
|
||||
['{', '}', 'curly brackets']
|
||||
];
|
||||
|
||||
function checkBrackets(textArea, counterElem) {
|
||||
const counts = {};
|
||||
const errors = new Set();
|
||||
let i = 0;
|
||||
@ -57,21 +56,20 @@
|
||||
|
||||
counterElem.title = [...errors].join('\n');
|
||||
counterElem.classList.toggle('error', errors.size !== 0);
|
||||
}
|
||||
}
|
||||
|
||||
function setupBracketChecking(id_prompt, id_counter) {
|
||||
function setupBracketChecking(id_prompt, id_counter) {
|
||||
const textarea = gradioApp().querySelector(`#${id_prompt} > label > textarea`);
|
||||
const counter = gradioApp().getElementById(id_counter);
|
||||
|
||||
if (textarea && counter) {
|
||||
onEdit(`${id_prompt}_BracketChecking`, textarea, 400, () => checkBrackets(textarea, counter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onUiLoaded(function() {
|
||||
onUiLoaded(function() {
|
||||
setupBracketChecking('txt2img_prompt', 'txt2img_token_counter');
|
||||
setupBracketChecking('txt2img_neg_prompt', 'txt2img_negative_token_counter');
|
||||
setupBracketChecking('img2img_prompt', 'img2img_token_counter');
|
||||
setupBracketChecking('img2img_neg_prompt', 'img2img_negative_token_counter');
|
||||
});
|
||||
})();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user