Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/attendance/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/attendance/test_gps.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GPS Location Test</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center">
    <div class="max-w-md mx-auto bg-white rounded-lg shadow-lg p-6">
        <h1 class="text-2xl font-bold text-gray-900 mb-6 text-center">
            <i class="fas fa-map-marker-alt text-blue-600 mr-2"></i>GPS Test
        </h1>
        
        <div class="space-y-4">
            <div id="status" class="text-center text-gray-600">
                <i class="fas fa-spinner fa-spin mr-2"></i>Testing GPS functionality...
            </div>
            
            <div id="results" class="hidden space-y-3">
                <div class="bg-green-50 border border-green-200 rounded-lg p-4">
                    <h3 class="font-semibold text-green-900 mb-2">Location Details:</h3>
                    <div class="text-sm space-y-1">
                        <p><strong>Latitude:</strong> <span id="lat"></span></p>
                        <p><strong>Longitude:</strong> <span id="lng"></span></p>
                        <p><strong>Accuracy:</strong> <span id="accuracy"></span> meters</p>
                        <p><strong>Address:</strong> <span id="address">Loading...</span></p>
                    </div>
                </div>
                
                <div class="text-center">
                    <a id="mapLink" href="#" target="_blank" 
                       class="inline-flex items-center text-blue-600 hover:text-blue-800">
                        <i class="fas fa-external-link-alt mr-2"></i>View on Google Maps
                    </a>
                </div>
            </div>
            
            <div id="error" class="hidden bg-red-50 border border-red-200 rounded-lg p-4">
                <h3 class="font-semibold text-red-900 mb-2">Error:</h3>
                <p id="errorMsg" class="text-sm text-red-700"></p>
            </div>
            
            <div class="text-center pt-4">
                <button onclick="testGPS()" 
                        class="bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700 transition duration-300">
                    <i class="fas fa-redo mr-2"></i>Test Again
                </button>
            </div>
        </div>
    </div>

    <script>
        function testGPS() {
            const status = document.getElementById('status');
            const results = document.getElementById('results');
            const error = document.getElementById('error');
            
            // Reset UI
            status.classList.remove('hidden');
            results.classList.add('hidden');
            error.classList.add('hidden');
            status.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i>Testing GPS functionality...';
            
            if (!navigator.geolocation) {
                showError('Geolocation is not supported by this browser.');
                return;
            }
            
            navigator.geolocation.getCurrentPosition(
                function(position) {
                    const lat = position.coords.latitude;
                    const lng = position.coords.longitude;
                    const accuracy = position.coords.accuracy;
                    
                    // Update UI
                    document.getElementById('lat').textContent = lat.toFixed(6);
                    document.getElementById('lng').textContent = lng.toFixed(6);
                    document.getElementById('accuracy').textContent = Math.round(accuracy);
                    document.getElementById('mapLink').href = `https://www.google.com/maps?q=${lat},${lng}`;
                    
                    status.classList.add('hidden');
                    results.classList.remove('hidden');
                    
                    // Get address
                    fetch(`https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}&zoom=18&addressdetails=1`)
                        .then(response => response.json())
                        .then(data => {
                            if (data && data.display_name) {
                                document.getElementById('address').textContent = data.display_name;
                            } else {
                                document.getElementById('address').textContent = 'Address not available';
                            }
                        })
                        .catch(error => {
                            document.getElementById('address').textContent = 'Address lookup failed';
                        });
                },
                function(error) {
                    let errorMessage = 'Unable to retrieve your location.';
                    
                    switch(error.code) {
                        case error.PERMISSION_DENIED:
                            errorMessage = 'Location access denied by user. Please allow location access and try again.';
                            break;
                        case error.POSITION_UNAVAILABLE:
                            errorMessage = 'Location information is unavailable. Check your device settings.';
                            break;
                        case error.TIMEOUT:
                            errorMessage = 'Location request timed out. Try again.';
                            break;
                    }
                    
                    showError(errorMessage);
                },
                {
                    enableHighAccuracy: true,
                    timeout: 10000,
                    maximumAge: 300000
                }
            );
        }
        
        function showError(message) {
            const status = document.getElementById('status');
            const error = document.getElementById('error');
            
            status.classList.add('hidden');
            error.classList.remove('hidden');
            document.getElementById('errorMsg').textContent = message;
        }
        
        // Auto-start test when page loads
        document.addEventListener('DOMContentLoaded', function() {
            testGPS();
        });
    </script>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists