generated from nathanwoodburn/python-webserver-template
feat: Show more locations if there are less submissions
All checks were successful
Build Docker / BuildImage (push) Successful in 38s
All checks were successful
Build Docker / BuildImage (push) Successful in 38s
This commit is contained in:
@@ -313,9 +313,16 @@
|
|||||||
new Date(location.date_added) > cutoffTime
|
new Date(location.date_added) > cutoffTime
|
||||||
);
|
);
|
||||||
|
|
||||||
if (recentLocations.length === 0) {
|
// Update the list with summary
|
||||||
locationsList.innerHTML = '<p>No locations added in the last 48 hours.</p>';
|
locationsList.innerHTML = `<p>Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.</p>`;
|
||||||
return;
|
|
||||||
|
// 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 = `<p>Showing the newest ${recentLocations.length} locations.</p>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add markers for each location
|
// Add markers for each location
|
||||||
@@ -323,8 +330,7 @@
|
|||||||
addLocationToMap(location);
|
addLocationToMap(location);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update the list with summary
|
|
||||||
locationsList.innerHTML = `<p>Showing ${recentLocations.length} locations from the last 48 hours. Click on markers to see details.</p>`;
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error loading locations:', error);
|
console.error('Error loading locations:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user