T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/.cursor-server/data/User/History/6b963d87/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/.cursor-server/data/User/History/6b963d87/iPNc.js
/**
 * Fresh Interactive Map - Clean Start
 */

(function() {
    'use strict';

    const BOUNDS = {
        minLat: 45.0,
        maxLat: 51.0,
        minLng: -80.0,
        maxLng: -66.0
    };

    let map = {
        canvas: null,
        ctx: null,
        container: null,
        cities: [],
        villages: [],
        zoom: 1.2,
        panX: 0,
        panY: 0,
        dragging: false,
        dragStart: { x: 0, y: 0 }
    };

    function init() {
        map.container = document.getElementById('homepageInteractiveMap');
        map.canvas = document.getElementById('homepageMapCanvas');
        if (!map.container || !map.canvas) {
            console.log('Map: Container or canvas not found');
            return;
        }

        map.ctx = map.canvas.getContext('2d');
        if (!map.ctx) {
            console.log('Map: Could not get canvas context');
            return;
        }

        setupCanvas();
        setupControls();
        loadCities();
        loadVillages();
        // Don't call draw() here - wait for data to load
    }

    function setupCanvas() {
        const rect = map.container.getBoundingClientRect();
        map.canvas.width = rect.width;
        map.canvas.height = rect.height;
        map.panX = map.canvas.width / 2;
        map.panY = map.canvas.height / 2;

        map.canvas.addEventListener('mousedown', (e) => {
            map.dragging = true;
            const rect = map.canvas.getBoundingClientRect();
            map.dragStart.x = e.clientX - rect.left;
            map.dragStart.y = e.clientY - rect.top;
        });

        map.canvas.addEventListener('mousemove', (e) => {
            if (map.dragging) {
                const rect = map.canvas.getBoundingClientRect();
                const x = e.clientX - rect.left;
                const y = e.clientY - rect.top;
                map.panX += x - map.dragStart.x;
                map.panY += y - map.dragStart.y;
                map.dragStart.x = x;
                map.dragStart.y = y;
                draw();
            }
        });

        map.canvas.addEventListener('mouseup', () => {
            map.dragging = false;
        });

        map.canvas.addEventListener('wheel', (e) => {
            e.preventDefault();
            const rect = map.canvas.getBoundingClientRect();
            const x = e.clientX - rect.left;
            const y = e.clientY - rect.top;
            const oldZoom = map.zoom;
            map.zoom *= e.deltaY > 0 ? 0.9 : 1.1;
            map.zoom = Math.max(0.5, Math.min(5, map.zoom));
            const zoomChange = map.zoom / oldZoom;
            map.panX = x - (x - map.panX) * zoomChange;
            map.panY = y - (y - map.panY) * zoomChange;
            draw();
        });

        window.addEventListener('resize', () => {
            const rect = map.container.getBoundingClientRect();
            map.canvas.width = rect.width;
            map.canvas.height = rect.height;
            draw();
        });
    }

    function setupControls() {
        const zoomIn = document.getElementById('mapZoomIn');
        const zoomOut = document.getElementById('mapZoomOut');
        const reset = document.getElementById('resetMapView');

        if (zoomIn) {
            zoomIn.onclick = () => {
                map.zoom = Math.min(5, map.zoom * 1.2);
                draw();
            };
        }

        if (zoomOut) {
            zoomOut.onclick = () => {
                map.zoom = Math.max(0.5, map.zoom / 1.2);
                draw();
            };
        }

        if (reset) {
            reset.onclick = () => {
                map.zoom = 1.2;
                map.panX = map.canvas.width / 2;
                map.panY = map.canvas.height / 2;
                draw();
            };
        }
    }

    function loadCities() {
        if (!window.quebecMunicipalities) {
            setTimeout(loadCities, 100);
            return;
        }

        map.cities = [];
        for (const [name, data] of Object.entries(window.quebecMunicipalities)) {
            if (!data || !data.lat || !data.lng) continue;
            const lat = parseFloat(data.lat);
            const lng = parseFloat(data.lng);
            if (lat >= BOUNDS.minLat && lat <= BOUNDS.maxLat &&
                lng >= BOUNDS.minLng && lng <= BOUNDS.maxLng) {
                map.cities.push({
                    name: name,
                    lat: lat,
                    lng: lng,
                    population: parseInt(data.population) || 0
                });
            }
        }
        draw();
    }

    function loadVillages() {
        fetch('/api/endpoints/map-villages.php')
            .then(res => res.json())
            .then(data => {
                if (data.success && data.villages) {
                    map.villages = data.villages
                        .filter(v => v.lat && v.lng)
                        .map(v => ({
                            name: v.name,
                            name_fr: v.name_fr,
                            lat: parseFloat(v.lat),
                            lng: parseFloat(v.lng),
                            status: v.status
                        }));
                    draw();
                }
            })
            .catch(() => {});
    }

    function latLngToXY(lat, lng) {
        const x = ((lng - BOUNDS.minLng) / (BOUNDS.maxLng - BOUNDS.minLng)) * map.canvas.width * map.zoom + (map.panX - (map.canvas.width * map.zoom) / 2);
        const y = ((BOUNDS.maxLat - lat) / (BOUNDS.maxLat - BOUNDS.minLat)) * map.canvas.height * map.zoom + (map.panY - (map.canvas.height * map.zoom) / 2);
        return { x, y };
    }

    function draw() {
        if (!map.ctx || !map.canvas) return;

        const ctx = map.ctx;
        const w = map.canvas.width;
        const h = map.canvas.height;

        // Clear
        ctx.clearRect(0, 0, w, h);

        // Background
        ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--color-bg-light').trim() || '#1a1a1a';
        ctx.fillRect(0, 0, w, h);

        // Grid
        ctx.strokeStyle = 'rgba(212, 165, 116, 0.1)';
        ctx.lineWidth = 1;
        for (let x = 0; x < w; x += 50) {
            ctx.beginPath();
            ctx.moveTo(x, 0);
            ctx.lineTo(x, h);
            ctx.stroke();
        }
        for (let y = 0; y < h; y += 50) {
            ctx.beginPath();
            ctx.moveTo(0, y);
            ctx.lineTo(w, y);
            ctx.stroke();
        }

        // Draw cities
        map.cities.forEach(city => {
            const pos = latLngToXY(city.lat, city.lng);
            if (pos.x < -50 || pos.x > w + 50 || pos.y < -50 || pos.y > h + 50) return;

            const radius = city.population > 100000 ? 8 : city.population > 50000 ? 5 : 3;
            const color = city.population > 100000 ? '#d4a574' : city.population > 50000 ? '#8bc34a' : '#6496c8';

            ctx.fillStyle = color;
            ctx.beginPath();
            ctx.arc(pos.x, pos.y, radius, 0, Math.PI * 2);
            ctx.fill();

            ctx.strokeStyle = color;
            ctx.lineWidth = 2;
            ctx.stroke();

            if (city.population > 50000 && map.zoom > 1.5) {
                ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--color-text').trim() || '#f5f5f5';
                ctx.font = '12px sans-serif';
                ctx.textAlign = 'center';
                ctx.fillText(city.name, pos.x, pos.y + radius + 5);
            }
        });

        // Draw villages
        if (map.zoom > 2.0) {
            map.villages.forEach(village => {
                const pos = latLngToXY(village.lat, village.lng);
                if (pos.x < -50 || pos.x > w + 50 || pos.y < -50 || pos.y > h + 50) return;

                const isActive = village.status === 'active';
                const radius = isActive ? 10 : 6;
                const color = isActive ? '#ffd700' : '#8bc34a';

                ctx.fillStyle = color;
                ctx.beginPath();
                ctx.arc(pos.x, pos.y, radius, 0, Math.PI * 2);
                ctx.fill();

                ctx.strokeStyle = color;
                ctx.lineWidth = isActive ? 3 : 2;
                ctx.stroke();

                const name = (document.documentElement.lang === 'fr' && village.name_fr) ? village.name_fr : village.name;
                ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--color-text').trim() || '#f5f5f5';
                ctx.font = isActive ? 'bold 13px sans-serif' : '12px sans-serif';
                ctx.textAlign = 'center';
                ctx.fillText(name, pos.x, pos.y + radius + 5);
            });
        } else {
            // Show only active villages when zoomed out
            map.villages.filter(v => v.status === 'active').forEach(village => {
                const pos = latLngToXY(village.lat, village.lng);
                if (pos.x < -50 || pos.x > w + 50 || pos.y < -50 || pos.y > h + 50) return;

                ctx.fillStyle = '#ffd700';
                ctx.beginPath();
                ctx.arc(pos.x, pos.y, 10, 0, Math.PI * 2);
                ctx.fill();

                ctx.strokeStyle = '#ffd700';
                ctx.lineWidth = 3;
                ctx.stroke();
            });
        }
    }

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        setTimeout(init, 100);
    }
})();

CasperSecurity Mini