networks indicator for active loras

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-08-06 07:25:28 -04:00
parent 5fd44e473e
commit e23ca199c0
6 changed files with 38 additions and 17 deletions
+21 -7
View File
@@ -239,14 +239,31 @@ function refreshENInput(tabname) {
gradioApp().querySelector(`#${tabname}_extra_networks textarea`)?.dispatchEvent(new Event('input'));
}
function cardClicked(textToAdd, allowNegativePrompt) {
// log('cardClicked', textToAdd, allowNegativePrompt);
async function markSelectedCards(selected, page = '') {
log('markSelectedCards', selected, page);
gradioApp().querySelectorAll('.extra-network-cards .card').forEach((el) => {
if (page.length > 0 && el.dataset.page !== page) return; // filter by page
if (selected.includes(el.dataset.name) || selected.includes(el.dataset.short)) el.classList.add('card-selected');
else el.classList.remove('card-selected');
});
}
function extractLoraNames(prompt) {
const regex = /<lora:([^:>]+)(?::[\d.]+)?>/g;
const names = [];
let match;
while ((match = regex.exec(prompt)) !== null) names.push(match[1]); // eslint-disable-line no-cond-assign
return names;
}
function cardClicked(textToAdd) {
const tabname = getENActiveTab();
log('cardClicked', tabname, textToAdd);
const textarea = allowNegativePrompt ? activePromptTextarea[tabname] : gradioApp().querySelector(`#${tabname}_prompt > label > textarea`);
const textarea = activePromptTextarea[tabname];
if (textarea.value.indexOf(textToAdd) !== -1) textarea.value = textarea.value.replace(textToAdd, '');
else textarea.value += textToAdd;
updateInput(textarea);
markSelectedCards(extractLoraNames(textarea.value), 'lora');
}
function extraNetworksSearchButton(event) {
@@ -278,10 +295,7 @@ function applyStyles(styles) {
const index = newStyles.indexOf(desiredStyle);
if (index > -1) newStyles.splice(index, 1);
else newStyles.push(desiredStyle);
gradioApp().querySelectorAll('.extra-network-cards .card').forEach((el) => {
if (newStyles.includes(el.getAttribute('data-name'))) el.classList.add('card-selected');
else el.classList.remove('card-selected');
});
markSelectedCards(newStyles, 'style');
return newStyles.join('|');
}
+6 -3
View File
@@ -484,20 +484,23 @@ function selectCheckpoint(name) {
const isRefiner = btnModel && btnModel.classList.contains('toolbutton-selected');
if (isRefiner) gradioApp().getElementById('change_refiner').click();
else gradioApp().getElementById('change_checkpoint').click();
log(`Change ${isRefiner ? 'refiner' : 'model'}: ${desiredCheckpointName}`);
log(`selectCheckpoint ${isRefiner ? 'refiner' : 'model'}: ${desiredCheckpointName}`);
markSelectedCards([desiredCheckpointName], 'model');
}
let desiredVAEName = null;
function selectVAE(name) {
desiredVAEName = name;
gradioApp().getElementById('change_vae').click();
log(`Change VAE: ${desiredVAEName}`);
log(`selectVAE: ${desiredVAEName}`);
markSelectedCards([desiredVAEName], 'vae');
}
function selectReference(name) {
log(`Select reference: ${name}`);
log(`selectReference: ${name}`);
desiredCheckpointName = name;
gradioApp().getElementById('change_reference').click();
markSelectedCards([desiredCheckpointName], 'model');
}
function currentImageResolutionimg2img(_a, _b, scaleBy) {