-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie.min.js
1 lines (1 loc) · 1.58 KB
/
cookie.min.js
1
"use strict";function getAlertTemplate(){return'<div id="cookie-info" style="background-color:#fff;padding-top:15px;font-size:14px;text-align:center;border:2px solid #000;max-width: 1260px;margin: 0 auto;"><span>This website uses "cookies" to give you best experience. Continue using this website means you have no problem with this.</span><a id="cookie-learn-more" style="border-bottom: solid 1px;" target="_blank" href="http://wikipedia.org/wiki/HTTP_cookie"> Learn more about "cookie"? </a><br/><button id="accept-cookies" style="padding: 10px;margin-bottom: 15px;font-size: 16px;">Continue</button></div>'}function showCookieAlert(){var e=document.createElement("div");e.style.position="fixed",e.style.bottom=0,e.style.left=0,e.style.right=0,e.style.zIndex=999,e.style.width="100%",e.style.textAlign="center",e.innerHTML=getAlertTemplate(),document.body.appendChild(e)}function setCookie(e,t,o){var i=new Date;i.setTime(i.getTime()+24*o*60*60*1e3);var n="expires="+i.toUTCString();document.cookie=e+"="+t+";"+n+";path=/"}function getCookie(e){for(var t=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var n=o[i];" "==n.charAt(0);)n=n.substring(1);if(0==n.indexOf(t))return n.substring(t.length,n.length)}return""}function checkCookie(){""==getCookie("cookies-accepted")&&showCookieAlert()}document.addEventListener("click",function(e){"accept-cookies"==e.target.id&&(setCookie("cookies-accepted","1",1825),document.getElementById("cookie-info").style.display="none")},!1),document.addEventListener("DOMContentLoaded",function(e){if(null==document.getElementById("accept-cookies"))return checkCookie()},!1);