Fix tracker double click issue and gps states

This commit is contained in:
cerenX9
2026-07-23 20:25:00 +03:00
parent 02fee31723
commit 14610efe55

View File

@@ -213,10 +213,15 @@
statusText.textContent = "HATA: Konum izni reddedildi! Lütfen tarayıcı ayarlarından konum izni verin."; statusText.textContent = "HATA: Konum izni reddedildi! Lütfen tarayıcı ayarlarından konum izni verin.";
statusText.style.color = "#ef4444"; // Kırmızı statusText.style.color = "#ef4444"; // Kırmızı
stopTracking(); // İzin yoksa devam edemeyiz stopTracking(); // İzin yoksa devam edemeyiz
} else if (err.code === 2) {
statusText.textContent = "GPS sinyali yok. Açık alana çıkın...";
statusText.style.color = "#fbbf24";
} else if (err.code === 3) {
statusText.textContent = "Konum bulma zaman aşımına uğradı, tekrar deneniyor...";
statusText.style.color = "#fbbf24";
} else { } else {
statusText.textContent = "Konum aranıyor... Lütfen bekleyin veya açık alana çıkın."; statusText.textContent = "Konum aranıyor... Lütfen bekleyin.";
statusText.style.color = "#fbbf24"; // Sarı uyarı rengi statusText.style.color = "#fbbf24";
// Timeout veya unvailable durumlarında aramaya devam et
} }
} }
@@ -230,14 +235,14 @@
btn.classList.add('active'); btn.classList.add('active');
trackLabel.textContent = "SEFERİ BİTİR"; trackLabel.textContent = "SEFERİ BİTİR";
trackIcon.className = "fa-solid fa-stop"; trackIcon.className = "fa-solid fa-stop";
statusText.textContent = "Konum canlı takip ediliyor..."; statusText.textContent = "GPS Sinyali Bekleniyor... (Dışarıda Test Edin)";
statusText.style.color = "#10b981"; statusText.style.color = "#10b981";
vehicleSelect.disabled = true; vehicleSelect.disabled = true;
// watchPosition keeps getting location updates // watchPosition keeps getting location updates
watchId = navigator.geolocation.watchPosition(successPosition, errorPosition, { watchId = navigator.geolocation.watchPosition(successPosition, errorPosition, {
enableHighAccuracy: true, enableHighAccuracy: true,
timeout: 30000, timeout: 10000,
maximumAge: 0 maximumAge: 0
}); });
} }
@@ -251,6 +256,7 @@
statusText.style.color = "#94a3b8"; statusText.style.color = "#94a3b8";
vehicleSelect.disabled = false; vehicleSelect.disabled = false;
lastPingText.style.display = 'none'; lastPingText.style.display = 'none';
coordsText.textContent = "-- / --";
if (watchId !== null) { if (watchId !== null) {
navigator.geolocation.clearWatch(watchId); navigator.geolocation.clearWatch(watchId);
@@ -258,7 +264,12 @@
} }
} }
btn.addEventListener('click', function() { btn.addEventListener('click', function(e) {
e.preventDefault();
// Disable button temporarily to prevent double clicking
btn.style.pointerEvents = 'none';
setTimeout(() => { btn.style.pointerEvents = 'auto'; }, 1000);
if (isTracking) { if (isTracking) {
stopTracking(); stopTracking();
} else { } else {