-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.js
36 lines (30 loc) · 826 Bytes
/
utils.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
function $(e) { return document.getElementById(e); }
function setcookie(name,value,expiredays) {
var d = new Date();
d.setTime(d.getTime()+(expiredays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = name + "=" + value + "; " + expires;
}
function getcookie(name) {
var n = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(n.length,c.length);
}
return "";
}
function erasecookie(name) {
setcookie(name,"",-1);
}
Array.prototype.unique = function(){
var u = {}, a = [];
for(var i = 0, l = this.length; i < l; ++i){
if(u.hasOwnProperty(this[i])) {
continue;
}
a.push(this[i]);
u[this[i]] = 1;
}
return a;
}