feat: Only show existing data

This commit is contained in:
moanos [he/him] 2025-01-09 19:26:33 +01:00
parent 0c94049e21
commit c6af3e8d04
3 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,8 @@
function ifdef(variable, prefix = "", suffix = "") {
if (variable !== undefined) {
return prefix + variable + suffix;
} else {
return "";
}
}

View File

@ -14,6 +14,8 @@
<link href="{% static 'fontawesomefree/css/brands.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'fontawesomefree/css/solid.css' %}" rel="stylesheet" type="text/css">
<script src="{% static 'fellchensammlung/js/custom.js' %}"></script>
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'fellchensammlung/favicon/apple-touch-icon.png' %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'fellchensammlung/favicon/favicon-32x32.png' %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'fellchensammlung/favicon/favicon-16x16.png' %}">

View File

@ -60,12 +60,12 @@
locations.forEach(location => {
const listItem = document.createElement('li');
listItem.classList.add('result-item');
listItem.textContent = location.properties.name + " (" + location.properties.city+")";
listItem.textContent = location.properties.name + ifdef(location.properties.city, " (", ")");
// Add event when user clicks on a result location
listItem.addEventListener('click', () => {
locationInput.value = location.properties.name + ", " + location.properties.city + ", " + location.properties.country; // Set input field to selected location
locationInput.value = location.properties.name +ifdef(location.properties.city, ", ", "") + ifdef(location.properties.country, ", ", ""); // Set input field to selected location
resultsList.innerHTML = ''; // Clear the results after selecting a location
});