css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>RJ_Cookie_Compliance</h1>
<hr />
<div id="notifier"><p class="notset">Cookie not set!</p></div>
<p>
  <button onclick="_rj_compliance.remove()">Reset Cookie</button>
</p>
<p>You have to hit rerun by yourself since codepen doesn't allow location&#46reload();</p>

<!-- 
  The Javascript creates it all so you just have to use the script.

  you only have to call, or see line 152
  <script>
    _rj_compliance_settings.message = "Awesome!";
    _rj_compliance.__construct();
  </script>
-->
            
          
!
            
              #_rj_compliance {
  color: #fff;
  margin: 0 40px;
  padding: 10px 50px 0;
	background-color: rgba(0,0,0,0.85);
	text-align: center;
	}
	#_rj_compliance_container {
		text-align: left;
		margin: 0 auto;
		}
		._rj_compliance_message {
			min-height: 48px;
		}
		#_rj_compliance ._rj_compliance_comment {
			margin-right: 180px;
		}
		#_rj_compliance ._rj_compliance_buttons {
			text-align: right;
			float: right;
			width: 150px;
			vertical-align: top;
			margin: 0;
			}
			#_rj_compliance ._rj_compliance_buttons a {
				margin-left: 10px;
				cursor: pointer;
			}
	
/*
  Not needed for this to work,
  Just some styling.
*/
.notset {
  font-weight: 400;
  color: #f00;
}
.accepted {
  font-weight: 400;
  color: #6f6;
}
.denied {
  font-weight: 400;
  color: #f00;
}
html, body {
  margin :0;
  padding: 0;
  text-align: center;
}
h1 {
  font-family: 'open sans', sans-serif;
  font-weight: 100;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #333;
}
hr {
  margin: 0 auto 50px;
  width: 40px;
  border: 0;
  border-bottom: 1px solid #666;
}
#_rj_compliance {
  font-family: arial;
  font-size: 0.9em;
}
a {
  color: #fff;
}
button {
  cursor: pointer;
}
p, button {
  font-family: 'open sans', sans-serif;
  font-size: 1em;
  font-weight: 100;
}

            
          
!
            
              /*	==========================================================================		
		
		Cookie Compliance Script of Awesomenes. 
		this script is made for RoaldJoosen.nl as an experiment. 
		
		Date	: Sept 06 2013
		Author	: Roald Joosen
		E-mail	: info@roaldjoosen.nl
		Website : www.roaldjoosen.nl
		
	========================================================================== */

/*
		Settings can be overwritten:
		_rj_compliance_settings.message = 'Yum yum, cookies';
		when using buttons they can be triggerd from anywhere by using _rj_compliance.accept() and _rj_compliance.decline()
	*/
var _rj_compliance_settings = {
  cookie_name: null,
  url: null,
  message: null,
  buttons: null,
  cookie_set: null
};

/*
		The code down here should not be touched, except i've you are me (Roald Joosen), or you have my permission.
	*/
