forked from pytorch/pytorch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie-banner.js
42 lines (33 loc) · 823 Bytes
/
cookie-banner.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
var cookieBanner = {
init: function() {
cookieBanner.bind();
var cookieExists = cookieBanner.cookieExists();
if (!cookieExists) {
cookieBanner.setCookie();
cookieBanner.showCookieNotice();
}
},
bind: function() {
$(".close-button").on("click", cookieBanner.hideCookieNotice);
},
cookieExists: function() {
var cookie = localStorage.getItem("returningPytorchUser");
if (cookie) {
return true;
} else {
return false;
}
},
setCookie: function() {
localStorage.setItem("returningPytorchUser", true);
},
showCookieNotice: function() {
$(".cookie-banner-wrapper").addClass("is-visible");
},
hideCookieNotice: function() {
$(".cookie-banner-wrapper").removeClass("is-visible");
}
};
$(function() {
cookieBanner.init();
});