Created
June 14, 2018 13:57
-
-
Save Remiii/c94567ac70a4ce55ecfd8c5cc0d50254 to your computer and use it in GitHub Desktop.
Revisions
-
Remiii created this gist
Jun 14, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # Cookie banner 🍪 Cookie banner/alert... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <div id="cookie-directive-container" style="display: none"> <nav class="navbar navbar-default navbar-fixed-bottom"> <div class="container" id="cookie-accept"> <div class="row"> <div class="col-sm-9 col-md-10"> <p class="text-muted credit navbar-left"> By visiting this site, you accept the use of cookies 🍪 to improve the quality of your visit, offer you adapted services as well as social sharing options. <a href="./legal" target="_blank">Know more</a>. </p> </div> <div class="col-sm-3 col-md-2"> <a href="#" class="btn btn-default pull-right" id="cookie-accept-button">I accept 👍</a> </div> </div> </div> </nav> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ <script> jQuery(function($) { function getHostName(url) { var match = url.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i); if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) { return match[2]; } else { return null; } } function getDomain(url) { var hostName = getHostName(url); var domain = hostName; if (hostName != null) { var parts = hostName.split('.').reverse(); if (parts != null && parts.length > 1) { domain = parts[1] + '.' + parts[0]; if (hostName.toLowerCase().indexOf('.co.uk') != -1 && parts.length > 2) { domain = parts[2] + '.' + domain; } } } return domain; } function checkCookieEu() { var consent = getCookieEu("COOKIE_CONSENT"); if (consent == null || consent == "" || consent == undefined) { $('#cookie-directive-container').show(); } } function setCookieEu(c_name,value,exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie = c_name + "=" + c_value + ";domain=" + getDomain(window.location.href) + ";path=/"; $('#cookie-directive-container').hide('slow'); } function getCookieEu(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } checkCookieEu(); $("#cookie-accept-button").click(function() { setCookieEu("COOKIE_CONSENT", 1, 365); }); }); </script>