const cookieName = 'myCookieConsent'
const path = '/';
(function(){
const cookieValue = 'OK'
const expiryDays = 365
function setCookie(_n, _v, _d){
const _e = new Date(Date.now() + (_d * 24 * 60 * 60 * 1000)).toGMTString()
document.cookie = _n + '=' + _v + '; expires=' + _e + '; path=' + path
}
function getCookieValue(_n){
const nameEQ = _n + '='
const ca = document.cookie.split(';')
for (let i=0; i<ca.length; i++){
let 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
}
function dismissBanner(){
setCookie(cookieName, cookieValue, expiryDays)
document.querySelector('.c-div').remove()
}
if (getCookieValue(cookieName) !== cookieValue){
const cDiv = document.createElement('div')
cDiv.classList.add('c-div')
document.body.append(cDiv)
const cContent = document.createElement('div')
cContent.classList.add('c-content')
cDiv.append(cContent)
cContent.append('Your message about cookies goes here.')
const cButton = document.createElement('button')
cButton.classList.add('c-OK')
cContent.append(cButton)
cButton.textContent = 'OK'
cButton.addEventListener('click', dismissBanner)
}
})()