We originally wrote `undefined` in CoffeeScript. CoffeeScript compiled it to `void 0` when generating the JavaScript files. However, the reason to do so was the `undefined` variable was mutable before ECMAScript 5. Using `undefined` is more intuitive, and nowadays there's no reason to use `void 0`.
33 lines
932 B
JavaScript
33 lines
932 B
JavaScript
(function() {
|
|
"use strict";
|
|
App.Cookies = {
|
|
saveCookie: function(name, value, days) {
|
|
var date, expires;
|
|
expires = undefined;
|
|
if (days) {
|
|
date = new Date;
|
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
expires = "; expires=" + date.toGMTString();
|
|
} else {
|
|
expires = "";
|
|
}
|
|
document.cookie = name + "=" + value + expires + "; path=/";
|
|
},
|
|
getCookie: function(name) {
|
|
var c_end, c_start;
|
|
if (document.cookie.length > 0) {
|
|
c_start = document.cookie.indexOf(name + "=");
|
|
if (c_start !== -1) {
|
|
c_start = c_start + name.length + 1;
|
|
c_end = document.cookie.indexOf(";", c_start);
|
|
if (c_end === -1) {
|
|
c_end = document.cookie.length;
|
|
}
|
|
return unescape(document.cookie.substring(c_start, c_end));
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
};
|
|
}).call(this);
|