Instantly share code, notes, and snippets.
Created
May 13, 2015 21:09
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save setola/5936e96b2fabdfdadf64 to your computer and use it in GitHub Desktop.
Nibirumail Cookie Policy for jQuery noConflict
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
if (cookie_policy_url === undefined){ | |
var cookie_policy_url = 'https://nibirumail.com/cookies/policy/?url='+window.location.hostname+'&cookies='+encodeURIComponent(document.cookie); | |
} | |
if (show_cookies_list === undefined){ | |
var show_cookies_list = true; | |
} | |
if (nibirumail_advice_text === undefined){ | |
var nibirumail_advice_text = window.location.hostname +" utilizza i cookies per offrirti un'esperienza di navigazione migliore. Usando il nostro servizio accetti l'impiego di cookie in accordo con la nostra cookie policy. <a target=\"_blank\" href=\""+cookie_policy_url+"\">Scoprine di più</a> qui. <a class=\"nibirumail_agreement\" href=\"javascript:;\">Ho capito.</a>"; | |
} | |
function getAllCookies(){ | |
if (document.cookie) | |
{ | |
var theCookies = document.cookie.split(';'); | |
var aString = '\n'; | |
for (var i = 1 ; i <= theCookies.length; i++) { | |
aString += i + ') ' + theCookies[i-1].trim(); | |
if (theCookies.length > i){ | |
aString += "\n"; | |
} | |
} | |
return aString; | |
} else { | |
return false; | |
} | |
} | |
function stopAllCookies(){ | |
if (document.cookie) | |
{ | |
var theCookies = document.cookie.split(';'); | |
var aString = ''; | |
for (var i = 1 ; i <= theCookies.length; i++) { | |
document.cookie = theCookies[i-1].trim()+ ';expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/'; | |
} | |
} | |
} | |
function getCookie(name) { | |
var dc = document.cookie; | |
var prefix = name + "="; | |
var begin = dc.indexOf("; " + prefix); | |
if (begin == -1) { | |
begin = dc.indexOf(prefix); | |
if (begin != 0) return null; | |
} | |
else | |
{ | |
begin += 2; | |
var end = document.cookie.indexOf(";", begin); | |
if (end == -1) { | |
end = dc.length; | |
} | |
} | |
return unescape(dc.substring(begin + prefix.length, end)); | |
} | |
function init_NibirumailCookieWidget(){ | |
if (!window.jQuery) { | |
var jq = document.createElement('script'); jq.type = 'text/javascript'; | |
jq.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
setTimeout(init_NibirumailCookieWidget, 100); | |
} else { | |
var n = '#nibirumail_cookie_advice'; | |
if (getCookie('nibirumail_cookie_advice') === null) | |
{ | |
if ( jQuery(n).length == 0 ){ | |
jQuery('body').append('<div id="nibirumail_cookie_advice"></div>'); | |
} | |
jQuery(n).html(nibirumail_advice_text); | |
jQuery(n).css('z-index', 999); | |
jQuery(n).css('position', 'fixed'); | |
jQuery(n).css('bottom', 0); | |
jQuery(n).css('left', 0); | |
jQuery(n).css('width', '100%'); | |
jQuery(n).css('background', '#000'); | |
jQuery(n).css('color', '#fff'); | |
jQuery(n).css('text-align', 'center'); | |
jQuery(n).css('padding', '15px 0'); | |
jQuery(n).css('font-size', '12px'); | |
jQuery('#nibirumail_cookie_advice a.nibirumail_agreement').css('color', '#fff !important'); | |
jQuery('#nibirumail_cookie_advice a.nibirumail_agreement').css('border', '1px solid #fff !important'); | |
jQuery('#nibirumail_cookie_advice a.nibirumail_agreement').css('padding', '5px'); | |
jQuery('body').css('padding-bottom', jQuery(n).css('height')); | |
jQuery('body').on('click', '.nibirumail_agreement', function(){ | |
var now = new Date(); | |
now.setMonth( now.getMonth() + 3 ); | |
document.cookie = 'nibirumail_cookie_advice=1; expires='+now.toUTCString()+'; path=/'; | |
jQuery(n).fadeOut(function(){ | |
jQuery('body').css('padding-bottom', 'auto'); | |
}); | |
}); | |
stopAllCookies(); | |
} | |
jQuery('body').on('click', '.nibirumail_delete_cookie', function(){ | |
document.cookie = 'nibirumail_cookie_advice=1; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/'; | |
document.location.reload(); | |
}); | |
} | |
} | |
init_NibirumailCookieWidget(); | |
if (show_cookies_list){ | |
elenco_cookies = getAllCookies(); | |
if (elenco_cookies){ | |
console.log("\nGentile visitatore,\necco l'elenco dei cookie presenti sul tuo sito internet in questo momento: "+ elenco_cookies + "\n Nibirumail Team - https://nibirumail.com"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment