mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
reorganize js callbacks and startup sequence
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
// 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.
|
||||
|
||||
let promptCheckerInitialized = false;
|
||||
|
||||
function checkBrackets(textArea, counterElt) {
|
||||
const counts = {};
|
||||
const errors = [];
|
||||
@@ -25,17 +23,15 @@ function setupBracketChecking(idPrompt, idCounter) {
|
||||
const textarea = gradioApp().querySelector(`#${idPrompt} > label > textarea`);
|
||||
const counter = gradioApp().getElementById(idCounter);
|
||||
if (!textarea || !counter) return;
|
||||
if (!promptCheckerInitialized) log('initPromptChecker');
|
||||
promptCheckerInitialized = true;
|
||||
textarea.addEventListener('input', () => checkBrackets(textarea, counter));
|
||||
}
|
||||
|
||||
onAfterUiUpdate(() => {
|
||||
if (promptCheckerInitialized) return;
|
||||
async function initPromptChecker() {
|
||||
log('initPromptChecker');
|
||||
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');
|
||||
setupBracketChecking('control_prompt', 'control_token_counter');
|
||||
setupBracketChecking('control_neg_prompt', 'control_negative_token_counter');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user