-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookieconsent.js
54 lines (54 loc) · 1.77 KB
/
cookieconsent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function GetCookie(name) {
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cookie.substring(i,j)==arg)
return "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
function testFirstCookie(){
var offset = new Date().getTimezoneOffset();
if ((offset >= -180) && (offset <= 240)) { //Europe and America
var visit=GetCookie("cookieCompliancyAccepted");
if (visit==null){
$("#myCookieConsent").fadeIn(800); // Show warning
} else {
// Already accepted
}
}
var offset = new Date().getTimezoneOffset();
if ((offset >= -180) && (offset <= 240)) { //Europe and America
var visit=GetCookie("saveBannerClosed");
console.log(visit);
if (visit==null){
console.log("show");
$("#savebanner").show(); // Show banner
} else {
console.log("hide");
$("#savebanner").hide(); //hidden
}
}
}
$(document).ready(function(){
$("#cookieButton").click(function(){
console.log('Understood');
var expire=new Date();
expire=new Date(expire.getTime()+7776000000);
document.cookie="cookieCompliancyAccepted=here; expires="+expire+";path=/";
$("#myCookieConsent").hide(800);
});
$("#denySaveBanner").click(function(){
console.log('Save Banner Closed');
var expire=new Date();
expire=new Date(expire.getTime()+604800000);
document.cookie="saveBannerClosed=here; expires="+expire+";path=/";
$("#savebanner").hide();
});
testFirstCookie();
});