Show trip replace confirmation as late as possible
All checks were successful
pedestrian-simulator / build (push) Successful in 58s
All checks were successful
pedestrian-simulator / build (push) Successful in 58s
This commit is contained in:
@@ -533,9 +533,20 @@ function setupKMLDetailsListeners() {
|
||||
document.getElementById('closeKmlDetails').addEventListener('click', closeKMLDetails);
|
||||
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;
|
||||
|
||||
// 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
|
||||
startFromCustomRoute(currentKmlPath, currentKmlFile.filename, false, currentKmlMarkers);
|
||||
|
||||
@@ -856,11 +867,22 @@ function initializeMap() {
|
||||
|
||||
function setupEventListeners() {
|
||||
// Start button
|
||||
document.getElementById('startButton').addEventListener('click', () => {
|
||||
document.getElementById('startButton').addEventListener('click', async () => {
|
||||
const startInput = document.getElementById('startLocationInput').value;
|
||||
const endInput = document.getElementById('endLocationInput').value;
|
||||
|
||||
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);
|
||||
} else {
|
||||
alert('Please enter both a start and destination location');
|
||||
@@ -876,20 +898,9 @@ function setupEventListeners() {
|
||||
document.getElementById('startLocationInput').addEventListener('keypress', handleEnter);
|
||||
document.getElementById('endLocationInput').addEventListener('keypress', handleEnter);
|
||||
|
||||
// Route Info Click -> Open Reset Confirmation
|
||||
document.getElementById('routeInfoGroup').addEventListener('click', async () => {
|
||||
if (localStorage.getItem(LOCATION_STORAGE)) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
// Route Info Click -> Open Setup (No reset prompt here)
|
||||
document.getElementById('routeInfoGroup').addEventListener('click', () => {
|
||||
resetLocation(); // This now just opens the overlay
|
||||
});
|
||||
|
||||
// Space bar hotkey for refresh
|
||||
|
||||
Reference in New Issue
Block a user