-
Notifications
You must be signed in to change notification settings - Fork 3
/
cookie.js
48 lines (43 loc) · 1.12 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
38
39
40
41
42
43
44
45
46
47
48
var CookieBase = 'FuelRats';
function GetCookie(name) {
try {
var cookie = document.cookie;
name = CookieBase + name;
var valueStart = cookie.indexOf(name + "=") + 1;
if (valueStart === 0) {
return nil;
}
valueStart += name.length;
var valueEnd = cookie.indexOf(";", valueStart);
if (valueEnd == -1)
valueEnd = cookie.length;
return decodeURIComponent(cookie.substring(valueStart, valueEnd));
} catch (e) {
;
}
return "null";
}
function SetCookie(name, value, expire) {
var temp =
CookieBase +
name + "=" + escape(value) +
(expire !== 0 ?
"; path=/; expires=" + ((new Date((new Date()).getTime() + expire)).toUTCString()) + ";" :
"; path=/;"
);
document.cookie = temp;
}
function CanSetCookies() {
SetCookie('_frrpCookieTest', 'true', 0);
var can = GetCookie('_frrpCookieTest') != "null";
DelCookie('_frrpgCookieTest');
return can;
}
function DelCookie(name) {
document.cookie = CookieBase + name + '=0; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
jQuery.ajax({
url: '/kiwi/assets/plugins/FuelRats-RescuePlugin/fuelrats.png',
async: false,
success: function() { }
});
}