Show trip replace confirmation as late as possible
All checks were successful
pedestrian-simulator / build (push) Successful in 58s

This commit is contained in:
2026-01-13 13:47:56 -07:00
parent cb1304bc6d
commit 41e82ed6e6

View File

@@ -533,9 +533,20 @@ function setupKMLDetailsListeners() {
document.getElementById('closeKmlDetails').addEventListener('click', closeKMLDetails); document.getElementById('closeKmlDetails').addEventListener('click', closeKMLDetails);
document.getElementById('backToKmlListBtn').addEventListener('click', closeKMLDetails); // Just close overlay to reveal browser behind document.getElementById('backToKmlListBtn').addEventListener('click', closeKMLDetails); // Just close overlay to reveal browser behind
document.getElementById('startKmlTripBtn').addEventListener('click', () => { document.getElementById('startKmlTripBtn').addEventListener('click', async () => {
if (!currentKmlFile || currentKmlPath.length === 0) return; if (!currentKmlFile || currentKmlPath.length === 0) return;
// Check for existing trip
if (localStorage.getItem(LOCATION_STORAGE)) {
const confirmed = await showConfirm({
title: '⚠️ Start New Trip?',
message: 'Starting a new trip will end your current one. Are you sure?',
confirmText: 'Yes, Start New Trip',
isDanger: true
});
if (!confirmed) return;
}
// Start the trip // Start the trip
startFromCustomRoute(currentKmlPath, currentKmlFile.filename, false, currentKmlMarkers); startFromCustomRoute(currentKmlPath, currentKmlFile.filename, false, currentKmlMarkers);
@@ -856,11 +867,22 @@ function initializeMap() {
function setupEventListeners() { function setupEventListeners() {
// Start button // Start button
document.getElementById('startButton').addEventListener('click', () => { document.getElementById('startButton').addEventListener('click', async () => {
const startInput = document.getElementById('startLocationInput').value; const startInput = document.getElementById('startLocationInput').value;
const endInput = document.getElementById('endLocationInput').value; const endInput = document.getElementById('endLocationInput').value;
if (startInput && endInput) { if (startInput && endInput) {
// Check for existing trip
if (localStorage.getItem(LOCATION_STORAGE)) {
const confirmed = await showConfirm({
title: '⚠️ Start New Trip?',
message: 'Starting a new trip will end your current one. Are you sure?',
confirmText: 'Yes, Start New Trip',
isDanger: true
});
if (!confirmed) return;
}
calculateAndStartRoute(startInput, endInput); calculateAndStartRoute(startInput, endInput);
} else { } else {
alert('Please enter both a start and destination location'); alert('Please enter both a start and destination location');
@@ -876,20 +898,9 @@ function setupEventListeners() {
document.getElementById('startLocationInput').addEventListener('keypress', handleEnter); document.getElementById('startLocationInput').addEventListener('keypress', handleEnter);
document.getElementById('endLocationInput').addEventListener('keypress', handleEnter); document.getElementById('endLocationInput').addEventListener('keypress', handleEnter);
// Route Info Click -> Open Reset Confirmation // Route Info Click -> Open Setup (No reset prompt here)
document.getElementById('routeInfoGroup').addEventListener('click', async () => { document.getElementById('routeInfoGroup').addEventListener('click', () => {
if (localStorage.getItem(LOCATION_STORAGE)) { resetLocation(); // This now just opens the overlay
const confirmed = await showConfirm({
title: '⚠️ Confirm Reset',
message: 'Are you sure you want to reset your location? This will end your current trip.',
confirmText: 'Yes, Reset',
isDanger: true
});
if (confirmed) {
resetLocation();
}
}
}); });
// Space bar hotkey for refresh // Space bar hotkey for refresh