This repository has been archived on 2022-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Mind-Overflow-Website/scripts/policy-popup.js

39 lines
1.1 KiB
JavaScript

function openPolicyPopup() {
if(getCookie("consentGiven") === "true") return;
$("#policy-popup").fadeIn(1000); // Enable the div
}
function agreePolicyPopup() {
const _paq = window._paq || [];
_paq.push(['rememberConsentGiven', 43800]);
$("#policy-popup").fadeOut(1000); // Disable the div
setCookie("consentGiven", "true", 1825) // todo: check if already present? also, firefox was throwing a warning...
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/;SameSite=Lax";
}