2024-12-10 22:53:16 +01:00
|
|
|
import { createStarterKitElement, enhanceStarterKits } from './utils/starterkit-utils.js';
|
|
|
|
import { seededShuffleChildren } from './utils/shuffle-utils.js';
|
2024-12-16 22:57:46 +01:00
|
|
|
import { initializeCreateStarterKitPopup } from './utils/create-starterkit.js';
|
2024-12-28 15:17:57 +01:00
|
|
|
import { loadPostwall } from './components/postwall.js';
|
2024-12-10 22:53:16 +01:00
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', async function () {
|
2024-12-29 12:24:22 +01:00
|
|
|
// Starte sofort den Seitenaufbau
|
2024-12-29 12:25:00 +01:00
|
|
|
initializeSite();
|
2024-12-29 12:20:30 +01:00
|
|
|
});
|
|
|
|
|
2024-12-29 12:25:00 +01:00
|
|
|
async function initializeSite() {
|
2024-12-19 22:38:21 +01:00
|
|
|
await loadTemplates();
|
2024-12-10 22:53:16 +01:00
|
|
|
|
2024-12-16 22:57:46 +01:00
|
|
|
initializeCreateStarterKitPopup();
|
|
|
|
|
2024-12-28 15:17:57 +01:00
|
|
|
// Lade die Postwall
|
|
|
|
loadPostwall();
|
|
|
|
|
2024-12-10 22:53:16 +01:00
|
|
|
const container = document.getElementById('starterkit-container');
|
|
|
|
const shuffleContainers = document.querySelectorAll('.shuffle-container');
|
|
|
|
const seed = Date.now();
|
|
|
|
|
2025-01-13 22:54:44 +01:00
|
|
|
fetch('config.json')
|
2024-12-10 22:53:16 +01:00
|
|
|
.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));
|
2024-12-29 12:20:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|