fix some localStorage bugs
This commit is contained in:
parent
64592e7278
commit
7f249ff12b
1 changed files with 8 additions and 10 deletions
|
@ -133,10 +133,7 @@ Ox.localStorage <o> localStorage wrapper
|
|||
({key, val}) -> <f> localStorage object
|
||||
@*/
|
||||
Ox.localStorage = function(namespace) {
|
||||
// Ox.Log calls this before Ox.isUndefined is defined
|
||||
if (localStorage === void 0) {
|
||||
localStorage = {};
|
||||
}
|
||||
window.localStorage = window.localStorage || {};
|
||||
function storage(key, val) {
|
||||
var ret, value;
|
||||
if (arguments.length == 0) {
|
||||
|
@ -146,9 +143,10 @@ Ox.localStorage = function(namespace) {
|
|||
ret[key.substr(namespace.length + 1)] = JSON.parse(val);
|
||||
}
|
||||
});
|
||||
} else if (arguments.length == 1 && !Ox.isObject(key)) {
|
||||
} else if (arguments.length == 1 && typeof key == 'string') {
|
||||
// This gets called by Ox.Log before Type.js has loaded
|
||||
value = localStorage[namespace + '.' + key];
|
||||
ret = Ox.isUndefined(value) ? void 0 : JSON.parse(value);
|
||||
ret = value === void 0 ? void 0 : JSON.parse(value);
|
||||
} else {
|
||||
args = Ox.makeObject(arguments);
|
||||
Ox.forEach(args, function(val, key) {
|
||||
|
@ -174,7 +172,7 @@ Ox.Log <f> Logging module
|
|||
@*/
|
||||
Ox.Log = (function() {
|
||||
var storage = Ox.localStorage('Ox'),
|
||||
log = storage('Log') || {filter: [], filterEnabled: true},
|
||||
log = storage('log') || {filter: [], filterEnabled: true},
|
||||
that = function() {
|
||||
var ret;
|
||||
if (arguments.length == 0) {
|
||||
|
@ -188,7 +186,7 @@ Ox.Log = (function() {
|
|||
if (!Ox.isUndefined(val)) {
|
||||
that.filter.enable();
|
||||
log.filter = Ox.toArray(val);
|
||||
storage('Log', log);
|
||||
storage('log', log);
|
||||
}
|
||||
return log.filter;
|
||||
};
|
||||
|
@ -197,11 +195,11 @@ Ox.Log = (function() {
|
|||
};
|
||||
that.filter.disable = function() {
|
||||
log.filterEnabled = false;
|
||||
storage('Log', log);
|
||||
storage('log', log);
|
||||
};
|
||||
that.filter.enable = function() {
|
||||
log.filterEnabled = true;
|
||||
storage('Log', log);
|
||||
storage('log', log);
|
||||
};
|
||||
that.filter.remove = function(val) {
|
||||
val = Ox.toArray(val);
|
||||
|
|
Loading…
Reference in a new issue