Можно не менять на на getElementsByClassName
(function(){
"use strict";
window.FS = window.FS || {};
window.FS.GDPR = window.FS.GDPR || {};
//setup hook for when accept is clicked
var onAcceptCbs = [];
window.FS.GDPR.onAccept = function(cb){
onAcceptCbs.push(cb);
};
const handler = function(event){
//save the acceptance cookie
var d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
//figure out the domain
var cookieDomain = window.location.hostname;
var domainParts = cookieDomain.split('.');
var firstPart = domainParts[0];
if( !isNumeric(firstPart) && (cookieDomain.indexOf("local")<0) && (domainParts.length > 1) ){
cookieDomain = '.' + domainParts.slice(domainParts.length -2).join('.');
}
//actually save the cookie value
document.cookie = 'gdprAccepted=true;path=/;expires=' + d.toUTCString() + ';domain='+cookieDomain;
banner.style.display = "none";
//trigger any callbacks that have registered for when accept is clicked
onAcceptCbs.forEach(function(cb){
cb();
});
//mark that it's been accepted
window.FS.GDPR.accepted = true;
//stops the click
return false;
};
//get the banner
var banner = document.getElementById('GdprCookieBanner');
var acceptButton = document.getElementById('GdprCookieBannerAccept');
acceptButton.onclick = handler;
baner.onclick = handler;
if(document.cookie.indexOf('gdprAccepted=true') < 0){
//cookie not found. show banner
banner.style.display = "block";
//mark that we don't have acceptance
window.FS.GDPR.accepted = false;
}else{
//mark that
window.FS.GDPR.accepted = true;
}
function isNumeric(item){
return !isNaN(parseFloat(item)) && isFinite(item);
}
})();