var _rj_compliance = {
  __construct: function() {

    // Create element at the end of the document
    this.createContainer();

    // Set default variables
    this.defaultVars();

    // Filtering the reference domain down to the start e.q. roaldjoosen.nl
    var ref = '';
    if (document.referrer) {
      ref = document.referrer.split("://");
      ref = ref[1].split("/");
      ref = ref[0];
    }

    //Check if compliance cookie was set
    var compliance = _rj_compliance_getCookie(_rj_compliance_settings.cookie_name);
    _rj_compliance_settings.cookie_set = compliance;

    //Test compliance cookie value to 0 and 1 or check if reference domain equals current domain
    if (compliance == 1) {
      //Do nothing
    } else if (compliance == 0) {
      //Do nothing
    } else if (ref.indexOf(document.location.hostname) != -1 && window.location.pathname.indexOf(_rj_compliance_settings.url) == -1) {
      //Set cookie when a click through is done
      _rj_compliance_setCookie(_rj_compliance_settings.cookie_name, 1, 25 * 356);
    } else {
      //Show cookie compliance
      this.init();
    }
  },
  init: function() {
    this.popup();
  },
  defaultVars: function() {
    //Loop through the settings and give them there default value when they are not set by the user.
    for (var key in _rj_compliance_settings) {
      if (_rj_compliance_settings.hasOwnProperty(key)) {

        switch (key) {
          case 'cookie_name':
            _rj_compliance_settings[key] = (_rj_compliance_settings[key]) ? _rj_compliance_settings[key] : '_rj_compliance';
            break;
          case 'url':
            _rj_compliance_settings[key] = (_rj_compliance_settings[key]) ? _rj_compliance_settings[key] : '/cookie-compliance.html';
            break;
          case 'message':
            _rj_compliance_settings[key] = (_rj_compliance_settings[key]) ? _rj_compliance_settings[key] : '<strong>Hello</strong>, I\'m using cookies. Read more about my <a href="' + _rj_compliance_settings.url + '">Cookies,</a>.';
            break;
          case 'buttons':
            _rj_compliance_settings[key] = (_rj_compliance_settings[key]) ? _rj_compliance_settings[key] : '<a onclick="_rj_compliance.accept()" class="accept button">Accept</a> <a onclick="_rj_compliance.decline()">Decline</a>';
            break;
        }
      }
    }
  },
  popup: function() {
    //Build html for message and buttons and insert into compliance container
    var msg = '<p class="_rj_compliance_message">' + _rj_compliance_settings.message + '</p>',
      bttns = '<p class="_rj_compliance_buttons">' + _rj_compliance_settings.buttons + '</p>',
      container = document.getElementById("_rj_compliance");
    container.innerHTML = '<div id="_rj_compliance_container">' + bttns + msg + '</div>';
  },
  accept: function() {
    //Remove complaince containers html and set compliance cookie to 1
    var container = document.getElementById("_rj_compliance");
    container.innerHTML = "";
    _rj_compliance_setCookie('_rj_compliance', 1, 25 * 356);
  },
  decline: function() {
    //Remove complaince containers html and set compliance cookie to 0
    var container = document.getElementById("_rj_compliance");
    container.innerHTML = "";
    _rj_compliance_setCookie(_rj_compliance_settings.cookie_name, 0, 25 * 356);
  },
  remove: function() {
    _rj_compliance_deleteDookie(_rj_compliance_settings.cookie_name);
  },
  createContainer: function() {
    var container = document.createElement('div');
    container.setAttribute('id', '_rj_compliance');
    document.body.appendChild(container);
  }
};

/*
		Cookie functions
	*/
function _rj_compliance_setCookie(n, v, e) {
  //Make experation date
  var x = new Date();
  x.setDate(x.getDate() + e);
  var c = escape(v) + ((e == null) ? "" : "; expires=" + x.toUTCString());

  //Set cookie
  document.cookie = n + "=" + c + ";domain=" + document.location.hostname + ";path=/";
}

function _rj_compliance_getCookie(n) {
  //Retrieve cookie string
  var i, x, y, ARRcookies = document.cookie.split(";");

  //Loop through cookies
  for (i = 0; i < ARRcookies.length; i++) {
    //Split cookies to key > value
    x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
    y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
    x = x.replace(/^\s+|\s+$/g, "");

    //when keys match return value
    if (x == n) return unescape(y);
  }
}

function _rj_compliance_deleteDookie(n) {
  document.cookie = n + "=;domain=" + document.location.hostname + ";path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT";
}

//Make it run for the demo
//_rj_compliance_settings.message = "Awesome!";
_rj_compliance.__construct();

if (_rj_compliance_settings.cookie_set == 1) {
  $('#notifier p').attr('class', 'accepted').text('Cookie Accepted');
} else if (_rj_compliance_settings.cookie_set == 0) {
  $('#notifier p').attr('class', 'denied').text('Cookie Denied');
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console