Merge remote-tracking branch 'origin/21-add-functionality-for-listing-query-results-in-frontend' into 21-add-functionality-for-listing-query-results-in-frontend

This commit is contained in:
J-Klinke 2024-07-01 11:12:01 +02:00
commit 32ba4995be
2 changed files with 17 additions and 2 deletions

View File

@ -198,7 +198,23 @@ function updateSections() {
}
}
// fetches the further categories used in the filter function
function fetchCategories() {
const fetchURL = new URL(
"api/v1/categories" , baseURL);
fetch(fetchURL)
.then(resp => resp.json())
.then((data) => {
for (let i = 0; i < data.length; i++) {
let category = data[i].toLowerCase();
category = category.charAt(0).toUpperCase() + category.slice(1);
document.getElementById("other-categories").appendChild(new Option(category));
}
});
}
window.onload = function () {
fetchCategories();
updateSections();
if (searchBar.value !== "") {
search(searchBar.value);

View File

@ -52,8 +52,7 @@
<option>Dataset</option>
<option>API</option>
</optgroup>
<optgroup label="Other categories">
<option>a category</option>
<optgroup id="other-categories" label="Other categories">
</optgroup>
</select>
<input type="search" name="query" id="search-entry" placeholder="Search">