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-29 12:20:30 +01:00
|
|
|
import { checkConsent, setUserConsent, showConsentPopup } from './utils/consent-utils.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
|
|
|
|
initializeApp();
|
|
|
|
|
|
|
|
// Überprüfe parallel den Consent-Status
|
2024-12-29 12:20:30 +01:00
|
|
|
const consent = checkConsent();
|
|
|
|
if (!consent) {
|
|
|
|
showConsentPopup(
|
|
|
|
() => {
|
|
|
|
setUserConsent(true);
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
setUserConsent(false);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
async function initializeApp() {
|
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();
|
|
|
|
|
|
|
|
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));
|
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);
|
|
|
|
}
|