local storage now properly implemented, (sessionstorage)
This commit is contained in:
parent
02d2f90e85
commit
62b0d5c028
@ -38,11 +38,11 @@ export default class Dataset {
|
|||||||
clone.querySelector("span").innerText = this.#upvotes;
|
clone.querySelector("span").innerText = this.#upvotes;
|
||||||
|
|
||||||
// depending on whether the button has been up/downvoted, its according button get disabled and hidden
|
// depending on whether the button has been up/downvoted, its according button get disabled and hidden
|
||||||
if (votedIDs.has(entryID)) {
|
if (votedIDs.getItem(entryID)) {
|
||||||
let votedButton = clone.querySelector(votedIDs.get(entryID)? ".upvote-btn":".downvote-btn");
|
let votedButton = clone.querySelector(votedIDs.getItem(entryID)? ".upvote-btn":".downvote-btn");
|
||||||
votedButton.classList.add("isVoted");
|
votedButton.classList.add("isVoted");
|
||||||
votedButton.disabled = true;
|
votedButton.disabled = true;
|
||||||
let notVotedButton = clone.querySelector(votedIDs.get(entryID)? ".downvote-btn":".upvote-btn");
|
let notVotedButton = clone.querySelector(votedIDs.getItem(entryID)? ".downvote-btn":".upvote-btn");
|
||||||
notVotedButton.style.visibility = "hidden";
|
notVotedButton.style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export const lastQuery = {
|
|||||||
totalPages: 0,
|
totalPages: 0,
|
||||||
currentPage: 0
|
currentPage: 0
|
||||||
};
|
};
|
||||||
export const votedIDs = new Map;
|
export const votedIDs = window.sessionStorage;
|
||||||
|
|
||||||
// definition of all buttons & sections
|
// definition of all buttons & sections
|
||||||
const addButton = document.getElementById("add-btn");
|
const addButton = document.getElementById("add-btn");
|
||||||
@ -154,7 +154,7 @@ export function vote(entryID, up) {
|
|||||||
votedButton.disabled = true;
|
votedButton.disabled = true;
|
||||||
let notVotedButton = dataSetElement.querySelector(up? ".downvote-btn":".upvote-btn");
|
let notVotedButton = dataSetElement.querySelector(up? ".downvote-btn":".upvote-btn");
|
||||||
notVotedButton.style.visibility = "hidden";
|
notVotedButton.style.visibility = "hidden";
|
||||||
votedIDs.set(dataSetElement.getAttribute("data-id"), up);
|
votedIDs.setItem(dataSetElement.getAttribute("data-id"), up);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user