(function() { var c, closeWidget, container, cook, createWidget, domain, getCookie, setCookie; domain = 'https://cookie-widget.ru/'; cook = '___cookie_accept'; container = document.createElement('div'); setCookie = function(k, v, date) { var c; domain = ' domain=' + domain + ';'; cook = k + "=" + v + '; expires=' + new Date(date ? date : new Date().getTime() + 5184000000).toGMTString() + '; path=/;'; document.cookie = cook + domain; c = getCookie('k'); if (c !== v) { document.cookie = cook; } return cook; }; getCookie = function(name) { var pattern, regexp; pattern = "(?:; )?" + name + "=([^;]*);?"; regexp = new RegExp(pattern); if (regexp.test(document.cookie)) { return decodeURIComponent(RegExp["$1"]); } return false; }; c = getCookie(cook); if (!c) { closeWidget = function() { setCookie(cook, 1); return container.remove(); }; createWidget = function() { var style; console.log('create widget'); style = document.createElement('link'); style.setAttribute('rel', 'stylesheet'); style.setAttribute('type', 'text/css'); style.setAttribute('href', domain + '/widget/style.css'); style.addEventListener('load', function() { var accept, btns, close, conf, content, label; container.setAttribute('id', '___cookie_widget'); container.setAttribute('class', '___cookie_widget_style_1'); close = document.createElement('div'); close.setAttribute('id', '___cookie_widget_close'); close.innerText = 'x'; close.addEventListener('click', closeWidget); accept = document.createElement('button'); accept.setAttribute('type', 'button'); accept.setAttribute('id', '___cookie_widget_accept'); accept.innerText = 'Хорошо'; accept.addEventListener('click', closeWidget); conf = document.createElement('div'); conf.setAttribute('id', '___cookie_widget_accept'); conf.innerHTML = 'Подробнее'; label = document.createElement('div'); label.innerHTML = 'CookieWidget'; btns = document.createElement('div'); btns.setAttribute('id', '___cookie_widget_btns'); content = document.createElement('div'); content.setAttribute('id', '___cookie_widget_content'); content.innerHTML = '
'; container.appendChild(close); container.appendChild(content); content.appendChild(btns); content.appendChild(btns); btns.appendChild(accept); btns.appendChild(conf); container.appendChild(label); return document.body.appendChild(container); }); return document.head.appendChild(style); }; if (document.readyState !== 'complete') { //document.addEventListener "DOMContentLoaded",-> return document.onreadystatechange = function() { if (document.readyState === 'complete') { return createWidget(); } }; } else { return createWidget(); } } })();