'use strict'; $('body').on('welcomeInfoFetched', function (e, isGDPR) { var cookieName = 'okdcookie'; var cookie = getCookie(cookieName); if (cookie === '' && isGDPR) { var el = $('body .default-navigation-all'); var cookieAlertHtml = getCookieAlertHTML(window.location.hostname); el.after(cookieAlertHtml); cookieAlertHtml.find('.btn').on('click', function () { cookieAlertHtml.slideUp(400, function () { cookieAlertHtml.remove(); }); setCookie(cookieName, 1, 365); }); cookieAlertHtml.find('.fa-times').on('click', function () { cookieAlertHtml.slideUp(400, function () { cookieAlertHtml.remove(); }); }); setTimeout(function () { cookieAlertHtml.removeClass('closed'); }, 10); } }); function getCookieAlertHTML(host) { return $('
'); } /** * ------------------------------------------------------------------------------------------------------------------ * The jQuery cookie plugin is not setup and I found it easier and more lightweight to copy this from w3 * * Copied from https://www.w3schools.com/js/js_cookies.asp * ------------------------------------------------------------------------------------------------------------------ */ /** * @param cname * @param cvalue * @param exdays */ function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = 'expires='+d.toUTCString(); document.cookie = cname + '=' + cvalue + ';' + expires + ';secure;path=/'; } /** * * @param cname * @returns {string} */ function getCookie(cname) { var name = cname + '='; 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); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ''; }