|
// Kathir Vel's EU Cookie Law Implied Consent Notice |
|
// Based on |
|
// Creare's 'Implied Consent' EU Cookie Law Banner v:2.4 |
|
// Conceived by Robert Kent, James Bavington & Tom Foyster |
|
|
|
var kvcn_dropCookie = true; // false disables the Cookie, allowing you to style the banner |
|
var kvcn_cookieDuration = 14; // Number of days before the cookie expires, and the banner reappears |
|
var kvcn_cookieName = 'euCookieLawImpliedConsentCookie'; // Name of our cookie |
|
var kvcn_cookieValue = 'on'; // Value of cookie |
|
|
|
window.addEventListener('load', function (){ |
|
if (kvcn_checkCookie(window.kvcn_cookieName) != window.kvcn_cookieValue) { |
|
kvcn_createDiv(); |
|
} |
|
}); |
|
|
|
function kvcn_createDiv() { |
|
var bodytag = document.getElementsByTagName('body')[0]; |
|
var div = document.createElement('div'); |
|
div.setAttribute('id', 'eu-cookie-law-implied-consent-notice'); |
|
div.setAttribute('class', 'cookie-notice-container cookie-notice-bar cookie-notice-bar-top text-center hidden-xs hidden-sm'); |
|
div.innerHTML = '<div class="cookie-notice-content" style="background: lightgrey;">' + |
|
'This site uses cookies. By continuing to browse this site you are agreeing to our use of cookies. <a title="Find out more." class="cookie-notice-page-link" href="/privacy-policy/">Our privacy policy.</a>' + |
|
' <a title="Close" id="cookie-notice-close-button" class="cookie-notice-button" href="javascript:void(0);" onclick="kvcn_removeCookieNotice();">Close this.</a>' + |
|
'</div>'; |
|
// Be advised the Close Banner 'X' link requires jQuery |
|
// bodytag.appendChild(div); // Adds the Cookie Law Banner just before the closing </body> tag |
|
// or |
|
bodytag.insertBefore(div, bodytag.firstChild); // Adds the Cookie Law Banner just after the opening <body> tag |
|
|
|
document.getElementsByTagName('body')[0].className += ' cookie-notice-visible'; //Adds a class tothe <body> tag when the banner is visible |
|
|
|
kvcn_createCookie(window.kvcn_cookieName, window.kvcn_cookieValue, window.kvcn_cookieDuration); // Create the cookie |
|
} |
|
|
|
function kvcn_createCookie(name, value, days) { |
|
if (days) { |
|
var date = new Date(); |
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); |
|
var expires = "; expires=" + date.toGMTString(); |
|
} |
|
else |
|
var expires = ""; |
|
if (window.kvcn_dropCookie) { |
|
document.cookie = name + "=" + value + expires + "; path=/"; |
|
} |
|
} |
|
|
|
function kvcn_checkCookie(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; |
|
} |
|
|
|
function kvcn_eraseCookie(name) { |
|
kvcn_createCookie(name, "", -1); |
|
} |
|
|
|
function kvcn_removeCookieNotice() { |
|
var element = document.getElementById('eu-cookie-law-implied-consent-notice'); |
|
element.parentNode.removeChild(element); |
|
} |