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.style.color = "#ef4444"; // Kırmızı
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 {
statusText.textContent = "Konum aranıyor... Lütfen bekleyin veya açık alana çıkın.";
statusText.style.color = "#fbbf24"; // Sarı uyarı rengi
// Timeout veya unvailable durumlarında aramaya devam et
statusText.textContent = "Konum aranıyor... Lütfen bekleyin.";
statusText.style.color = "#fbbf24";
}
}
@@ -230,14 +235,14 @@
btn.classList.add('active');
trackLabel.textContent = "SEFERİ BİTİR";
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";
vehicleSelect.disabled = true;
// watchPosition keeps getting location updates
watchId = navigator.geolocation.watchPosition(successPosition, errorPosition, {
enableHighAccuracy: true,
timeout: 30000,
timeout: 10000,
maximumAge: 0
});
}
@@ -251,6 +256,7 @@
statusText.style.color = "#94a3b8";
vehicleSelect.disabled = false;
lastPingText.style.display = 'none';
coordsText.textContent = "-- / --";
if (watchId !== null) {
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) {
stopTracking();
} else {