added read/write cookie via js
This commit is contained in:
parent
7d1b88f26f
commit
0185a3bf93
|
@ -9965,6 +9965,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
return body.classList.add("shown");
|
||||
}, 400);
|
||||
|
||||
var statusCookiePolicyAccepted = readCookie("status-cookie-policy");
|
||||
if (statusCookiePolicyAccepted == "accepted") {
|
||||
hideCookiePopup();
|
||||
}
|
||||
|
||||
document.querySelectorAll(".more-button")[0].addEventListener('click', function (event) {
|
||||
animateScroll(slideTwo, 600, "easeInOutCubic", 0);
|
||||
event.preventDefault();
|
||||
|
@ -9981,7 +9986,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
});
|
||||
|
||||
cookieButton.addEventListener('click', function (event) {
|
||||
document.querySelectorAll(".cookie-popup__inner")[0].style.display = "none";
|
||||
createCookie("status-cookie-policy", "accepted", 30);
|
||||
hideCookiePopup();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
@ -10030,4 +10036,43 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|||
}
|
||||
}]
|
||||
}).init();
|
||||
|
||||
function hideCookiePopup() {
|
||||
document.querySelectorAll(".cookie-popup__inner")[0].style.display = "none";
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create cookie
|
||||
function createCookie(name, value, days) {
|
||||
var expires;
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=/";
|
||||
}
|
||||
|
||||
// Read cookie
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return c.substring(nameEQ.length, c.length);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Erase cookie
|
||||
function eraseCookie(name) {
|
||||
createCookie(name, "", -1);
|
||||
}
|
||||
}, { "./lib/ScrollOver.js": 17, "./lib/animatescroll.js": 18 }] }, {}, [19]);
|
|
@ -13,6 +13,11 @@ let iphone = document.querySelectorAll(".phone-wrap--iphone")[0],
|
|||
|
||||
setTimeout(() => body.classList.add("shown"), 400)
|
||||
|
||||
let statusCookiePolicyAccepted = readCookie("status-cookie-policy")
|
||||
if (statusCookiePolicyAccepted == "accepted") {
|
||||
hideCookiePopup()
|
||||
}
|
||||
|
||||
document.querySelectorAll(".more-button")[0].addEventListener('click', function(event){
|
||||
animateScroll(slideTwo, 600, "easeInOutCubic", 0)
|
||||
event.preventDefault()
|
||||
|
@ -29,7 +34,8 @@ document.querySelectorAll(".nav__item--about")[0].addEventListener('click', func
|
|||
})
|
||||
|
||||
cookieButton.addEventListener('click', function(event){
|
||||
document.querySelectorAll(".cookie-popup__inner")[0].style.display = "none"
|
||||
createCookie("status-cookie-policy", "accepted", 30)
|
||||
hideCookiePopup()
|
||||
event.preventDefault()
|
||||
})
|
||||
|
||||
|
@ -93,3 +99,43 @@ new ScrollOver({
|
|||
}
|
||||
]
|
||||
}).init()
|
||||
|
||||
function hideCookiePopup() {
|
||||
document.querySelectorAll(".cookie-popup__inner")[0].style.display = "none"
|
||||
return true
|
||||
}
|
||||
|
||||
// Create cookie
|
||||
function createCookie(name, value, days) {
|
||||
var expires;
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
expires = "; expires="+date.toGMTString();
|
||||
}
|
||||
else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = name+"="+value+expires+"; path=/";
|
||||
}
|
||||
|
||||
// Read cookie
|
||||
function readCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1,c.length);
|
||||
}
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Erase cookie
|
||||
function eraseCookie(name) {
|
||||
createCookie(name,"",-1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue