From 69f17424868f7c8338179faf15a035c3788d604b Mon Sep 17 00:00:00 2001 From: Serverlele30 <46974281+Serverlele30@users.noreply.github.com> Date: Mon, 20 Oct 2025 13:13:06 +0200 Subject: [PATCH] Add files via upload --- app.js | 237 ++++++++++++++++++++----- index.html | 27 ++- style.css | 505 +++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 693 insertions(+), 76 deletions(-) diff --git a/app.js b/app.js index 55221f0..98c7865 100644 --- a/app.js +++ b/app.js @@ -1,19 +1,56 @@ // ============================= -// Karte initialisieren +// Dark Mode +// ============================= +const darkModeToggle = document.getElementById('darkModeToggle'); +const body = document.body; + +const savedTheme = localStorage.getItem('theme') || 'light'; +if (savedTheme === 'dark') { + body.classList.add('dark-mode'); + darkModeToggle.querySelector('.toggle-icon').textContent = 'โ๏ธ'; +} + +darkModeToggle.addEventListener('click', () => { + body.classList.toggle('dark-mode'); + const isDark = body.classList.contains('dark-mode'); + darkModeToggle.querySelector('.toggle-icon').textContent = isDark ? 'โ๏ธ' : '๐'; + localStorage.setItem('theme', isDark ? 'dark' : 'light'); + updateMapTiles(); +}); + +// ============================= +// Map Setup // ============================= const map = L.map('map').setView([52.52, 13.405], 13); +let currentTileLayer; -L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - maxZoom: 19, - attribution: 'ยฉ OpenStreetMap contributors' -}).addTo(map); +function updateMapTiles() { + if (currentTileLayer) { + map.removeLayer(currentTileLayer); + } + + const isDark = body.classList.contains('dark-mode'); + + if (isDark) { + currentTileLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', { + maxZoom: 19, + attribution: 'ยฉ OpenStreetMap contributors ยฉ CARTO' + }).addTo(map); + } else { + currentTileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, + attribution: 'ยฉ OpenStreetMap contributors' + }).addTo(map); + } +} + +updateMapTiles(); -// Layer fรผr Fahrzeuge const vehiclesLayer = L.layerGroup().addTo(map); const vehicleMarkers = {}; // ============================= -// Farben & Symbole +// Colors & Symbols // ============================= const lineColors = { 'S45': '#CD9C53', 'S46': '#CD9C53', 'S47': '#CD9C53', 'S6': '#CD9C53', 'S65': '#CD9C53', 'S66': '#CD9C53', @@ -36,8 +73,13 @@ const symbols = { regional: '๐', express: '๐', longDistance: '๐ ', ferry: '๐ฅ๏ธ' }; +const productNames = { + bus: 'Bus', tram: 'Straรenbahn', subway: 'U-Bahn', suburban: 'S-Bahn', + regional: 'Regional', express: 'Express', longDistance: 'Fernverkehr', ferry: 'Fรคhre' +}; + // ============================= -// Hilfsfunktionen +// Helper Functions // ============================= function getLineColor(lineName, product) { if(lineName === 'U12') return null; @@ -59,8 +101,8 @@ function createDivIcon(vehicle) { if(lineName === 'U12') { const iconHtml = ` -