mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2025-09-08 06:58:43 +00:00
40 lines
922 B
JavaScript
40 lines
922 B
JavaScript
// js/disclaimer.js
|
|
|
|
class DisclaimerModal {
|
|
constructor() {
|
|
// Initialize elements when the disclaimer HTML is in the DOM.
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
this.modal = document.getElementById("disclaimerModal");
|
|
this.acceptButton = document.getElementById("acceptDisclaimer");
|
|
if (this.acceptButton) {
|
|
this.acceptButton.addEventListener("click", () => {
|
|
this.hide();
|
|
});
|
|
}
|
|
}
|
|
|
|
hide() {
|
|
if (this.modal) {
|
|
this.modal.classList.add("hidden");
|
|
}
|
|
localStorage.setItem("hasSeenDisclaimer", "true");
|
|
}
|
|
|
|
show() {
|
|
// In case the modal hasn't been initialized yet.
|
|
if (!this.modal) {
|
|
this.init();
|
|
}
|
|
if (!localStorage.getItem("hasSeenDisclaimer") && this.modal) {
|
|
this.modal.classList.remove("hidden");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create and export a default instance.
|
|
const disclaimerModal = new DisclaimerModal();
|
|
export default disclaimerModal;
|