59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
// seasonals.js
|
|
class SeasonalThemes {
|
|
constructor() {
|
|
this.currentTheme = this.determineCurrentTheme();
|
|
this.loadTheme();
|
|
}
|
|
|
|
determineCurrentTheme() {
|
|
const date = new Date();
|
|
const month = date.getMonth();
|
|
|
|
// Beispielhafte Theme-Zuordnung
|
|
if (month === 11 || month === 0 || month === 1) return 'winter'; // Dezember, Januar, Februar
|
|
if (month >= 2 && month <= 4) return 'spring';
|
|
if (month >= 5 && month <= 7) return 'summer';
|
|
if (month >= 8 && month <= 10) return 'autumn';
|
|
|
|
return 'winter'; // Fallback
|
|
}
|
|
|
|
loadTheme() {
|
|
const themeConfigs = {
|
|
winter: {
|
|
css: 'snowflakes.css',
|
|
js: 'snowflakes.js',
|
|
containerClass: 'snowflakes'
|
|
},
|
|
summer: {
|
|
css: 'beach.css',
|
|
js: 'beach.js',
|
|
containerClass: 'beach'
|
|
},
|
|
// ... andere Themes
|
|
};
|
|
|
|
const theme = themeConfigs[this.currentTheme];
|
|
|
|
// CSS dynamisch laden
|
|
const link = document.createElement('link');
|
|
link.rel = 'stylesheet';
|
|
link.href = theme.css;
|
|
document.head.appendChild(link);
|
|
|
|
// JavaScript dynamisch laden
|
|
const script = document.createElement('script');
|
|
script.src = theme.js;
|
|
document.body.appendChild(script);
|
|
|
|
// Themen-Container hinzufügen mit dynamischer Klasse
|
|
const container = document.createElement('div');
|
|
container.className = `seasonals ${theme.containerClass}`;
|
|
document.body.appendChild(container);
|
|
}
|
|
}
|
|
|
|
// Initialisierung beim Laden der Seite
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
new SeasonalThemes();
|
|
}); |