/** * Rechte Sidebar: Uebersicht aller aktiven Datenpunkte mit Suche. */ const Sidebar = { _open: true, _searchTerm: '', init() { var self = this; var toggle = document.getElementById('sidebar-toggle'); var search = document.getElementById('sidebar-search'); if (toggle) toggle.addEventListener('click', function() { self.toggle(); }); if (search) search.addEventListener('input', function() { self._searchTerm = this.value.toLowerCase(); self.update(); }); // Periodisch aktualisieren setInterval(function() { self.update(); }, 5000); }, toggle() { this._open = !this._open; var panel = document.getElementById('sidebar-right'); var toggle = document.getElementById('sidebar-toggle'); if (panel) panel.classList.toggle('collapsed', !this._open); if (toggle) toggle.innerHTML = this._open ? '' : ''; }, update() { var container = document.getElementById('sidebar-content'); if (!container) return; var html = ''; var term = this._searchTerm; // Monitor OSINT if (typeof MonitorLayer !== 'undefined' && MonitorLayer._data.length) { html += this._renderSection('monitor', 'OSINT Monitor', MonitorLayer._data, function(f) { var p = f.properties; return { name: p.name || '?', sub: (p.incident_title || '') + (p.article_count > 1 ? ' (' + p.article_count + ' Artikel)' : ''), color: { primary: '#ff2222', secondary: '#ff8800', tertiary: '#4499ff', mentioned: '#888' }[p.category] || '#888', lat: f.geometry.coordinates[1], lon: f.geometry.coordinates[0], }; }, term); } // Katastrophen if (typeof DisastersLayer !== 'undefined' && DisastersLayer._dataSource && DisastersLayer._count > 0) { var entities = DisastersLayer._dataSource.entities.values; var items = []; for (var i = 0; i < entities.length; i++) { var e = entities[i]; var name = e.name || (e._name && e._name.getValue ? e._name.getValue() : ''); if (!name && e.description) { var match = e.description.getValue().match(/]*>([^<]+)<\/strong>/); if (match) name = match[1]; } var pos = e.position ? e.position.getValue(Cesium.JulianDate.now()) : null; var carto = pos ? Cesium.Cartographic.fromCartesian(pos) : null; items.push({ name: name || 'Ereignis', sub: '', color: '#ff4400', lat: carto ? Cesium.Math.toDegrees(carto.latitude) : 0, lon: carto ? Cesium.Math.toDegrees(carto.longitude) : 0, entity: e, }); } html += this._renderEntitySection('disasters', 'Katastrophen + Erdbeben', items, term); } // Flugverkehr (nur count, keine Liste — zu viele) if (typeof FlightsLayer !== 'undefined' && FlightsLayer._count > 0) { html += this._renderCountSection('flights', 'Flugverkehr', FlightsLayer._count, '#00ff88'); } // Schiffsverkehr if (typeof ShipsLayer !== 'undefined' && ShipsLayer._count > 0) { html += this._renderCountSection('ships', 'Schiffsverkehr', ShipsLayer._count, '#4499ff'); } // Satelliten if (typeof SatellitesLayer !== 'undefined' && SatellitesLayer._count > 0) { html += this._renderCountSection('satellites', 'Satelliten', SatellitesLayer._count, '#ff4444'); } if (!html) { html = 'Keine Layer aktiv'; } container.innerHTML = html; this._attachListeners(); }, _renderSection(id, title, features, mapFn, term) { var items = features.map(mapFn).filter(function(item) { if (!term) return true; return (item.name + ' ' + item.sub).toLowerCase().indexOf(term) >= 0; }); if (!items.length) return ''; return '' + '' + '▾' + '' + title + '' + '' + items.length + '' + '' + items.slice(0, 100).map(function(item) { return '' + '' + '' + item.name + '' + (item.sub ? '' + item.sub + '' : '') + ''; }).join('') + (items.length > 100 ? '+ ' + (items.length - 100) + ' weitere' : '') + ''; }, _renderEntitySection(id, title, items, term) { if (term) { items = items.filter(function(item) { return item.name.toLowerCase().indexOf(term) >= 0; }); } if (!items.length) return ''; return '' + '' + '▾' + '' + title + '' + '' + items.length + '' + '' + items.slice(0, 100).map(function(item, idx) { return '' + '' + '' + item.name + ''; }).join('') + ''; }, _renderCountSection(id, title, count, color) { return '' + '' + '' + '' + title + '' + '' + count.toLocaleString('de-DE') + ''; }, _toggleSection(id) { var list = document.getElementById('sb-list-' + id); var chev = document.getElementById('sb-chev-' + id); if (list) { var open = list.style.display !== 'none'; list.style.display = open ? 'none' : 'block'; if (chev) chev.style.transform = open ? 'rotate(-90deg)' : ''; } }, _flyTo(lat, lon) { if (typeof Globe !== 'undefined' && Globe.viewer) { Globe.viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(lon, lat, 800000), duration: 1.5, }); } }, _attachListeners() { // Wird nach jedem Update aufgerufen }, };