started implementing local storage

This commit is contained in:
J-Klinke
2024-07-02 17:41:48 +02:00
parent 1174f03d42
commit 20eda5931a
5 changed files with 42 additions and 13 deletions

View File

@@ -29,13 +29,20 @@ export default class Dataset {
this.#votes = votes;
}
createDatasetHTMLElement() {
createDatasetHTMLElement(votable, isUpVoted) {
let template = document.querySelector("#dataset-template");
const clone = template.content.cloneNode(true);
clone.querySelector(".dataset").dataset.id = this.#id;
clone.querySelector("h3").innerText = this.#title;
clone.querySelector("p").innerText = this.#description;
clone.querySelector("span").innerText = this.#upvotes;
if (!votable) {
let votedButton = clone.querySelector(isUpVoted? ".upvote-btn":".downvote-btn");
votedButton.classList.add("isVoted");
votedButton.disabled = true;
let notVotedButton = clone.querySelector(isUpVoted? ".downvote-btn":".upvote-btn");
notVotedButton.style.visibility = "hidden";
}
// Event Listeners
clone.querySelector(".upvote-btn").addEventListener("click", () => {
@@ -48,4 +55,8 @@ export default class Dataset {
return clone;
}
getID() {
return this.#id;
}
}