mirror of
https://codeberg.org/kirche-im-netz/Startodon-Hub.git
synced 2025-07-24 04:44:46 +02:00
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import { createStarterKitElement, enhanceStarterKits } from './utils/starterkit-utils.js';
|
|
import { seededShuffleChildren } from './utils/shuffle-utils.js';
|
|
import { initializeCreateStarterKitPopup } from './utils/create-starterkit.js';
|
|
import { loadPostwall } from './components/postwall.js';
|
|
|
|
document.addEventListener('DOMContentLoaded', async function () {
|
|
// Starte sofort den Seitenaufbau
|
|
initializeSite();
|
|
});
|
|
|
|
async function initializeSite() {
|
|
await loadTemplates();
|
|
|
|
initializeCreateStarterKitPopup();
|
|
|
|
// Lade die Postwall
|
|
loadPostwall();
|
|
|
|
const container = document.getElementById('starterkit-container');
|
|
const shuffleContainers = document.querySelectorAll('.shuffle-container');
|
|
const seed = Date.now();
|
|
|
|
fetch('config.json')
|
|
.then(response => response.json())
|
|
.then(config => {
|
|
const starterkitFiles = config.starterkits;
|
|
|
|
return Promise.all(
|
|
starterkitFiles.map(file => fetch(file).then(res => res.json()))
|
|
);
|
|
})
|
|
.then(starterkits => {
|
|
starterkits.forEach(kit => {
|
|
const kitElement = createStarterKitElement(kit);
|
|
container.appendChild(kitElement);
|
|
});
|
|
|
|
shuffleContainers.forEach(container => {
|
|
seededShuffleChildren(container, seed);
|
|
});
|
|
|
|
enhanceStarterKits();
|
|
})
|
|
.catch(error => console.error('Fehler beim Laden der StarterKits:', error));
|
|
}
|
|
|
|
async function loadTemplates() {
|
|
const response = await fetch('src/template/template.html');
|
|
const templateHTML = await response.text();
|
|
|
|
const templateContainer = document.createElement('div');
|
|
templateContainer.innerHTML = templateHTML;
|
|
document.body.appendChild(templateContainer);
|
|
}
|