started implementing local storage
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user