mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Share createCookie
and readCookie
methods.
This commit is contained in:
parent
7038f9a61d
commit
34edba3adf
3 changed files with 35 additions and 50 deletions
|
@ -26,28 +26,8 @@ require('/jquery');
|
|||
JSON = require('/json2');
|
||||
require('/undo-xpopup');
|
||||
|
||||
function createCookie(name,value,days)
|
||||
{
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
var expires = "; expires="+date.toGMTString();
|
||||
}
|
||||
else var expires = "";
|
||||
document.cookie = name+"="+value+expires+"; path=/";
|
||||
}
|
||||
|
||||
function readCookie(name)
|
||||
{
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var createCookie = require('/pad_utils').createCookie;
|
||||
var readCookie = require('/pad_utils').readCookie;
|
||||
|
||||
function randomString() {
|
||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue