started implementing cookies popup; made a "common-style" css file to keep everything tidy and not have duplicate code

This commit is contained in:
Lorenzo Dellacà
2020-07-09 03:23:47 +02:00
parent d1f41cab38
commit 7421f6d06e
9 changed files with 208 additions and 109 deletions

View File

@@ -2,9 +2,9 @@
$(document).ready(function(){
$(window).scroll(function(){
if($(this).scrollTop() > $(window).height()*0.3){
$(".arrow-down").css({"opacity" : "0"})
$(".arrow-down").css({"opacity" : "0"});
} else {
$(".arrow-down").css({"opacity" : "0.4"})
$(".arrow-down").css({"opacity" : "0.4"});
}
})
})

28
scripts/policy-popup.js Normal file
View File

@@ -0,0 +1,28 @@
function openPolicyPopup() {
if(getCookie("consent") === "true") return;
$("#policy-popup").fadeIn(1000); // Enable the div
}
function agreePolicyPopup() {
const _paq = window._paq || [];
_paq.push(['rememberConsentGiven']); // todo: check if this works
$("#policy-popup").fadeOut(1000); // Disable the div
document.cookie = "consent=true"; // 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 "";
}