Real-time dashboard for monitoring global news, markets, and geopolitical events
TypeScript
Clean up dead code and unused files
Reggie796f671e091d
diff --git a/js/layers.js b/js/layers.jsdeleted file mode 100644index f9b29c1..0000000--- a/js/layers.js+++ /dev/null@@ -1,261 +0,0 @@-// layers.js - Map layer controls, satellite imagery, flight data--import { SATELLITE_CONFIG, FLIGHT_CACHE_DURATION } from './constants.js';-import { getMapViewMode } from './map.js';--// Map layer visibility state-export const mapLayers = {- hotspots: true,- chokepoints: true,- earthquakes: false,- cyber: false,- conflicts: true,- intel: false,- bases: false,- nuclear: false,- cables: false,- sanctions: false,- flights: false,- satellite: false,- density: false-};--// Flight data cache-let flightDataCache = null;-let flightDataTimestamp = 0;--// Toggle map layer visibility-export function toggleLayer(layerName, refreshCallback) {- mapLayers[layerName] = !mapLayers[layerName];- if (refreshCallback) {- refreshCallback();- }-}--// Toggle satellite layer with special handling-export function toggleSatelliteLayer(refreshCallback) {- mapLayers.satellite = !mapLayers.satellite;-- const canvas = document.getElementById('satelliteCanvas');- const attribution = document.getElementById('satelliteAttribution');- const svg = document.getElementById('worldMapSVG');-- if (mapLayers.satellite) {- // Show loading indicator- const loading = document.getElementById('satelliteLoading');- if (loading) loading.classList.add('visible');-- // Render satellite tiles- renderSatelliteTiles().then(() => {- if (loading) loading.classList.remove('visible');- if (canvas) canvas.classList.add('visible');- if (attribution) attribution.classList.add('visible');- if (svg) svg.style.opacity = '0.7';- });- } else {- if (canvas) canvas.classList.remove('visible');- if (attribution) attribution.classList.remove('visible');- if (svg) svg.style.opacity = '1';- }-- if (refreshCallback) {- refreshCallback();- }-}--// Render satellite tiles to canvas-export async function renderSatelliteTiles() {- const canvas = document.getElementById('satelliteCanvas');- if (!canvas) return;-- const container = document.getElementById('worldMapContainer');- const width = container.offsetWidth || 800;- const height = container.offsetHeight || 550;-- canvas.width = width;- canvas.height = height;-- const ctx = canvas.getContext('2d');-- // Determine tile parameters based on view- const mapViewMode = getMapViewMode();- const isUSView = mapViewMode === 'us';- const isMidEastView = mapViewMode === 'mideast';- const isUkraineView = mapViewMode === 'ukraine';- const isTaiwanView = mapViewMode === 'taiwan';-- let bounds, zoom;-- if (isUSView) {- bounds = { north: 50, south: 24, east: -66, west: -125 };- zoom = 4;- } else if (isMidEastView) {- bounds = { north: 42, south: 12, east: 63, west: 25 };- zoom = 4;- } else if (isUkraineView) {- bounds = { north: 58, south: 42, east: 45, west: 22 };- zoom = 4;- } else if (isTaiwanView) {- bounds = { north: 42, south: 5, east: 145, west: 100 };- zoom = 4;- } else {- bounds = { north: 85, south: -85, east: 180, west: -180 };- zoom = 2;- }-- // Calculate tile range- const tileCount = Math.pow(2, zoom);-- // Convert bounds to tile coordinates- const minTileX = Math.floor((bounds.west + 180) / 360 * tileCount);- const maxTileX = Math.floor((bounds.east + 180) / 360 * tileCount);- const minTileY = Math.floor((1 - Math.log(Math.tan(bounds.north * Math.PI / 180) + 1 / Math.cos(bounds.north * Math.PI / 180)) / Math.PI) / 2 * tileCount);- const maxTileY = Math.floor((1 - Math.log(Math.tan(bounds.south * Math.PI / 180) + 1 / Math.cos(bounds.south * Math.PI / 180)) / Math.PI) / 2 * tileCount);-- // Load and draw tiles- const tilePromises = [];-- for (let x = minTileX; x <= maxTileX; x++) {- for (let y = minTileY; y <= maxTileY; y++) {- const tileX = ((x % tileCount) + tileCount) % tileCount;- const tileY = Math.max(0, Math.min(tileCount - 1, y));-- const url = SATELLITE_CONFIG.esri.url- .replace('{z}', zoom)- .replace('{x}', tileX)- .replace('{y}', tileY);-- const promise = loadTileImage(url).then(img => {- if (!img) return;-- // Calculate tile position on canvas- const tileLonWidth = 360 / tileCount;- const tileLon = x * tileLonWidth - 180;-- // Mercator Y calculation- const n = Math.PI - 2 * Math.PI * tileY / tileCount;- const tileLat = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));-- const n2 = Math.PI - 2 * Math.PI * (tileY + 1) / tileCount;- const tileLat2 = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n2) - Math.exp(-n2)));-- // Convert to canvas coordinates- const canvasX = ((tileLon - bounds.west) / (bounds.east - bounds.west)) * width;- const canvasX2 = ((tileLon + tileLonWidth - bounds.west) / (bounds.east - bounds.west)) * width;- const canvasY = ((bounds.north - tileLat) / (bounds.north - bounds.south)) * height;- const canvasY2 = ((bounds.north - tileLat2) / (bounds.north - bounds.south)) * height;-- const tileWidth = canvasX2 - canvasX;- const tileHeight = canvasY2 - canvasY;-- ctx.drawImage(img, canvasX, canvasY, tileWidth, tileHeight);- }).catch(e => {- console.warn('Tile load failed:', e);- });-- tilePromises.push(promise);- }- }-- await Promise.all(tilePromises);-}--// Load a single tile image-export function loadTileImage(url) {- return new Promise((resolve, reject) => {- const img = new Image();- img.crossOrigin = 'anonymous';- img.onload = () => resolve(img);- img.onerror = () => resolve(null);- img.src = url;-- // Timeout after 10 seconds- setTimeout(() => resolve(null), 10000);- });-}--// Fetch flight data from OpenSky Network API-export async function fetchFlightData(bounds = null) {- const now = Date.now();-- // Return cached data if still valid- if (flightDataCache && (now - flightDataTimestamp) < FLIGHT_CACHE_DURATION) {- return flightDataCache;- }-- try {- let url = 'https://opensky-network.org/api/states/all';-- if (bounds) {- url += `?lamin=${bounds.south}&lomin=${bounds.west}&lamax=${bounds.north}&lomax=${bounds.east}`;- }-- const response = await fetch(url);- if (!response.ok) {- throw new Error(`HTTP ${response.status}`);- }-- const data = await response.json();-- // Parse OpenSky response format- const flights = (data.states || []).slice(0, 500).map(s => ({- icao24: s[0],- callsign: (s[1] || '').trim(),- country: s[2],- lon: s[5],- lat: s[6],- altitude: s[7] || s[13],- onGround: s[8],- velocity: s[9],- heading: s[10],- verticalRate: s[11],- squawk: s[14]- })).filter(f => f.lat && f.lon && !f.onGround);-- flightDataCache = flights;- flightDataTimestamp = now;-- return flights;- } catch (error) {- console.error('Failed to fetch flight data:', error);- return flightDataCache || [];- }-}--// Classify aircraft type based on callsign patterns-export function classifyAircraft(callsign, country) {- const cs = (callsign || '').toUpperCase();-- // Military patterns- if (/^(RCH|JAKE|DUKE|EVAC|AIR|RRR|NAVY|ARMY|USAF|RAF|IAF)/i.test(cs) ||- ['United States', 'Russia', 'China'].includes(country) && /^\d{5,}$/.test(cs)) {- return 'military';- }-- // Cargo/freight patterns- if (/^(FDX|UPS|DHL|GTI|ABX|ATN|CLX)/i.test(cs)) {- return 'cargo';- }-- // Helicopter patterns- if (cs.length <= 4 && /^[A-Z]{1,2}\d{2,3}$/.test(cs)) {- return 'helicopter';- }-- return 'commercial';-}--// Get aircraft direction arrow based on heading-export function getAircraftArrow(heading) {- if (heading === null || heading === undefined) return '✈';- const normalized = ((heading % 360) + 360) % 360;- if (normalized >= 337.5 || normalized < 22.5) return '↑';- if (normalized >= 22.5 && normalized < 67.5) return '↗';- if (normalized >= 67.5 && normalized < 112.5) return '→';- if (normalized >= 112.5 && normalized < 157.5) return '↘';- if (normalized >= 157.5 && normalized < 202.5) return '↓';- if (normalized >= 202.5 && normalized < 247.5) return '↙';- if (normalized >= 247.5 && normalized < 292.5) return '←';- if (normalized >= 292.5 && normalized < 337.5) return '↖';- return '✈';-}diff --git a/js/panels.js b/js/panels.jsindex 7210b84..fe5fc53 100644--- a/js/panels.js+++ b/js/panels.js@@ -30,7 +30,7 @@ export function savePanelSettings(settings) {// Check if panel is enabledexport function isPanelEnabled(panelId) {const settings = getPanelSettings();- return settings[panelId] !== false; // Default to enabled+ return settings[panelId] !== false;}// Toggle panel visibility@@ -40,9 +40,7 @@ export function togglePanel(panelId, refreshCallback) {savePanelSettings(settings);applyPanelSettings();updateSettingsUI();- if (refreshCallback) {- refreshCallback();- }+ if (refreshCallback) refreshCallback();}// Apply panel settings to DOM@@ -60,18 +58,11 @@ export function applyPanelSettings() {// Toggle settings modalexport function toggleSettings(renderMonitorsList) {const modal = document.getElementById('settingsModal');+ if (!modal) return;modal.classList.toggle('open');if (modal.classList.contains('open')) {updateSettingsUI();- if (renderMonitorsList) {- renderMonitorsList();- }- // Load saved livestream URL- const savedUrl = localStorage.getItem('livestreamUrl') || 'https://www.youtube.com/watch?v=jWEZa9WEnIo';- const urlInput = document.getElementById('livestreamUrl');- if (urlInput) {- urlInput.value = savedUrl;- }+ if (renderMonitorsList) renderMonitorsList();}}@@ -91,110 +82,45 @@ export function updateSettingsUI() {}).join('');}-// Extract YouTube video ID from various URL formats-export function extractYouTubeId(url) {- if (!url) return null;- const patterns = [- /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/|youtube\.com\/live\/)([^&\?\/]+)/,- /^([a-zA-Z0-9_-]{11})$/- ];- for (const pattern of patterns) {- const match = url.match(pattern);- if (match) return match[1];- }- return null;-}--// Save livestream URL-export function saveLivestreamUrl() {- const input = document.getElementById('livestreamUrl');- const url = input.value.trim();- localStorage.setItem('livestreamUrl', url);- updateLivestreamEmbed();-}--// Update the livestream embed-export function updateLivestreamEmbed() {- const url = localStorage.getItem('livestreamUrl') || 'https://www.youtube.com/watch?v=jWEZa9WEnIo';- const videoId = extractYouTubeId(url);- const panel = document.getElementById('tbpnPanel');- if (panel && videoId) {- panel.innerHTML = `- <iframe- src="https://www.youtube.com/embed/${videoId}?autoplay=0&mute=1"- frameborder="0"- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"- allowfullscreen>- </iframe>- `;- } else if (panel) {- panel.innerHTML = '<div class="loading-msg">Invalid YouTube URL</div>';- }-}--// Get current livestream embed URL-export function getLivestreamEmbedUrl() {- const url = localStorage.getItem('livestreamUrl') || 'https://www.youtube.com/watch?v=jWEZa9WEnIo';- const videoId = extractYouTubeId(url);- return videoId ? `https://www.youtube.com/embed/${videoId}?autoplay=0&mute=1` : '';-}-// Initialize drag and drop-export function initDragAndDrop() {+function initDragAndDrop() {const dashboard = document.querySelector('.dashboard');if (!dashboard) return;- const panels = dashboard.querySelectorAll('.panel');-- panels.forEach(panel => {+ dashboard.querySelectorAll('.panel').forEach(panel => {const panelId = panel.dataset.panel;const isDraggable = !NON_DRAGGABLE_PANELS.includes(panelId);-panel.setAttribute('draggable', isDraggable ? 'true' : 'false');- if (!isDraggable) {- panel.style.cursor = 'default';- const header = panel.querySelector('.panel-header');- if (header) header.style.cursor = 'default';- return;- }+ if (!isDraggable) return;panel.addEventListener('dragstart', (e) => {draggedPanel = panel;panel.classList.add('dragging');e.dataTransfer.effectAllowed = 'move';- e.dataTransfer.setData('text/plain', panel.dataset.panel);});panel.addEventListener('dragend', () => {panel.classList.remove('dragging');- document.querySelectorAll('.panel.drag-over').forEach(p => p.classList.remove('drag-over'));+ document.querySelectorAll('.drag-over').forEach(p => p.classList.remove('drag-over'));draggedPanel = null;savePanelOrder();});panel.addEventListener('dragover', (e) => {e.preventDefault();- e.dataTransfer.dropEffect = 'move';- if (draggedPanel && draggedPanel !== panel) {- panel.classList.add('drag-over');- }+ if (draggedPanel && draggedPanel !== panel) panel.classList.add('drag-over');});- panel.addEventListener('dragleave', () => {- panel.classList.remove('drag-over');- });+ panel.addEventListener('dragleave', () => panel.classList.remove('drag-over'));panel.addEventListener('drop', (e) => {e.preventDefault();panel.classList.remove('drag-over');-if (draggedPanel && draggedPanel !== panel) {- const dashboard = document.querySelector('.dashboard');const panels = [...dashboard.querySelectorAll('.panel')];const draggedIdx = panels.indexOf(draggedPanel);const targetIdx = panels.indexOf(panel);-if (draggedIdx < targetIdx) {panel.parentNode.insertBefore(draggedPanel, panel.nextSibling);} else {@@ -205,170 +131,99 @@ export function initDragAndDrop() {});}-// Save panel order to localStorage-export function savePanelOrder() {+// Save/restore panel order+function savePanelOrder() {const dashboard = document.querySelector('.dashboard');if (!dashboard) return;-- const panels = dashboard.querySelectorAll('.panel');- const order = [...panels].map(p => p.dataset.panel);+ const order = [...dashboard.querySelectorAll('.panel')].map(p => p.dataset.panel);localStorage.setItem('panelOrder', JSON.stringify(order));}-// Restore panel order from localStorage-export function restorePanelOrder() {- const savedOrder = localStorage.getItem('panelOrder');- if (!savedOrder) return;-+function restorePanelOrder() {+ const saved = localStorage.getItem('panelOrder');+ if (!saved) return;try {- const order = JSON.parse(savedOrder);+ const order = JSON.parse(saved);const dashboard = document.querySelector('.dashboard');if (!dashboard) return;-const panels = [...dashboard.querySelectorAll('.panel')];-order.forEach(panelId => {if (NON_DRAGGABLE_PANELS.includes(panelId)) return;const panel = panels.find(p => p.dataset.panel === panelId);- if (panel) {- dashboard.appendChild(panel);- }+ if (panel) dashboard.appendChild(panel);});- } catch (e) {- console.error('Error restoring panel order:', e);- }+ } catch (e) {}}-// Reset panel orderexport function resetPanelOrder() {localStorage.removeItem('panelOrder');location.reload();}-// Initialize panel resize-export function initPanelResize() {+// Panel resize+function initPanelResize() {document.querySelectorAll('.panel').forEach(panel => {if (panel.querySelector('.panel-resize-handle')) return;- // Corner handle- const cornerHandle = document.createElement('div');- cornerHandle.className = 'panel-resize-handle corner';- cornerHandle.addEventListener('mousedown', (e) => startResize(e, panel, 'corner'));- panel.appendChild(cornerHandle);-- // Bottom edge handle- const bottomHandle = document.createElement('div');- bottomHandle.className = 'panel-resize-handle bottom';- bottomHandle.addEventListener('mousedown', (e) => startResize(e, panel, 'bottom'));- panel.appendChild(bottomHandle);-- // Right edge handle- const rightHandle = document.createElement('div');- rightHandle.className = 'panel-resize-handle right';- rightHandle.addEventListener('mousedown', (e) => startResize(e, panel, 'right'));- panel.appendChild(rightHandle);+ const handle = document.createElement('div');+ handle.className = 'panel-resize-handle corner';+ handle.addEventListener('mousedown', (e) => {+ e.preventDefault();+ resizingPanel = panel;+ resizeStart = { x: e.clientX, y: e.clientY, width: panel.offsetWidth, height: panel.offsetHeight };+ panel.classList.add('resizing');+ });+ panel.appendChild(handle);});- // Global mouse events for resize- document.addEventListener('mousemove', handleResizeMove);- document.addEventListener('mouseup', handleResizeEnd);-}--function startResize(e, panel, direction) {- e.preventDefault();- e.stopPropagation();-- resizingPanel = panel;- resizeDirection = direction;- resizeStart = {- x: e.clientX,- y: e.clientY,- width: panel.offsetWidth,- height: panel.offsetHeight- };-- panel.classList.add('resizing');- document.body.style.cursor = direction === 'corner' ? 'nwse-resize' :- direction === 'bottom' ? 'ns-resize' : 'ew-resize';-}--function handleResizeMove(e) {- if (!resizingPanel) return;-- const deltaX = e.clientX - resizeStart.x;- const deltaY = e.clientY - resizeStart.y;-- if (resizeDirection === 'corner' || resizeDirection === 'right') {- const newWidth = Math.max(200, resizeStart.width + deltaX);+ document.addEventListener('mousemove', (e) => {+ if (!resizingPanel) return;+ const newWidth = Math.max(200, resizeStart.width + (e.clientX - resizeStart.x));+ const newHeight = Math.max(150, resizeStart.height + (e.clientY - resizeStart.y));resizingPanel.style.width = newWidth + 'px';- resizingPanel.style.minWidth = newWidth + 'px';- resizingPanel.style.maxWidth = newWidth + 'px';- }-- if (resizeDirection === 'corner' || resizeDirection === 'bottom') {- const newHeight = Math.max(150, resizeStart.height + deltaY);resizingPanel.style.minHeight = newHeight + 'px';- resizingPanel.style.maxHeight = newHeight + 'px';- }-}+ });-function handleResizeEnd() {- if (resizingPanel) {- resizingPanel.classList.remove('resizing');- savePanelSizes();- resizingPanel = null;- resizeDirection = null;- document.body.style.cursor = '';- }+ document.addEventListener('mouseup', () => {+ if (resizingPanel) {+ resizingPanel.classList.remove('resizing');+ savePanelSizes();+ resizingPanel = null;+ }+ });}-// Save panel sizes to localStorage-export function savePanelSizes() {+function savePanelSizes() {const sizes = {};document.querySelectorAll('.panel').forEach(panel => {- const panelName = panel.getAttribute('data-panel');- if (panelName && (panel.style.minHeight || panel.style.width)) {- sizes[panelName] = {- height: panel.style.minHeight,- width: panel.style.width- };+ const name = panel.dataset.panel;+ if (name && (panel.style.minHeight || panel.style.width)) {+ sizes[name] = { height: panel.style.minHeight, width: panel.style.width };}});localStorage.setItem('panelSizes', JSON.stringify(sizes));}-// Restore panel sizes from localStorage-export function restorePanelSizes() {+function restorePanelSizes() {const saved = localStorage.getItem('panelSizes');if (!saved) return;-try {const sizes = JSON.parse(saved);- Object.entries(sizes).forEach(([panelName, dims]) => {- const panel = document.querySelector(`.panel[data-panel="${panelName}"]`);+ Object.entries(sizes).forEach(([name, dims]) => {+ const panel = document.querySelector(`.panel[data-panel="${name}"]`);if (panel) {- if (dims.height) {- panel.style.minHeight = dims.height;- panel.style.maxHeight = dims.height;- }- if (dims.width) {- panel.style.width = dims.width;- panel.style.minWidth = dims.width;- panel.style.maxWidth = dims.width;- }+ if (dims.height) panel.style.minHeight = dims.height;+ if (dims.width) panel.style.width = dims.width;}});- } catch (e) {- console.error('Failed to restore panel sizes:', e);- }+ } catch (e) {}}// Initialize all panel functionality-export function initPanels(renderMonitorsList) {+export function initPanels() {applyPanelSettings();restorePanelOrder();restorePanelSizes();- updateLivestreamEmbed();initDragAndDrop();initPanelResize();}diff --git a/js/popups.js b/js/popups.jsdeleted file mode 100644index 83283b7..0000000--- a/js/popups.js+++ /dev/null@@ -1,590 +0,0 @@-// popups.js - All popup show/hide functions--import { escapeHtml, getTimeAgo } from './utils.js';--// Helper function to position popup within map bounds-function positionPopup(popup, targetEl, popupWidth, popupHeight) {- const mapContainer = document.getElementById('worldMapContainer');- if (!mapContainer) return;-- const mapRect = mapContainer.getBoundingClientRect();- const targetRect = targetEl.getBoundingClientRect();-- let left = targetRect.left - mapRect.left + 20;- let top = targetRect.top - mapRect.top - 10;-- if (left + popupWidth > mapRect.width) {- left = targetRect.left - mapRect.left - popupWidth - 20;- }- if (top + popupHeight > mapRect.height) {- top = mapRect.height - popupHeight - 10;- }- if (top < 10) top = 10;- if (left < 10) left = 10;-- popup.style.left = left + 'px';- popup.style.top = top + 'px';-}--// Hide hotspot popup-export function hideHotspotPopup() {- const popup = document.getElementById('hotspotPopup');- if (popup) popup.classList.remove('visible');-}--// Hide conflict popup-export function hideConflictPopup() {- const popup = document.getElementById('conflictPopup');- if (popup) popup.classList.remove('visible');-}--// Hide US city popup-export function hideUSCityPopup() {- const popup = document.getElementById('usCityPopup');- if (popup) popup.classList.remove('visible');-}--// Hide US hotspot popup-export function hideUSHotspotPopup() {- const popup = document.getElementById('usHotspotPopup');- if (popup) popup.classList.remove('visible');-}--// Hide chokepoint popup-export function hideChokepointPopup() {- const popup = document.getElementById('chokepointPopup');- if (popup) popup.classList.remove('visible');-}--// Hide earthquake popup-export function hideQuakePopup() {- const popup = document.getElementById('quakePopup');- if (popup) popup.classList.remove('visible');-}--// Hide cyber popup-export function hideCyberPopup() {- const popup = document.getElementById('cyberPopup');- if (popup) popup.classList.remove('visible');-}--// Hide custom hotspot popup-export function hideCustomHotspotPopup() {- const popup = document.getElementById('customHotspotPopup');- if (popup) popup.classList.remove('visible');-}--// Hide aircraft popup-export function hideAircraftPopup() {- const popup = document.getElementById('aircraftPopup');- if (popup) popup.classList.remove('visible');-}--// Hide all popups-export function hideAllPopups() {- hideHotspotPopup();- hideChokepointPopup();- hideQuakePopup();- hideCyberPopup();- hideCustomHotspotPopup();- hideConflictPopup();- hideUSCityPopup();- hideUSHotspotPopup();- hideAircraftPopup();-}--// Show hotspot popup-export function showHotspotPopup(event, hotspotId) {- event.stopPropagation();-- const hotspotEl = document.querySelector(`[data-hotspot-id="${hotspotId}"]`);- if (!hotspotEl) return;-- hideChokepointPopup();- hideQuakePopup();- hideCyberPopup();- hideCustomHotspotPopup();- hideUSCityPopup();- hideUSHotspotPopup();-- const activityData = JSON.parse(decodeURIComponent(hotspotEl.dataset.hotspotActivity));- const popup = document.getElementById('hotspotPopup');-- let headlinesHTML = '';- if (activityData.headlines && activityData.headlines.length > 0) {- headlinesHTML = activityData.headlines.map(h => `- <div class="hotspot-popup-headline">- <div class="hotspot-popup-source">${escapeHtml(h.source || 'News')}</div>- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('');- } else {- headlinesHTML = '<div class="hotspot-popup-empty">No recent headlines for this location</div>';- }-- let agenciesHTML = '';- if (activityData.agencies && activityData.agencies.length > 0) {- agenciesHTML = `- <div class="hotspot-popup-agencies">- <div class="hotspot-popup-agencies-title">Key Entities</div>- ${activityData.agencies.map(a => `<span class="hotspot-popup-agency">${escapeHtml(a)}</span>`).join('')}- </div>- `;- }-- popup.innerHTML = `- <button class="hotspot-popup-close" onclick="hideHotspotPopup()">×</button>- <div class="hotspot-popup-header">- <span class="hotspot-popup-title">${escapeHtml(activityData.name)}</span>- <span class="hotspot-popup-level ${activityData.level}">${activityData.level.toUpperCase()}</span>- </div>- <div class="hotspot-popup-subtext">${escapeHtml(activityData.subtext)}</div>- ${activityData.description ? `<div class="hotspot-popup-desc">${escapeHtml(activityData.description)}</div>` : ''}- <div class="hotspot-popup-meta">- <div class="hotspot-popup-meta-item">- <span class="hotspot-popup-meta-label">Coordinates</span>- <span class="hotspot-popup-meta-value">${activityData.lat.toFixed(2)}°${activityData.lat >= 0 ? 'N' : 'S'}, ${Math.abs(activityData.lon).toFixed(2)}°${activityData.lon >= 0 ? 'E' : 'W'}</span>- </div>- ${activityData.status ? `- <div class="hotspot-popup-meta-item">- <span class="hotspot-popup-meta-label">Status</span>- <span class="hotspot-popup-meta-value">${escapeHtml(activityData.status)}</span>- </div>- ` : ''}- </div>- ${agenciesHTML}- ${headlinesHTML.includes('hotspot-popup-headline') ? '<div class="hotspot-popup-headlines-title">Related Headlines</div>' : ''}- <div class="hotspot-popup-headlines">- ${headlinesHTML}- </div>- `;-- popup.className = `hotspot-popup visible ${activityData.level}`;- positionPopup(popup, hotspotEl, 320, 400);-}--// Show conflict popup-export function showConflictPopup(event, conflictId) {- event.stopPropagation();-- const conflictEl = document.querySelector(`[data-conflict-id="${conflictId}"]`);- if (!conflictEl) return;-- hideAllPopups();-- const conflictData = JSON.parse(decodeURIComponent(conflictEl.dataset.conflictInfo));- const popup = document.getElementById('conflictPopup');-- let matchedHeadlines = [];- if (window.cachedAllNews && conflictData.keywords) {- matchedHeadlines = window.cachedAllNews.filter(item => {- const title = (item.title || '').toLowerCase();- return conflictData.keywords.some(kw => title.includes(kw.toLowerCase()));- }).slice(0, 5);- }-- let headlinesHTML = '';- if (matchedHeadlines.length > 0) {- headlinesHTML = `- <div class="conflict-popup-headlines-title">Related Headlines</div>- <div class="conflict-popup-headlines">- ${matchedHeadlines.map(h => `- <div class="conflict-popup-headline">- <div class="conflict-popup-headline-source">${escapeHtml(h.source || 'News')}</div>- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('')}- </div>- `;- }-- popup.innerHTML = `- <button class="conflict-popup-close" onclick="hideConflictPopup()">×</button>- <div class="conflict-popup-header">- <span class="conflict-popup-title">${escapeHtml(conflictData.name)}</span>- <span class="conflict-popup-intensity ${conflictData.intensity}">${conflictData.intensity.toUpperCase()}</span>- </div>- <div class="conflict-popup-meta">- <div class="conflict-popup-meta-item">- <span class="conflict-popup-meta-label">Start Date</span>- <span class="conflict-popup-meta-value">${escapeHtml(conflictData.startDate)}</span>- </div>- <div class="conflict-popup-meta-item">- <span class="conflict-popup-meta-label">Casualties</span>- <span class="conflict-popup-meta-value">${escapeHtml(conflictData.casualties)}</span>- </div>- <div class="conflict-popup-meta-item">- <span class="conflict-popup-meta-label">Displaced</span>- <span class="conflict-popup-meta-value">${escapeHtml(conflictData.displaced)}</span>- </div>- </div>- <div class="conflict-popup-desc">${escapeHtml(conflictData.description)}</div>- <div class="conflict-popup-parties">- <div class="conflict-popup-parties-title">Belligerents</div>- ${conflictData.parties.map(p => `<span class="conflict-popup-party">${escapeHtml(p)}</span>`).join('')}- </div>- <div class="conflict-popup-events">- <div class="conflict-popup-events-title">Key Developments</div>- ${conflictData.keyEvents.map(e => `<div class="conflict-popup-event">${escapeHtml(e)}</div>`).join('')}- </div>- ${headlinesHTML}- `;-- popup.classList.add('visible');- positionPopup(popup, conflictEl, 380, 450);-}--// Show US city popup-export function showUSCityPopup(event, cityId) {- event.stopPropagation();-- const cityEl = document.querySelector(`[data-city-id="${cityId}"]`);- if (!cityEl) return;-- hideAllPopups();-- const cityData = JSON.parse(decodeURIComponent(cityEl.dataset.cityInfo));- const popup = document.getElementById('usCityPopup');-- let headlinesHTML = '';- if (cityData.headlines && cityData.headlines.length > 0) {- headlinesHTML = cityData.headlines.map(h => `- <div class="us-city-popup-headline">- <div class="us-city-popup-headline-source">${escapeHtml(h.source || 'News')}</div>- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('');- } else {- headlinesHTML = '<div style="padding: 1rem; color: #336688; font-size: 0.6rem; text-align: center;">No recent headlines for this city</div>';- }-- const sectorsHTML = cityData.sectors ? cityData.sectors.map(s =>- `<span style="display: inline-block; font-size: 0.5rem; padding: 0.1rem 0.3rem; margin: 0.1rem; background: rgba(0, 170, 255, 0.1); border: 1px solid rgba(0, 170, 255, 0.2); color: #66aacc;">${escapeHtml(s)}</span>`- ).join('') : '';-- popup.innerHTML = `- <button class="us-city-popup-close" onclick="hideUSCityPopup()">×</button>- <div class="us-city-popup-header">- <span class="us-city-popup-title">${escapeHtml(cityData.name)}</span>- <span class="us-city-popup-state">${escapeHtml(cityData.state)}</span>- </div>- <div class="us-city-popup-meta">- <div>- <span class="us-city-popup-meta-label">Population</span>- <span class="us-city-popup-meta-value">${escapeHtml(cityData.population)}</span>- </div>- <div>- <span class="us-city-popup-meta-label">News Matches</span>- <span class="us-city-popup-meta-value">${cityData.matchCount || 0}</span>- </div>- </div>- <div class="us-city-popup-desc">${escapeHtml(cityData.description)}</div>- ${sectorsHTML ? `<div style="padding: 0.5rem 1rem; border-bottom: 1px solid rgba(0, 100, 170, 0.2);"><div style="font-size: 0.45rem; color: #336688; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.3rem;">Key Sectors</div>${sectorsHTML}</div>` : ''}- <div class="us-city-popup-headlines-title">Related Headlines</div>- <div class="us-city-popup-headlines">- ${headlinesHTML}- </div>- `;-- popup.classList.add('visible');- positionPopup(popup, cityEl, 360, 420);-}--// Show US hotspot popup-export function showUSHotspotPopup(event, hotspotId) {- event.stopPropagation();-- const hotspotEl = document.querySelector(`[data-us-hotspot-id="${hotspotId}"]`);- if (!hotspotEl) return;-- hideAllPopups();-- const hotspotData = JSON.parse(decodeURIComponent(hotspotEl.dataset.usHotspotInfo));- const popup = document.getElementById('usHotspotPopup');-- let headlinesHTML = '';- if (hotspotData.headlines && hotspotData.headlines.length > 0) {- headlinesHTML = hotspotData.headlines.map(h => `- <div class="us-hotspot-popup-headline">- <div class="us-hotspot-popup-headline-source">${escapeHtml(h.source || 'News')}</div>- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('');- } else {- headlinesHTML = '<div class="us-hotspot-popup-headline" style="color: #666;">No matching headlines found</div>';- }-- popup.className = `us-hotspot-popup ${hotspotData.level}`;- popup.innerHTML = `- <button class="us-hotspot-popup-close" onclick="hideUSHotspotPopup()">×</button>- <div class="us-hotspot-popup-header">- <span class="us-hotspot-popup-title">${hotspotData.icon} ${escapeHtml(hotspotData.name)}</span>- <span class="us-hotspot-popup-level ${hotspotData.level}">${hotspotData.level.toUpperCase()}</span>- </div>- <div class="us-hotspot-popup-meta">- <div>- <span class="us-hotspot-popup-meta-label">Location</span>- <span class="us-hotspot-popup-meta-value">${escapeHtml(hotspotData.location)}</span>- </div>- <div>- <span class="us-hotspot-popup-meta-label">Category</span>- <span class="us-hotspot-popup-meta-value">${escapeHtml(hotspotData.category)}</span>- </div>- <div>- <span class="us-hotspot-popup-meta-label">Since</span>- <span class="us-hotspot-popup-meta-value">${escapeHtml(hotspotData.startDate)}</span>- </div>- <div>- <span class="us-hotspot-popup-meta-label">Status</span>- <span class="us-hotspot-popup-meta-value">${escapeHtml(hotspotData.status)}</span>- </div>- </div>- <div class="us-hotspot-popup-desc">${escapeHtml(hotspotData.description)}</div>- <div class="us-hotspot-popup-headlines-title">Related Headlines (${hotspotData.matchCount || 0})</div>- <div class="us-hotspot-popup-headlines">- ${headlinesHTML}- </div>- `;-- popup.classList.add('visible');- positionPopup(popup, hotspotEl, 320, 400);-}--// Show chokepoint popup-export function showChokepointPopup(event, chokepointId) {- event.stopPropagation();-- const cpEl = document.querySelector(`[data-chokepoint-id="${chokepointId}"]`);- if (!cpEl) return;-- hideAllPopups();-- const cpData = JSON.parse(decodeURIComponent(cpEl.dataset.chokepointInfo));- const popup = document.getElementById('chokepointPopup');-- let headlinesHTML = '';- if (cpData.headlines && cpData.headlines.length > 0) {- headlinesHTML = cpData.headlines.map(h => `- <div class="chokepoint-popup-headline">- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('');- } else {- headlinesHTML = '<div class="chokepoint-popup-empty">No recent headlines for this chokepoint</div>';- }-- popup.innerHTML = `- <button class="chokepoint-popup-close" onclick="hideChokepointPopup()">×</button>- <div class="chokepoint-popup-header">- <span class="chokepoint-popup-title">${escapeHtml(cpData.name)}</span>- <span class="chokepoint-popup-status ${cpData.isAlert ? 'alert' : 'normal'}">${cpData.isAlert ? 'ALERT' : 'NORMAL'}</span>- </div>- <div class="chokepoint-popup-info">- <div class="chokepoint-popup-stat">- <span class="chokepoint-popup-stat-label">Region</span>- <span class="chokepoint-popup-stat-value">${escapeHtml(cpData.region)}</span>- </div>- <div class="chokepoint-popup-stat">- <span class="chokepoint-popup-stat-label">Traffic</span>- <span class="chokepoint-popup-stat-value">${escapeHtml(cpData.traffic)}</span>- </div>- </div>- <div class="chokepoint-popup-desc">${escapeHtml(cpData.desc)}</div>- <div class="chokepoint-popup-headlines">- ${headlinesHTML}- </div>- `;-- popup.className = `chokepoint-popup visible ${cpData.isAlert ? 'alert' : ''}`;- positionPopup(popup, cpEl, 280, 300);-}--// Show earthquake popup-export function showQuakePopup(event, quakeId) {- event.stopPropagation();-- const quakeEl = document.querySelector(`[data-quake-id="${quakeId}"]`);- if (!quakeEl) return;-- hideAllPopups();-- const eqData = JSON.parse(decodeURIComponent(quakeEl.dataset.quakeInfo));- const popup = document.getElementById('quakePopup');-- const isMajor = eqData.mag >= 6.0;- const isModerate = eqData.mag >= 5.0;-- let severity = 'minor';- let severityLabel = 'Minor';- if (isMajor) {- severity = 'major';- severityLabel = 'Major';- } else if (isModerate) {- severity = 'moderate';- severityLabel = 'Moderate';- }-- const time = new Date(eqData.time);- const timeAgoStr = getTimeAgo(time);- const usgsLink = `https://earthquake.usgs.gov/earthquakes/eventpage/${eqData.id || ''}`;-- popup.innerHTML = `- <button class="quake-popup-close" onclick="hideQuakePopup()">×</button>- <div class="quake-popup-header">- <span class="quake-popup-mag">M${eqData.mag.toFixed(1)}</span>- <span class="quake-popup-severity ${severity}">${severityLabel}</span>- </div>- <div class="quake-popup-location">${escapeHtml(eqData.place)}</div>- <div class="quake-popup-info">- <div class="quake-popup-stat">- <span class="quake-popup-stat-label">Depth</span>- <span class="quake-popup-stat-value">${eqData.depth.toFixed(1)} km</span>- </div>- <div class="quake-popup-stat">- <span class="quake-popup-stat-label">Coordinates</span>- <span class="quake-popup-stat-value">${eqData.lat.toFixed(2)}°, ${eqData.lon.toFixed(2)}°</span>- </div>- <div class="quake-popup-stat">- <span class="quake-popup-stat-label">Time</span>- <span class="quake-popup-stat-value">${timeAgoStr}</span>- </div>- </div>- <a href="${usgsLink}" target="_blank" class="quake-popup-link">View on USGS →</a>- `;-- popup.className = `quake-popup visible ${isMajor ? 'major' : ''}`;- positionPopup(popup, quakeEl, 260, 220);-}--// Show cyber threat popup-export function showCyberPopup(event, cyberId) {- event.stopPropagation();-- const cyberEl = document.querySelector(`[data-cyber-id="${cyberId}"]`);- if (!cyberEl) return;-- hideAllPopups();-- const czData = JSON.parse(decodeURIComponent(cyberEl.dataset.cyberInfo));- const popup = document.getElementById('cyberPopup');-- const targetsHTML = czData.targets.map(t =>- `<span class="cyber-popup-target-tag">${escapeHtml(t)}</span>`- ).join('');-- popup.innerHTML = `- <button class="cyber-popup-close" onclick="hideCyberPopup()">×</button>- <div class="cyber-popup-header">- <span class="cyber-popup-title">${escapeHtml(czData.fullName)}</span>- <span class="cyber-popup-status ${czData.isActive ? 'active' : 'dormant'}">${czData.isActive ? 'Active' : 'Dormant'}</span>- </div>- <div class="cyber-popup-apt">${escapeHtml(czData.group)} — ${escapeHtml(czData.aka)}</div>- <div class="cyber-popup-desc">${escapeHtml(czData.desc)}</div>- <div class="cyber-popup-info">- <div class="cyber-popup-stat">- <span class="cyber-popup-stat-label">State Sponsor</span>- <span class="cyber-popup-stat-value">${escapeHtml(czData.sponsor)}</span>- </div>- <div class="cyber-popup-stat">- <span class="cyber-popup-stat-label">Coordinates</span>- <span class="cyber-popup-stat-value">${czData.lat.toFixed(1)}°, ${czData.lon.toFixed(1)}°</span>- </div>- </div>- <div class="cyber-popup-targets">- <div class="cyber-popup-targets-label">Primary Targets</div>- <div class="cyber-popup-target-tags">${targetsHTML}</div>- </div>- `;-- popup.className = `cyber-popup visible ${czData.isActive ? 'active' : ''}`;- positionPopup(popup, cyberEl, 280, 300);-}--// Show custom hotspot popup-export function showCustomHotspotPopup(event, monitorId) {- event.stopPropagation();-- const hotspotEl = document.querySelector(`[data-monitor-id="${monitorId}"]`);- if (!hotspotEl) return;-- hideAllPopups();-- const monitorData = JSON.parse(decodeURIComponent(hotspotEl.dataset.monitorInfo));- const popup = document.getElementById('customHotspotPopup');-- let headlinesHTML = '';- if (monitorData.matches && monitorData.matches.length > 0) {- headlinesHTML = monitorData.matches.map(h => `- <div class="custom-hotspot-popup-headline">- <div class="custom-hotspot-popup-headline-source">${escapeHtml(h.source || 'News')}</div>- <a href="${h.link || '#'}" target="_blank">${escapeHtml(h.title)}</a>- </div>- `).join('');- } else {- headlinesHTML = '<div style="padding: 1rem; color: #888; font-size: 0.6rem; text-align: center;">No matching headlines</div>';- }-- popup.style.borderColor = monitorData.color || '#00ff88';- popup.innerHTML = `- <button class="custom-hotspot-popup-close" onclick="hideCustomHotspotPopup()">×</button>- <div class="custom-hotspot-popup-header" style="border-bottom-color: ${monitorData.color || '#00ff88'};">- <span class="custom-hotspot-popup-title" style="color: ${monitorData.color || '#00ff88'};">${escapeHtml(monitorData.name)}</span>- <span class="custom-hotspot-popup-count">${monitorData.matchCount || 0} matches</span>- </div>- <div class="custom-hotspot-popup-keywords">- ${monitorData.keywords.map(k => `<span class="custom-hotspot-popup-keyword">${escapeHtml(k)}</span>`).join('')}- </div>- <div class="custom-hotspot-popup-headlines">- ${headlinesHTML}- </div>- `;-- popup.classList.add('visible');- positionPopup(popup, hotspotEl, 300, 350);-}--// Show aircraft popup-export function showAircraftPopup(event, flightData) {- event.stopPropagation();-- hideAllPopups();-- const popup = document.getElementById('aircraftPopup');- if (!popup) return;-- popup.innerHTML = `- <button class="aircraft-popup-close" onclick="hideAircraftPopup()">×</button>- <div class="aircraft-popup-header">- <span class="aircraft-popup-callsign">${escapeHtml(flightData.callsign || 'Unknown')}</span>- <span class="aircraft-popup-country">${escapeHtml(flightData.country || '')}</span>- </div>- <div class="aircraft-popup-info">- <div class="aircraft-popup-stat">- <span class="aircraft-popup-stat-label">Altitude</span>- <span class="aircraft-popup-stat-value">${flightData.altitude ? Math.round(flightData.altitude * 3.281) + ' ft' : 'N/A'}</span>- </div>- <div class="aircraft-popup-stat">- <span class="aircraft-popup-stat-label">Speed</span>- <span class="aircraft-popup-stat-value">${flightData.velocity ? Math.round(flightData.velocity * 1.944) + ' kts' : 'N/A'}</span>- </div>- <div class="aircraft-popup-stat">- <span class="aircraft-popup-stat-label">Heading</span>- <span class="aircraft-popup-stat-value">${flightData.heading ? Math.round(flightData.heading) + '°' : 'N/A'}</span>- </div>- <div class="aircraft-popup-stat">- <span class="aircraft-popup-stat-label">ICAO</span>- <span class="aircraft-popup-stat-value">${escapeHtml(flightData.icao24 || 'Unknown')}</span>- </div>- </div>- `;-- popup.classList.add('visible');-- // Position at cursor- const mapContainer = document.getElementById('worldMapContainer');- if (mapContainer) {- const mapRect = mapContainer.getBoundingClientRect();- popup.style.left = (event.clientX - mapRect.left + 10) + 'px';- popup.style.top = (event.clientY - mapRect.top + 10) + 'px';- }-}