-
Notifications
You must be signed in to change notification settings - Fork 1
/
cookie.js
37 lines (31 loc) · 1.02 KB
/
cookie.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
//cookie
(function () {
function setCookie(cName, cValue, cDay) {
var expire = new Date();
expire.setDate(expire.getDate() + cDay);
cookies = cName + '=' + escape(cValue) + '; path=/ ';
if (typeof cDay != 'undefined') cookies += ';expires=' + expire.toGMTString() + ';';
document.cookie = cookies;
}
function getCookie(cName) {
cName = cName + '=';
var cookieData = document.cookie;
var start = cookieData.indexOf(cName);
var cValue = '';
if (start != -1) {
start += cName.length;
var end = cookieData.indexOf(';', start);
if (end == -1) end = cookieData.length;
cValue = cookieData.substring(start, end);
}
return unescape(cValue);
}
var cookie = getCookie("darkMode");
if (cookie == "true") {
setCookie("darkMode", "fales", 10000);
window.location.reload();
} else {
//None
setCookie("darkMode", "true", 10000);
}
})();