final edit sys-promt and markdown image

This commit is contained in:
2026-03-04 19:29:58 +00:00
parent fe3a25fa3a
commit 0923de4259
15 changed files with 1060 additions and 267 deletions

106
static/common.js Normal file
View File

@@ -0,0 +1,106 @@
/* ==========================================
NAVIGATION & MOBILE MENU
========================================== */
function toggleHamburger() {
const navLinks = document.getElementById('navLinks');
const hamburger = document.querySelector('.hamburger');
navLinks.classList.toggle('mobile-open');
hamburger.classList.toggle('active');
}
/* ==========================================
DROPDOWN LOGIC (Vereinheitlicht)
========================================== */
const langBtn = document.getElementById('langBtn');
const langDropdown = document.getElementById('langDropdown');
const themeBtn = document.getElementById('themeBtn');
const themeDropdown = document.getElementById('themeDropdown');
// Funktion zum Schließen aller Dropdowns
function closeAllDropdowns() {
if (langDropdown) langDropdown.classList.remove('show');
if (themeDropdown) themeDropdown.classList.remove('show');
}
// Event Listener für Sprach-Dropdown
if (langBtn) {
langBtn.addEventListener('click', (e) => {
e.stopPropagation();
closeAllDropdowns();
langDropdown.classList.toggle('show');
});
}
// Event Listener für Theme-Dropdown
if (themeBtn) {
themeBtn.addEventListener('click', (e) => {
e.stopPropagation();
closeAllDropdowns();
themeDropdown.classList.toggle('show');
});
}
// Klick außerhalb schließt alle
window.addEventListener('click', () => {
closeAllDropdowns();
});
/* ==========================================
LANGUAGE SWITCHER LOGIC
========================================== */
if (langDropdown) {
langDropdown.querySelectorAll('.theme-option').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const selectedLang = link.getAttribute('data-lang');
const currentPath = window.location.pathname;
// URL Logik: Pfad ersetzen
let newPath = currentPath.replace(/^\/(de|en|fr|es|ru)(\/|$)/, '/' + selectedLang + '/');
if (currentPath === '/' || !newPath.startsWith('/' + selectedLang)) {
newPath = '/' + selectedLang + '/';
}
newPath = newPath.replace(/\/+/g, '/');
window.location.href = newPath;
});
});
}
/* ==========================================
THEME SWITCHER LOGIC
========================================== */
const themeOptions = document.querySelectorAll('#themeDropdown .theme-option');
const htmlEl = document.documentElement;
themeOptions.forEach(btn => {
btn.addEventListener('click', () => {
const action = btn.getAttribute('data-theme');
let theme;
if (action === 'setdark') theme = 'dark';
else if (action === 'setlight') theme = 'light';
else theme = 'auto';
applyTheme(theme);
});
});
function applyTheme(theme) {
if (theme === 'auto') {
localStorage.removeItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
htmlEl.setAttribute('data-theme', prefersDark ? 'dark' : 'light');
themeBtn.innerHTML = '🌓';
} else {
htmlEl.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
themeBtn.innerHTML = theme === 'dark' ? '🌙' : '☀️';
}
}