Cookie Bar privacy policy
Created
June 5, 2015 09:43
-
-
Save lmacchiavelli/c08bb158797d4f58e707 to your computer and use it in GitHub Desktop.
Cookie Bar javascript no jquery
This file contains 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 characters
<!-- NON COMPRESSED | |
/* | |
Author: [email protected] | |
Created: 05/06/2015 | |
Licence: free | |
AVVERTENZE: Questo software è concesso a titolo gratuito, eventuali danni legali o di qualsiasi altra natura sono da attribuirsi esclusivamente all' utilizzatore di tale script e non all'autore | |
( Macchiavelli Lorenzo, [email protected] ) che concede questo script a titolo gratuito e senza nessuna garanzie sul corretto funzionamento a fini legali e software. | |
var cookieStyle = [ | |
{ | |
ID:'cookie-bar', | |
SHORT_TEXT_PRIVACY_DESCRIPTION:'Questo sito usa cookie per fornirti un\'esperienza migliore. Proseguendo la navigazione accetti l\'utilizzo dei cookie da parte nostra.', | |
STYLE:'background:#000;padding:20px;width:100%;position:fixed;z-index:10000;box-sizing:border-box;-webkit-box-shadow: 0px 3px 12px 0px rgba(50, 50, 50, 0.75);-moz-box-shadow:0px 3px 12px 0px rgba(50, 50, 50, 0.75);box-shadow:0px 3px 12px 0px rgba(50, 50, 50, 0.75);' | |
}, | |
{ | |
ID:'cookie-button', | |
LINK:'/privacy-policy-page', | |
TEXT:'Approfondisci qui', | |
HOVER:'rgb(236, 236, 236)', | |
STYLE:'text-decoration:none;padding:3px 10px; background:silver;border-radius: 2px 2px 2px 2px;-moz-border-radius: 2px 2px 2px 2px;-webkit-border-radius: 2px 2px 2px 2px;float:right;cursor:pointer;color:#000;margin-right:10px;' | |
}, | |
{ | |
ID:'cookie-ok-button', | |
TEXT:'OK', | |
STYLE:'padding:3px 10px; background:red;border-radius: 2px 2px 2px 2px;-moz-border-radius: 2px 2px 2px 2px;-webkit-border-radius: 2px 2px 2px 2px;float:right;cursor:pointer;color:#fff;' | |
} | |
],data = cookieStyle; | |
window.onload = checkCookieBar(); | |
function initBar() { | |
var cookieBar = document.createElement('div'); | |
cookieBar.id = data[0].ID; | |
cookieBar.innerHTML ='<style>#' + data[1].ID + ' :hover{ background-color:'+data[1].HOVER + '!important; float:left; text-decoration:underline;}#'+data[0].ID+' p{color:#fff;float:left; padding:0px; margin:0px;}</style><p>'+data[0].SHORT_TEXT_PRIVACY_DESCRIPTION+'</p><a onclick="setCookieBar()" href="javascript:void(0);" style="'+data[2].STYLE+'" id="' + data[2].ID + '">'+data[2].TEXT+'</a><a style="' + data[1].STYLE + '" id="' + data[1].ID + '" href="'+data[1].LINK+'">'+ data[1].TEXT +'</a>' | |
cookieBar.setAttribute("style", data[0].STYLE); | |
document.getElementsByTagName('body')[0].appendChild(cookieBar); | |
} | |
function checkCookieBar(){ | |
var privacy_check=getCookie("privacy_policy_confirmation"); | |
if (privacy_check!="") { | |
} | |
else{ | |
initBar(); | |
} | |
} | |
function setCookieBar(){ | |
var date = new Date(); | |
date.setTime(date.getTime()+31536000000); | |
document.cookie = 'privacy_policy_confirmation=1; expires=' + date.toGMTString() + '; path=/'; | |
alert(document.cookie); | |
} | |
function getCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for(var i=0; i<ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0)==' ') c = c.substring(1); | |
if (c.indexOf(name) == 0) return c.substring(name.length,c.length); | |
} | |
return ""; | |
} | |
--> |
This file contains 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 characters
/* | |
Author: [email protected] | |
Created: 05/06/2015 | |
Licence: free | |
AVVERTENZE: Questo software è concesso a titolo gratuito, eventuali danni legali o di qualsiasi altra natura sono da attribuirsi esclusivamente all' utilizzatore di tale script e non all'autore | |
( Macchiavelli Lorenzo, [email protected] ) che concede questo script a titolo gratuito e senza nessuna garanzie sul corretto funzionamento a fini legali e software. | |
*/ | |
var cookieStyle = [ | |
{ | |
ID:'cookie-bar', | |
SHORT_TEXT_PRIVACY_DESCRIPTION:'Questo sito usa cookie per fornirti un\'esperienza migliore. Proseguendo la navigazione accetti l\'utilizzo dei cookie da parte nostra.', | |
STYLE:'background:#000;padding:20px;width:100%;position:fixed;z-index:10000;box-sizing:border-box;-webkit-box-shadow: 0px 3px 12px 0px rgba(50, 50, 50, 0.75);-moz-box-shadow:0px 3px 12px 0px rgba(50, 50, 50, 0.75);box-shadow:0px 3px 12px 0px rgba(50, 50, 50, 0.75);' | |
}, | |
{ | |
ID:'cookie-button', | |
LINK:'/privacy-policy-page', | |
TEXT:'Approfondisci qui', | |
HOVER:'rgb(236, 236, 236)', | |
STYLE:'text-decoration:none;padding:3px 10px; background:silver;border-radius: 2px 2px 2px 2px;-moz-border-radius: 2px 2px 2px 2px;-webkit-border-radius: 2px 2px 2px 2px;float:right;cursor:pointer;color:#000;margin-right:10px;' | |
}, | |
{ | |
ID:'cookie-ok-button', | |
TEXT:'OK', | |
STYLE:'padding:3px 10px; background:red;border-radius: 2px 2px 2px 2px;-moz-border-radius: 2px 2px 2px 2px;-webkit-border-radius: 2px 2px 2px 2px;float:right;cursor:pointer;color:#fff;' | |
} | |
],data = cookieStyle; | |
function initBar(){var t=document.createElement("div") | |
t.id=data[0].ID,t.innerHTML="<style>#"+data[1].ID+" :hover{ background-color:"+data[1].HOVER+"!important; float:left; text-decoration:underline;}#"+data[0].ID+" p{color:#fff;float:left; padding:0px; margin:0px;}</style><p>"+data[0].SHORT_TEXT_PRIVACY_DESCRIPTION+'</p><a onclick="setCookieBar()" href="javascript:void(0);" style="'+data[2].STYLE+'" id="'+data[2].ID+'">'+data[2].TEXT+'</a><a style="'+data[1].STYLE+'" id="'+data[1].ID+'" href="'+data[1].LINK+'">'+data[1].TEXT+"</a>",t.setAttribute("style",data[0].STYLE),document.getElementsByTagName("body")[0].appendChild(t)}function checkCookieBar(){var t=getCookie("privacy_policy_confirmation") | |
""!=t||initBar()}function setCookieBar(){var t=new Date | |
t.setTime(t.getTime()+31536e6),document.cookie="privacy_policy_confirmation=1; expires="+t.toGMTString()+"; path=/"}function getCookie(t){for(var e=t+"=",a=document.cookie.split(";"),o=0;o<a.length;o++){for(var i=a[o];" "==i.charAt(0);)i=i.substring(1) | |
if(0==i.indexOf(e))return i.substring(e.length,i.length)}return""}window.onload=checkCookieBar(); |
This file contains 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 characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains 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 characters
body{ | |
margin:0px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment