search nw displays the search results.

other section are being hidden in the case of a search and vice versa.
a 'nothing found' div was implemented
This commit is contained in:
J-Klinke
2024-06-24 17:03:47 +02:00
parent 43d3ff17d5
commit d96da1b1e7
7 changed files with 137 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import { searchBarTimeout } from "./main.js"
import {searchBarTimeout, searchSection} from "./main.js"
import Dataset from "./dataset.js"
export function fetchQuery(fetchString) {
clearTimeout(searchBarTimeout);
@@ -11,4 +12,17 @@ export function fetchQuery(fetchString) {
function parseContent(content) {
//TODO: method for parsing query results
console.log(content);
if (content.length === 0) {
searchSection.querySelector("#nothing-found ").classList.remove("hidden");
} else {
searchSection.querySelector("#nothing-found").classList.add("hidden");
const datasets = content.map(dataset => new Dataset(dataset));
console.log(datasets);
Array.from(searchSection.querySelectorAll(".datasets .dataset")).forEach(e => e.remove());
for (const dataset of datasets) {
searchSection.querySelector(".datasets").appendChild(dataset.createDatasetHTMLElement());
}
}
}