Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Mobile menu toggle
+ const menuToggle = document.querySelector('.menu-toggle');
+ const navLinks = document.querySelector('.nav-links');
+
+ menuToggle?.addEventListener('click', () => {
+ navLinks.classList.toggle('active');
+
+ // Toggle menu animation
+ const spans = menuToggle.getElementsByTagName('span');
+ Array.from(spans).forEach(span => {
+ span.classList.toggle('active');
+ });
+ });
+
+ // Map initialization
+ const pressureMap = document.getElementById('pressureMap');
+ const zoomIn = document.getElementById('zoomIn');
+ const zoomOut = document.getElementById('zoomOut');
+ const updateInterval = document.getElementById('updateInterval');
+
+ let zoom = 1;
+ let isDragging = false;
+ let startPos = { x: 0, y: 0 };
+ let currentPos = { x: 0, y: 0 };
+
+ // Zoom controls
+ zoomIn?.addEventListener('click', () => {
+ zoom = Math.min(zoom * 1.2, 3);
+ updateMapTransform();
+ });
+
+ zoomOut?.addEventListener('click', () => {
+ zoom = Math.max(zoom / 1.2, 1);
+ updateMapTransform();
+ });
+
+ // Map pan functionality
+ pressureMap?.addEventListener('mousedown', startDragging);
+ pressureMap?.addEventListener('mousemove', drag);
+ pressureMap?.addEventListener('mouseup', stopDragging);
+ pressureMap?.addEventListener('mouseleave', stopDragging);
+
+ // Touch events
+ pressureMap?.addEventListener('touchstart', (e) => {
+ e.preventDefault();
+ startDragging(e.touches[0]);
+ });
+
+ pressureMap?.addEventListener('touchmove', (e) => {
+ e.preventDefault();
+ drag(e.touches[0]);
+ });
+
+ pressureMap?.addEventListener('touchend', stopDragging);
+
+ function startDragging(e) {
+ isDragging = true;
+ startPos = {
+ x: e.clientX - currentPos.x,
+ y: e.clientY - currentPos.y
+ };
+ }
+
+ function drag(e) {
+ if (!isDragging) return;
+
+ currentPos = {
+ x: e.clientX - startPos.x,
+ y: e.clientY - startPos.y
+ };
+
+ updateMapTransform();
+ }
+
+ function stopDragging() {
+ isDragging = false;
+ }
+
+ function updateMapTransform() {
+ if (!pressureMap) return;
+ pressureMap.style.transform = `translate(${currentPos.x}px, ${currentPos.y}px) scale(${zoom})`;
+ }
+
+ // Simulated pressure data update
+ function updatePressureData() {
+ // This would typically fetch real data from an API
+ const loadingOverlay = document.querySelector('.loading-overlay');
+ loadingOverlay.style.display = 'flex';
+
+ setTimeout(() => {
+ loadingOverlay.style.display = 'none';
+ }, 1000);
+ }
+
+ // Initial update
+ updatePressureData();
+
+ // Set up interval for updates
+ updateInterval?.addEventListener('change', (e) => {
+ const interval = parseInt(e.target.value);
+ setUpdateInterval(interval);
+ });
+
+ let updateTimer;
+ function setUpdateInterval(interval) {
+ clearInterval(updateTimer);
+ updateTimer = setInterval(updatePressureData, interval);
+ }
+
+ // Set initial update interval
+ setUpdateInterval(300000); // 5 minutes
+ });