mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(config) add mapCondition
This commit is contained in:
parent
df122dbcbe
commit
4b5110bb51
1 changed files with 23 additions and 5 deletions
|
|
@ -170,15 +170,33 @@ var CloudCmd, Util, DOM, io;
|
|||
};
|
||||
|
||||
function changeConfig(config) {
|
||||
Object.keys(config).forEach(function(name) {
|
||||
var item = config[name],
|
||||
isBool = Util.type.boolean(item);
|
||||
var array = Object.keys(config);
|
||||
|
||||
mapCondition(array, function(name) {
|
||||
var type = typeof config[name],
|
||||
is = type === 'boolean';
|
||||
|
||||
if (isBool)
|
||||
config[name] = setState(item);
|
||||
return is;
|
||||
}).forEach(function(name) {
|
||||
var item = config[name];
|
||||
|
||||
config[name] = setState(item);
|
||||
});
|
||||
}
|
||||
|
||||
function mapCondition(array, fn) {
|
||||
var result = [];
|
||||
|
||||
array.forEach(function(item) {
|
||||
var is = fn(item);
|
||||
|
||||
if (is)
|
||||
result.push(item);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function setState(state) {
|
||||
var ret = '';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue