You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
161hz.de/js/main.js

58 lines
1.6 KiB

(function () {
var infoBar = document.querySelector(".cookies-infobar");
var btnAccept = document.querySelector("#cookies-infobar-close");
// Check if user has already accepted the notification
if(wasAccepted()) {
hideInfobar();
return;
}
//listen for the click event on Accept button
btnAccept.addEventListener("click", function (e) {
e.preventDefault();
hideInfobar();
saveAcceptInCookies(7);
});
//hide cookie info bar
function hideInfobar () {
infoBar.className = infoBar.classList.value + " cookies-infobar_accepted";
}
// Check if user has already accepted the notification
function wasAccepted () {
return checkCookie() === "1";
}
// get cookie
function checkCookie () {
var name = "cookieInfoHidden=";
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
while (cookie.charAt(0)==' ') {
cookie = cookie.substring(1);
}
if (cookie.indexOf(name) === 0) {
return cookie.substring(name.length, cookie.length);
}
}
return "";
};
//save cookie
function saveAcceptInCookies (daysOfValidity) {
var now = new Date();
var time = now.getTime() + (daysOfValidity * 24 * 60 * 60 * 1000);
var newTime = new Date(now.setTime(time));
newTime = newTime.toUTCString();
document.cookie = "cookieInfoHidden=1; expires=" + newTime + "; path=/";
}
})();