update Ox.Log
This commit is contained in:
parent
dce2843303
commit
8ef45bb1cb
2 changed files with 21 additions and 20 deletions
|
@ -117,6 +117,7 @@ Ox.Theme = (function() {
|
|||
});
|
||||
});
|
||||
}
|
||||
localStorage && localStorage.OxTheme = theme;
|
||||
return that;
|
||||
}
|
||||
|
||||
|
@ -142,4 +143,4 @@ Ox.Theme = (function() {
|
|||
|
||||
return that;
|
||||
|
||||
}());
|
||||
}());
|
||||
|
|
|
@ -122,48 +122,48 @@ Ox.load = function() {
|
|||
};
|
||||
|
||||
Ox.Log = (function() {
|
||||
var filter = localStorage && localStorage.filter
|
||||
? JSON.parse(localStorage.filter)
|
||||
: {enabled: true, matches: []},
|
||||
var log = localStorage && localStorage.OxLog
|
||||
? JSON.parse(localStorage.OxLog)
|
||||
: {enabled: false, filter: []},
|
||||
that = function() {
|
||||
return that.log.apply(null, arguments);
|
||||
};
|
||||
function saveFilter() {
|
||||
function save() {
|
||||
if (localStorage) {
|
||||
localStorage.filter = JSON.stringify(filter);
|
||||
localStorage.OxLog = JSON.stringify(log);
|
||||
}
|
||||
}
|
||||
that.disable = function() {
|
||||
log.enabled = false;
|
||||
save();
|
||||
};
|
||||
that.enable = function() {
|
||||
log.enabled = true;
|
||||
save();
|
||||
};
|
||||
that.filter = function(val) {
|
||||
var ret;
|
||||
if (Ox.isUndefined(val)) {
|
||||
ret = filter.matches;
|
||||
ret = log.filter;
|
||||
} else {
|
||||
filter.matches = Ox.toArray(val);
|
||||
saveFilter();
|
||||
log.filter = Ox.toArray(val);
|
||||
save();
|
||||
ret = that;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
that.filter.add = function(val) {
|
||||
return that.filter(Ox.unique(Ox.merge(filter, Ox.toArray(val))));
|
||||
};
|
||||
that.filter.disable = function() {
|
||||
filter.enabled = false;
|
||||
saveFilter();
|
||||
};
|
||||
that.filter.enable = function() {
|
||||
filter.enabled = true;
|
||||
saveFilter();
|
||||
return that.filter(Ox.unique(Ox.merge(log.filter, Ox.toArray(val))));
|
||||
};
|
||||
that.filter.remove = function(val) {
|
||||
val = Ox.toArray(val);
|
||||
return that.filter(filter.matches.filter(function(v) {
|
||||
return that.filter(log.filter.filter(function(v) {
|
||||
return val.indexOf(v) == -1;
|
||||
}));
|
||||
};
|
||||
that.log = function log() {
|
||||
var args = Ox.makeArray(arguments), date, ret;
|
||||
if (!filter.enabled || filter.matches.indexOf(args[0]) > -1) {
|
||||
if (log.enabled && log.filter.indexOf(args[0]) > -1) {
|
||||
date = new Date();
|
||||
args.unshift(
|
||||
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().substr(-3),
|
||||
|
|
Loading…
Reference in a new issue