Add more links and improve script checks
This commit is contained in:
parent
483f406037
commit
eccd4d8bfe
12 changed files with 264 additions and 205 deletions
|
|
@ -56,8 +56,12 @@ import IconTriangleExclamation from "./icons/IconTriangleExclamation.astro";
|
|||
import { ENABLE_VIEW_TRANSITIONS } from "astro:env/client";
|
||||
|
||||
const ageRestrictedModalSetup = () => {
|
||||
if (localStorage.ageVerified !== "true") {
|
||||
const modal = document.querySelector<HTMLElementTagNameMap["div"]>("div#modal-age-restricted")!;
|
||||
const modal = document.querySelector<HTMLElementTagNameMap["div"]>("body > div#modal-age-restricted");
|
||||
if (!modal) {
|
||||
throw new Error("Missing #modal-age-restricted element! Make sure that it's a direct child of body.");
|
||||
}
|
||||
let ageVerified: "true" | undefined = localStorage.ageVerified;
|
||||
if (ageVerified !== "true") {
|
||||
const rejectButton = modal.querySelector<HTMLElementTagNameMap["button"]>("button[data-modal-reject]")!;
|
||||
const onRejectButtonClick = (e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
|
@ -69,7 +73,8 @@ import IconTriangleExclamation from "./icons/IconTriangleExclamation.astro";
|
|||
(e: MouseEvent) => {
|
||||
e.preventDefault();
|
||||
rejectButton.removeEventListener("click", onRejectButtonClick);
|
||||
localStorage.ageVerified = "true";
|
||||
ageVerified = "true";
|
||||
localStorage.ageVerified = ageVerified;
|
||||
document.body.style.overflow = "auto";
|
||||
document.querySelectorAll("body > :not(#modal-age-restricted)").forEach((el) => el.removeAttribute("inert"));
|
||||
modal.style.display = "none";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue