asdasd
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
(function () {
|
||||
const root = document.getElementById('mining-checker-app');
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return;
|
||||
}
|
||||
function boot(root) {
|
||||
if (!root || !window.React || !window.ReactDOM) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const h = React.createElement;
|
||||
const { useEffect, useMemo, useRef, useState } = React;
|
||||
const apiBase = root.dataset.apiBase || '/api/mining-checker/v1';
|
||||
const initialProjectKey = root.dataset.defaultProjectKey || 'doge-main';
|
||||
const initialActiveTab = String(root.dataset.activeView || 'overview').trim() || 'overview';
|
||||
const configuredSections = (() => {
|
||||
try {
|
||||
const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
|
||||
if (!Array.isArray(parsed)) {
|
||||
const h = React.createElement;
|
||||
const { useEffect, useMemo, useRef, useState } = React;
|
||||
const apiBase = root.dataset.apiBase || '/api/mining-checker/v1';
|
||||
const initialProjectKey = root.dataset.defaultProjectKey || 'doge-main';
|
||||
const initialActiveTab = String(root.dataset.activeView || 'overview').trim() || 'overview';
|
||||
const configuredSections = (() => {
|
||||
try {
|
||||
const parsed = JSON.parse(root.dataset.sectionsJson || '[]');
|
||||
if (!Array.isArray(parsed)) {
|
||||
return [];
|
||||
}
|
||||
return parsed
|
||||
.map((section) => {
|
||||
const key = section && typeof section.key === 'string' ? section.key.trim() : '';
|
||||
const label = section && typeof section.label === 'string' ? section.label.trim() : '';
|
||||
return key && label ? [key, label] : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
return parsed
|
||||
.map((section) => {
|
||||
const key = section && typeof section.key === 'string' ? section.key.trim() : '';
|
||||
const label = section && typeof section.label === 'string' ? section.label.trim() : '';
|
||||
return key && label ? [key, label] : null;
|
||||
})
|
||||
.filter(Boolean);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
})();
|
||||
const initialDebugMode = document.body && document.body.dataset.moduleDebugEnabled === '1';
|
||||
})();
|
||||
const initialDebugMode = root.dataset.moduleDebugEnabled === '1'
|
||||
|| (document.body && document.body.dataset.moduleDebugEnabled === '1');
|
||||
function getCookie(name) {
|
||||
const pattern = `; ${document.cookie}`;
|
||||
const parts = pattern.split(`; ${name}=`);
|
||||
@@ -3184,5 +3185,47 @@
|
||||
}
|
||||
}
|
||||
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
ReactDOM.createRoot(root).render(h(App));
|
||||
return true;
|
||||
}
|
||||
|
||||
window.initMiningCheckerApp = function initMiningCheckerApp(root, options) {
|
||||
if (!(root instanceof HTMLElement)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const config = options && typeof options === 'object' ? options : {};
|
||||
|
||||
if (config.apiBase) {
|
||||
root.dataset.apiBase = String(config.apiBase);
|
||||
}
|
||||
if (config.defaultProjectKey) {
|
||||
root.dataset.defaultProjectKey = String(config.defaultProjectKey);
|
||||
}
|
||||
if (config.activeView) {
|
||||
root.dataset.activeView = String(config.activeView);
|
||||
}
|
||||
if (config.sections) {
|
||||
root.dataset.sectionsJson = JSON.stringify(config.sections);
|
||||
}
|
||||
if (config.moduleDebugEnabled !== undefined) {
|
||||
root.dataset.moduleDebugEnabled = config.moduleDebugEnabled ? '1' : '0';
|
||||
}
|
||||
|
||||
if (root.dataset.miningCheckerMounted === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
const mounted = boot(root);
|
||||
if (mounted) {
|
||||
root.dataset.miningCheckerMounted = '1';
|
||||
}
|
||||
|
||||
return mounted;
|
||||
};
|
||||
|
||||
const root = document.getElementById('mining-checker-app');
|
||||
if (root) {
|
||||
window.initMiningCheckerApp(root);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -410,6 +410,22 @@ h1 {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.window-content--module {
|
||||
position: relative;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.window-module-host {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.window-module-error {
|
||||
padding: 18px;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.window-embed-fallback {
|
||||
position: absolute;
|
||||
inset: auto 16px 16px 16px;
|
||||
|
||||
@@ -108,6 +108,14 @@ if (payloadNode) {
|
||||
};
|
||||
|
||||
const buildWindowBody = (definition) => {
|
||||
if (definition.content_mode === 'native-module' && definition.app_id === 'mining-checker') {
|
||||
return `
|
||||
<div class="window-content window-content--embedded window-content--module">
|
||||
<div class="window-module-host" data-module-app="mining-checker"></div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (definition.content_mode === 'iframe' && typeof definition.entry_route === 'string' && definition.entry_route !== '') {
|
||||
const title = escapeHtml(definition.title);
|
||||
const src = escapeHtml(definition.entry_route);
|
||||
@@ -544,6 +552,22 @@ if (payloadNode) {
|
||||
}, { once: true });
|
||||
}
|
||||
|
||||
const moduleHost = node.querySelector('.window-module-host');
|
||||
if (moduleHost && definition.content_mode === 'native-module' && definition.app_id === 'mining-checker') {
|
||||
const moduleOptions = definition.module_options || {};
|
||||
if (typeof window.initMiningCheckerApp === 'function') {
|
||||
window.initMiningCheckerApp(moduleHost, {
|
||||
apiBase: '/api/mining-checker/index.php/v1',
|
||||
defaultProjectKey: moduleOptions.default_project_key || 'doge-main',
|
||||
activeView: moduleOptions.active_view || 'overview',
|
||||
sections: Array.isArray(moduleOptions.sections) ? moduleOptions.sections : [],
|
||||
moduleDebugEnabled: false,
|
||||
});
|
||||
} else {
|
||||
moduleHost.innerHTML = '<div class="window-module-error">Mining-Checker Assets konnten nicht initialisiert werden.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
node.querySelectorAll('.window-action').forEach((action) => {
|
||||
action.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
@@ -595,6 +619,7 @@ if (payloadNode) {
|
||||
content: app.summary || '',
|
||||
entry_route: app.entry_route || '',
|
||||
content_mode: app.content_mode || 'summary',
|
||||
module_options: app.module_options || null,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user