From 8ef45bb1cb7317f2df7e6ab42edd78cfa1213217 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 4 Nov 2011 16:04:46 +0000 Subject: [PATCH] update Ox.Log --- source/Ox.UI/js/Core/Ox.Theme.js | 3 ++- source/Ox/js/Core.js | 38 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Theme.js b/source/Ox.UI/js/Core/Ox.Theme.js index db2f91d0..e0aa2134 100644 --- a/source/Ox.UI/js/Core/Ox.Theme.js +++ b/source/Ox.UI/js/Core/Ox.Theme.js @@ -117,6 +117,7 @@ Ox.Theme = (function() { }); }); } + localStorage && localStorage.OxTheme = theme; return that; } @@ -142,4 +143,4 @@ Ox.Theme = (function() { return that; -}()); \ No newline at end of file +}()); diff --git a/source/Ox/js/Core.js b/source/Ox/js/Core.js index 804650a1..122a1ddf 100644 --- a/source/Ox/js/Core.js +++ b/source/Ox/js/Core.js @@ -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),