diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 832ea8f6..e5099951 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -17,6 +17,7 @@ * along with this program. If not, see . */ +import Placeholder from '../../util/Placeholder.js'; import UIWindow from '../UIWindow.js' async function UIWindowSettings(options){ @@ -26,6 +27,7 @@ async function UIWindowSettings(options){ const svc_settings = globalThis.services.get('settings'); const tabs = svc_settings.get_tabs(); + const tab_placeholders = []; let h = ''; @@ -42,9 +44,14 @@ async function UIWindowSettings(options){ h += `
`; tabs.forEach((tab, i) => { - h += `
- ${tab.html()} -
`; + h += `
`; + if ( tab.factory ) { + tab_placeholders[i] = Placeholder(); + h += tab_placeholders[i].html; + } else { + h += tab.html(); + } + h += `
`; }); h += `
`; @@ -85,7 +92,13 @@ async function UIWindowSettings(options){ } }); const $el_window = $(el_window); - tabs.forEach(tab => tab.init($el_window)); + tabs.forEach((tab, i) => { + tab.init && tab.init($el_window); + if ( tab.factory ) { + const component = tab.factory(); + component.attach(tab_placeholders[i]); + } + }); $(el_window).on('click', '.settings-sidebar-item', function(){ const $this = $(this); diff --git a/src/init_sync.js b/src/init_sync.js index 44277a2f..cea2e534 100644 --- a/src/init_sync.js +++ b/src/init_sync.js @@ -84,7 +84,8 @@ logger.info('start -> blocking initialization'); } if ( registry_.classes_m[id] ) { - throw new Error(`Class with ID ${id} already registered`); + // throw new Error(`Class with ID ${id} already registered`); + return; } registry_.classes_m[id] = cls; diff --git a/src/util/Placeholder.js b/src/util/Placeholder.js index 48bf6019..5515a9f7 100644 --- a/src/util/Placeholder.js +++ b/src/util/Placeholder.js @@ -18,7 +18,7 @@ * * @returns {PlaceholderReturn} */ -const Placeholder = () => { +const Placeholder = def(() => { const id = Placeholder.get_next_id_(); return { $: 'placeholder', @@ -29,7 +29,7 @@ const Placeholder = () => { place.replaceWith(el); } }; -}; +}, 'util.Placeholder'); const anti_collision = `94d2cb6b85a1`; // Arbitrary random string Placeholder.next_id_ = 0;