0a51001791
Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
925 B
JavaScript
25 lines
925 B
JavaScript
document.addEventListener("DOMContentLoaded", () => {
|
|
const banner = document.getElementById("cookieBanner");
|
|
const acceptBtn = document.getElementById("cookieAcceptBtn");
|
|
const rejectBtn = document.getElementById("cookieRejectBtn");
|
|
if (!banner) return;
|
|
|
|
const consent = localStorage.getItem("photohost_cookie_consent");
|
|
if (!consent) {
|
|
banner.hidden = false;
|
|
}
|
|
|
|
async function saveConsent(analytics) {
|
|
await fetch("/legal/cookie-consent", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ essential: true, analytics }),
|
|
});
|
|
localStorage.setItem("photohost_cookie_consent", analytics ? "all" : "essential");
|
|
banner.hidden = true;
|
|
}
|
|
|
|
acceptBtn?.addEventListener("click", () => saveConsent(true));
|
|
rejectBtn?.addEventListener("click", () => saveConsent(false));
|
|
});
|