update
This commit is contained in:
@@ -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/') {
|
||||
|
||||
Reference in New Issue
Block a user