started initial page display
This commit is contained in:
@@ -11,7 +11,6 @@ export function fetchQuery(fetchString) {
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
console.log(content); //TODO: remove
|
||||
if (content.length === 0) {
|
||||
searchSection.querySelector("#nothing-found ").classList.remove("hidden");
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {fetchQuery} from "./contentUtility.js";
|
||||
import Dataset from "./dataset";
|
||||
|
||||
const apiEndpoint = "/api/v1/datasets";
|
||||
const baseURL = location.origin;
|
||||
@@ -106,6 +107,7 @@ function getSearchQuery() {
|
||||
let searchString = searchBar.value;
|
||||
return (searchString.length === 0 ? "%" : (searchString + "%"));
|
||||
}
|
||||
|
||||
function getSortQuery() {
|
||||
let sortString = sortButton.value.toLowerCase().split(" ");
|
||||
if (sortString[1] === "a-z" || sortString[1] === "↑" || sortString[1] === "oldest-newest") {
|
||||
@@ -181,8 +183,21 @@ function fetchCategories() {
|
||||
});
|
||||
}
|
||||
|
||||
function fetchInitialEntries() {
|
||||
let topVotedQueryURL = new URL(apiEndpoint + "/search" + baseURL);
|
||||
topVotedQueryURL.searchParams.append("sort", getSortQuery()[0]);
|
||||
topVotedQueryURL.searchParams.append("direction", getSortQuery()[1]);
|
||||
topVotedQueryURL.searchParams.append("size", "1");
|
||||
fetch(topVotedQueryURL)
|
||||
.then(resp => resp.json())
|
||||
.then((data) => {
|
||||
document.querySelector("#top .datasets").appendChild(new Dataset(data[0]).createDatasetHTMLElement());
|
||||
});
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
fetchCategories();
|
||||
fetchInitialEntries();
|
||||
updateSections();
|
||||
if (searchBar.value !== "") {
|
||||
fetchQuery(createQuery());
|
||||
|
||||
Reference in New Issue
Block a user