main.js further implemented
This commit is contained in:
@@ -16,7 +16,7 @@ searchButton.addEventListener("click", () => {
|
||||
search(searchString);
|
||||
});
|
||||
const searchBar = document.getElementById("search-entry");
|
||||
searchBar.addEventListener("change", () => {
|
||||
searchBar.addEventListener("input", () => {
|
||||
const searchString = searchBar.value;
|
||||
search(searchString);
|
||||
});
|
||||
@@ -27,17 +27,23 @@ sortButton.addEventListener("change", () => {
|
||||
sort(sortString);
|
||||
});
|
||||
|
||||
const upvoteButton = document.getElementsByClassName("upvote-btn");
|
||||
upvoteButton.addEventListener("click", () => {
|
||||
//const entryID = ;
|
||||
const upvoteButtons = document.getElementsByClassName("upvote-btn");
|
||||
const upvoteButtonClickListener = () => {
|
||||
const entryID = upvoteButton.parent.dataset.id;
|
||||
vote(entryID, true);
|
||||
});
|
||||
};
|
||||
for (const upvoteButton of upvoteButtons) {
|
||||
upvoteButton.addEventListener("click", upvoteButtonClickListener);
|
||||
}
|
||||
|
||||
const downvoteButton = document.getElementsByClassName("downvote-btn");
|
||||
downvoteButton.addEventListener("click", () => {
|
||||
//const entryID;
|
||||
const downvoteButtons = document.getElementsByClassName("downvote-btn");
|
||||
const downvoteButtonClickListener = () => {
|
||||
const entryID = downvoteButton.parent.dataset.id;
|
||||
vote(entryID, false);
|
||||
});
|
||||
};
|
||||
for (const downvoteButton of downvoteButtons) {
|
||||
downvoteButton.addEventListener("click", downvoteButtonClickListener);
|
||||
}
|
||||
|
||||
function navigateToAdd() {
|
||||
|
||||
@@ -48,7 +54,7 @@ function filter(filterString) {
|
||||
}
|
||||
|
||||
function search(searchString) {
|
||||
|
||||
console.log(searchString);
|
||||
}
|
||||
|
||||
function sort(sortString) {
|
||||
@@ -57,5 +63,4 @@ function sort(sortString) {
|
||||
|
||||
function vote(entryID, up) {
|
||||
fetch()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user