mirror of
https://codeberg.org/kirche-im-netz/Startodon-Hub.git
synced 2025-08-19 00:58:17 +02:00
js refactoring; stylesheet optimized; starterkit entwicklung
This commit is contained in:
parent
eda868da25
commit
4affe858bc
9 changed files with 354 additions and 287 deletions
48
src/main.js
Normal file
48
src/main.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { createStarterKitElement, enhanceStarterKits } from './utils/starterkit-utils.js';
|
||||
import { seededShuffleChildren } from './utils/shuffle-utils.js';
|
||||
|
||||
async function loadTemplates() {
|
||||
const response = await fetch('src/template/template.html');
|
||||
const templateHTML = await response.text();
|
||||
|
||||
// Füge die Templates in das DOM ein
|
||||
const templateContainer = document.createElement('div');
|
||||
templateContainer.innerHTML = templateHTML;
|
||||
document.body.appendChild(templateContainer);
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async function () {
|
||||
await loadTemplates(); // Templates laden
|
||||
|
||||
const container = document.getElementById('starterkit-container');
|
||||
const shuffleContainers = document.querySelectorAll('.shuffle-container');
|
||||
const seed = Date.now();
|
||||
|
||||
// Lade die Haupt-Konfigurationsdatei
|
||||
fetch('config.json')
|
||||
.then(response => response.json())
|
||||
.then(config => {
|
||||
const starterkitFiles = config.starterkits;
|
||||
|
||||
// Lade alle StarterKit-Dateien
|
||||
return Promise.all(
|
||||
starterkitFiles.map(file => fetch(file).then(res => res.json()))
|
||||
);
|
||||
})
|
||||
.then(starterkits => {
|
||||
// Verarbeite die geladenen StarterKits
|
||||
starterkits.forEach(kit => {
|
||||
const kitElement = createStarterKitElement(kit);
|
||||
container.appendChild(kitElement);
|
||||
});
|
||||
|
||||
// Shuffle-Logik anwenden
|
||||
shuffleContainers.forEach(container => {
|
||||
seededShuffleChildren(container, seed);
|
||||
});
|
||||
|
||||
// Zusätzliche Funktionalität für StarterKits hinzufügen
|
||||
enhanceStarterKits();
|
||||
})
|
||||
.catch(error => console.error('Fehler beim Laden der StarterKits:', error));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue