mirror of
https://github.com/vladmandic/automatic
synced 2026-09-03 11:30:46 +02:00
avoid js double load
This commit is contained in:
@@ -207,17 +207,18 @@ function setupExtraNetworksForTab(tabname) {
|
||||
const div = document.createElement('div');
|
||||
div.classList.add('second-line');
|
||||
tabs.appendChild(div);
|
||||
const txtSearch = gradioApp().querySelector(`#${tabname}_extra_search textarea`);
|
||||
const txtSearch = gradioApp().querySelector(`#${tabname}_extra_search`);
|
||||
const txtSearchValue = gradioApp().querySelector(`#${tabname}_extra_search textarea`);
|
||||
const txtDescription = gradioApp().getElementById(`${tabname}_description`);
|
||||
txtSearch.classList.add('search');
|
||||
txtDescription.classList.add('description');
|
||||
div.appendChild(txtSearch);
|
||||
div.appendChild(txtDescription);
|
||||
let searchTimer = null;
|
||||
txtSearch.addEventListener('input', (evt) => {
|
||||
txtSearchValue.addEventListener('input', (evt) => {
|
||||
if (searchTimer) clearTimeout(searchTimer);
|
||||
searchTimer = setTimeout(() => {
|
||||
filterExtraNetworksForTab(tabname, txtSearch.value.toLowerCase());
|
||||
filterExtraNetworksForTab(tabname, txtSearchValue.value.toLowerCase());
|
||||
searchTimer = null;
|
||||
}, 150);
|
||||
});
|
||||
|
||||
@@ -79,8 +79,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
executedOnLoaded = true;
|
||||
executeCallbacks(uiLoadedCallbacks);
|
||||
}
|
||||
executeCallbacks(uiUpdateCallbacks, m);
|
||||
scheduleAfterUiUpdateCallbacks();
|
||||
if (executedOnLoaded) {
|
||||
executeCallbacks(uiUpdateCallbacks, m);
|
||||
scheduleAfterUiUpdateCallbacks();
|
||||
}
|
||||
const newTab = getUICurrentTab();
|
||||
if (newTab && (newTab !== uiCurrentTab)) {
|
||||
uiCurrentTab = newTab;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
let settingsInitialized = false;
|
||||
let opts_metadata = {};
|
||||
const opts_tabs = {};
|
||||
|
||||
@@ -47,6 +48,7 @@ function showAllSettings() {
|
||||
}
|
||||
|
||||
function markIfModified(setting_name, value) {
|
||||
if (!opts_metadata[setting_name]) return;
|
||||
const elem = gradioApp().getElementById(`modification_indicator_${setting_name}`);
|
||||
if (!elem) return;
|
||||
const previous_value = JSON.stringify(opts[setting_name]);
|
||||
@@ -137,7 +139,9 @@ onOptionsChanged(() => {
|
||||
});
|
||||
});
|
||||
|
||||
onUiLoaded(() => {
|
||||
function initSettings() {
|
||||
if (settingsInitialized) return;
|
||||
settingsInitialized = true;
|
||||
const tab_nav_element = gradioApp().querySelector('#settings > .tab-nav');
|
||||
const tab_nav_buttons = gradioApp().querySelectorAll('#settings > .tab-nav > button');
|
||||
const tab_elements = gradioApp().querySelectorAll('#settings > div:not(.tab-nav)');
|
||||
@@ -158,4 +162,6 @@ onUiLoaded(() => {
|
||||
observer.observe(elem, { attributes: true, attributeFilter: ['style'] });
|
||||
});
|
||||
log('initSettings');
|
||||
});
|
||||
}
|
||||
|
||||
onUiLoaded(initSettings);
|
||||
|
||||
@@ -10,12 +10,14 @@ function uiOpenSubmenus() {
|
||||
return states;
|
||||
}
|
||||
|
||||
onUiLoaded(() => {
|
||||
function getUIDefaults() {
|
||||
const btn = gradioApp().getElementById('ui_defaults_view');
|
||||
if (!btn) return;
|
||||
const intersectionObserver = new IntersectionObserver((entries) => {
|
||||
if (entries[0].intersectionRatio <= 0) {}
|
||||
if (entries[0].intersectionRatio <= 0) { }
|
||||
if (entries[0].intersectionRatio > 0) btn.click();
|
||||
});
|
||||
intersectionObserver.observe(btn); // monitor visibility of tab
|
||||
});
|
||||
}
|
||||
|
||||
onUiLoaded(getUIDefaults);
|
||||
|
||||
Reference in New Issue
Block a user