mirror of
https://github.com/WhatCD/Gazelle.git
synced 2024-12-13 19:06:27 +00:00
24 lines
555 B
JavaScript
24 lines
555 B
JavaScript
/*
|
|
TODO: Document.
|
|
*/
|
|
"use strict";
|
|
var cookie = {
|
|
get: function (cookie_name) {
|
|
var value = document.cookie.match('(^|;)?' + cookie_name + '=([^;]*)(;|$)');
|
|
return (value) ? value[2] : null;
|
|
},
|
|
set: function (cookie_name, value, days) {
|
|
var date = new Date();
|
|
|
|
if (days === undefined) {
|
|
days = 365;
|
|
}
|
|
|
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
document.cookie = cookie_name + "=" + value + "; expires=" + date.toGMTString() + "; path=/";
|
|
},
|
|
del: function (cookie_name) {
|
|
cookie.set(cookie_name, '', -1);
|
|
}
|
|
};
|