snappymail/dev/Storage/Settings.js

47 lines
905 B
JavaScript
Raw Normal View History

2015-11-15 08:23:16 +08:00
2016-07-02 06:49:59 +08:00
import window from 'window';
2016-06-07 05:57:52 +08:00
import {isUnd, isNormal, isArray, inArray} from 'Common/Utils';
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
let SETTINGS = window.__rlah_data() || null;
SETTINGS = isNormal(SETTINGS) ? SETTINGS : {};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
let APP_SETTINGS = SETTINGS.System || null;
APP_SETTINGS = isNormal(APP_SETTINGS) ? APP_SETTINGS : {};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {*}
2016-06-16 07:36:44 +08:00
*/
export function settingsGet(name)
{
return isUnd(SETTINGS[name]) ? null : SETTINGS[name];
}
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
* @param {*} value
*/
export function settingsSet(name, value)
{
SETTINGS[name] = value;
}
2016-04-30 07:42:18 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {*}
2016-06-16 07:36:44 +08:00
*/
export function appSettingsGet(name)
{
return isUnd(APP_SETTINGS[name]) ? null : APP_SETTINGS[name];
2015-11-15 08:23:16 +08:00
}
2016-06-16 07:36:44 +08:00
/**
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {boolean}
2016-06-16 07:36:44 +08:00
*/
export function capa(name)
{
const values = settingsGet('Capa');
return isArray(values) && isNormal(name) && -1 < inArray(name, values);
}