From d53e0d423fbe80e7f17d52dec0262fa0c90b3bf3 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 27 May 2025 12:24:12 +1000 Subject: [PATCH] feat: Show more locations if there are less submissions --- templates/index.html | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/templates/index.html b/templates/index.html index 435f2a0..7f664d5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -312,10 +312,17 @@ const recentLocations = locations.filter(location => new Date(location.date_added) > cutoffTime ); - - if (recentLocations.length === 0) { - locationsList.innerHTML = '

No locations added in the last 48 hours.

'; - return; + + // Update the list with summary + locationsList.innerHTML = `

Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.

`; + + // If there are less than 10 recent locations, show the newest 10 + if (recentLocations.length < 10) { + // Get the newest locations up to 10 + recentLocations.sort((a, b) => new Date(b.date_added) - new Date(a.date_added)); + recentLocations.splice(10); + + locationsList.innerHTML = `

Showing the newest ${recentLocations.length} locations.

`; } // Add markers for each location @@ -323,8 +330,7 @@ addLocationToMap(location); }); - // Update the list with summary - locationsList.innerHTML = `

Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.

`; + }) .catch(error => { console.error('Error loading locations:', error);