Advertisement
Guest User

Untitled

a guest
May 29th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     addLoadEvent();
  3. });
  4.  
  5. function addLoadEvent() {
  6.     var oldonload = window.onload;
  7.  
  8.     console.log(typeof window.onload != 'function');
  9.     if (typeof window.onload != 'function') {
  10.         window.onload = cookiesAccept;
  11.     } else {
  12.         window.onload = function() {
  13.             if (oldonload) { oldonload(); }
  14.             cookiesAccept();
  15.         }
  16.     }
  17. }
  18.  
  19. function cookiesAccept() {
  20.  
  21.     checkCookie();
  22.  
  23.     function getCookie(c_name) {
  24.         var i, x, y, ARRcookies = document.cookie.split(";");
  25.  
  26.         for (i = 0; i < ARRcookies.length; i++) {
  27.             x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  28.             y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  29.             x = x.replace(/^\s+|\s+$/g,"");
  30.             if (x == c_name) { return unescape(y); }
  31.         }
  32.     }
  33.  
  34.     function setCookie() {
  35.         var exdate = new Date();
  36.         exdate.setDate(exdate.getDate() + 365);
  37.         var c_value = escape('1') + ((365==null) ? "" : "; expires=" + exdate.toUTCString());
  38.         document.cookie = 'cookies_info' + "=" + c_value;
  39.  
  40.         document.getElementById('cookie_info').style.display = 'none';
  41.     }
  42.  
  43.     function checkCookie() {
  44.         var cookies_info = getCookie("cookies_info");
  45.         if (cookies_info == null || cookies_info == "") {
  46.  
  47.             var cookiesContainer = document.createElement("div");
  48.                 cookiesContainer.setAttribute("class", "container-fluid");
  49.                 cookiesContainer.setAttribute("id", "cookie_info");
  50.                 cookiesContainer.innerHTML = '<div class="user_information container"><div class="row"><div class="col-md-8 col-xs-12">Ta strona używa ciasteczek.......</div><div class="pull-right col-md-2 col-xs-6 button-cookies"><button class="btn btn-default"><a id="close_info_cookie">zgadzam się</a></butotn></div><div class="pull-right col-md-2 col-xs-6 button-cookies"><button class="btn btn-default"><a href="/privacy_policy" title="polityka prywatności">polityka prywatności</a></butotn></div>';
  51.  
  52.             document.getElementsByTagName("body").item(0).appendChild(cookiesContainer);
  53.  
  54.  
  55.             var element = document.getElementById('close_info_cookie');
  56.  
  57.             if (element.addEventListener) { element.addEventListener('click', function() { setCookie() } , false); }
  58.             else if (element.attachEvent) { element.attachEvent('onclick', function() { setCookie() }); }
  59.  
  60.         }
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement