mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-04 05:52:44 +08:00
06274c6a7c
Fixed owncloud password encoder/decoder (#291) Fixed ckeditor in ownCloud iframe (Closes #302) Release commit
100 lines
No EOL
1.6 KiB
JavaScript
100 lines
No EOL
1.6 KiB
JavaScript
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
var
|
|
$ = require('$'),
|
|
JSON = require('JSON'),
|
|
|
|
Consts = require('Common/Consts'),
|
|
Utils = require('Common/Utils')
|
|
;
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
function CookieLocalDriver()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @static
|
|
* @return {boolean}
|
|
*/
|
|
CookieLocalDriver.supported = function ()
|
|
{
|
|
return !!(window.navigator && window.navigator.cookieEnabled);
|
|
};
|
|
|
|
/**
|
|
* @param {string} sKey
|
|
* @param {*} mData
|
|
* @return {boolean}
|
|
*/
|
|
CookieLocalDriver.prototype.set = function (sKey, mData)
|
|
{
|
|
var
|
|
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
|
bResult = false,
|
|
mResult = null
|
|
;
|
|
|
|
try
|
|
{
|
|
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
|
}
|
|
catch (oException) {}
|
|
|
|
if (!mResult)
|
|
{
|
|
mResult = {};
|
|
}
|
|
|
|
mResult[sKey] = mData;
|
|
|
|
try
|
|
{
|
|
$.cookie(Consts.Values.ClientSideStorageIndexName, JSON.stringify(mResult), {
|
|
'expires': 30
|
|
});
|
|
|
|
bResult = true;
|
|
}
|
|
catch (oException) {}
|
|
|
|
return bResult;
|
|
};
|
|
|
|
/**
|
|
* @param {string} sKey
|
|
* @return {*}
|
|
*/
|
|
CookieLocalDriver.prototype.get = function (sKey)
|
|
{
|
|
var
|
|
mStorageValue = $.cookie(Consts.Values.ClientSideStorageIndexName),
|
|
mResult = null
|
|
;
|
|
|
|
try
|
|
{
|
|
mResult = null === mStorageValue ? null : JSON.parse(mStorageValue);
|
|
if (mResult && !Utils.isUnd(mResult[sKey]))
|
|
{
|
|
mResult = mResult[sKey];
|
|
}
|
|
else
|
|
{
|
|
mResult = null;
|
|
}
|
|
}
|
|
catch (oException) {}
|
|
|
|
return mResult;
|
|
};
|
|
|
|
module.exports = CookieLocalDriver;
|
|
|
|
}()); |