File size: 1,664 Bytes
1bb6c36
d51dbe5
35d793a
 
1aa50e0
 
35d793a
c368f70
 
 
1aa50e0
c368f70
 
 
35d793a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
972e622
35d793a
 
 
 
 
1aa50e0
3221d07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

document.addEventListener('DOMContentLoaded', function() {
    // Initialize feather icons
    if (typeof feather !== 'undefined') {
        feather.replace();
    }
    
    // Smooth page transitions
    document.body.style.opacity = '0';
    setTimeout(() => {
        document.body.style.transition = 'opacity 0.3s ease-in';
        document.body.style.opacity = '1';
    }, 50);

    // Handle all button clicks
    document.addEventListener('click', function(e) {
        if (e.target.closest('button') || e.target.closest('a')) {
            e.preventDefault();
            const href = e.target.closest('a')?.getAttribute('href');
            if (href && href !== '#') {
                window.location.href = href;
            } else {
                alert('This feature is coming soon!');
            }
        }
    });

    // Initialize map on tracking pages
    if (document.getElementById('map') && typeof L !== 'undefined') {
        const map = L.map('map').setView([51.505, -0.09], 13);
        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
        
        const markers = {};
        const devices = [
            { id: 'dev-001', name: 'Device 1', lat: 51.505, lng: -0.09, battery: 85 },
            { id: 'dev-002', name: 'Device 2', lat: 51.51, lng: -0.1, battery: 72 },
            { id: 'dev-003', name: 'Device 3', lat: 51.515, lng: -0.08, battery: 43 }
        ];

        devices.forEach(device => {
            markers[device.id] = L.marker([device.lat, device.lng])
                .addTo(map)
                .bindPopup(`<b>${device.name}</b><br>Battery: ${device.battery}%`);
        });
    }
});