This commit is contained in:
2025-11-24 00:57:19 +01:00
parent 0b6f30a83e
commit f3cd26ba89
6 changed files with 1319 additions and 63 deletions

View File

@@ -1,5 +1,19 @@
// public/assets/js/header.js
document.addEventListener('DOMContentLoaded', function () {
const supportedLangs = ['de', 'en', 'it', 'fr'];
function resolveCurrentLang() {
const url = new URL(window.location.href);
const urlLang = (url.searchParams.get('lang') || '').toLowerCase();
const docLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
const globalLang = (window.currentLang || '').toLowerCase();
if (supportedLangs.includes(urlLang)) return urlLang;
if (supportedLangs.includes(globalLang)) return globalLang;
if (supportedLangs.includes(docLang)) return docLang;
return 'de';
}
// --------------------------------------------------
// LOGIN-BUTTON → /login mit redirect + lang
// --------------------------------------------------
@@ -13,12 +27,8 @@ document.addEventListener('DOMContentLoaded', function () {
const currentQuery = window.location.search || '';
const redirect = currentPath + currentQuery;
// Sprache aus dem Label oben ziehen, falls vorhanden
const langLabelEl = document.getElementById('langCurrentLabel');
let lang = 'de';
if (langLabelEl && langLabelEl.textContent) {
lang = langLabelEl.textContent.trim().toLowerCase();
}
// Sprache aus URL / globalem State ableiten
const lang = resolveCurrentLang();
// Wenn wir bereits auf /login sind → nur zum #auth scrollen
if (currentPath === '/login' || currentPath === '/login/') {