From 7415b7203751a387785c8d83cb62d27ddd081565 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sat, 29 Oct 2011 12:32:55 +0000 Subject: [PATCH] fix a bug related to clearing the requests cache --- source/Ox.UI/js/Core/Ox.Request.js | 3 ++- source/Ox.UI/js/Form/Ox.Input.js | 1 - source/Ox/js/Core.js | 32 ++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Request.js b/source/Ox.UI/js/Core/Ox.Request.js index 14f25b98..63d14aa1 100644 --- a/source/Ox.UI/js/Core/Ox.Request.js +++ b/source/Ox.UI/js/Core/Ox.Request.js @@ -119,8 +119,9 @@ Ox.Request = function(options) { options.age == -1 || options.age > +new Date() - cache[req].time )) { + var data = cache[req].data; setTimeout(function() { - callback && callback(cache[req].data); + callback && callback(data); }, 0); } else { pending[options.id] = true; diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js index 10ccaf69..d6cbcbed 100644 --- a/source/Ox.UI/js/Form/Ox.Input.js +++ b/source/Ox.UI/js/Form/Ox.Input.js @@ -695,7 +695,6 @@ Ox.Input = function(options, self) { newValue = oldValue.substr(0, oldCursor[0] - 1), hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46) && oldCursor[0] < oldCursor[1] && oldCursor[1] == oldValue.length; - Ox.print('CHANGE ON KEYPRESS', self.options.changeOnKeypress); if ( event.keyCode != 9 // tab && (self.options.type == 'textarea' || event.keyCode != 13) // enter diff --git a/source/Ox/js/Core.js b/source/Ox/js/Core.js index 874d43a4..b338f206 100644 --- a/source/Ox/js/Core.js +++ b/source/Ox/js/Core.js @@ -122,20 +122,30 @@ Ox.load = function() { }; Ox.Log = (function() { - var filter = /*localStorage && localStorage.filter - ? new RegExp(localStorage.filter) || */'/.*?/', + var filter = localStorage && localStorage.filter + ? JSON.parse(localStorage.filter) : 0, that = function() { - Ox.Log.log.apply(null, arguments); - return that; + return that.log.apply(null, arguments); }; - that.filter = function(regexp) { - filter = regexp; - // ... - }; - that.log = function() { - if (filter.test(JSON.stringify(arguments))) { - Ox.print.apply(null, arguments); + that.filter = function(value) { + filter = value; + if (localStorage) { + localStorage.filter = JSON.stringify(filter); } + return that; + }; + that.log = function log() { + var args = Ox.makeArray(arguments), + level = Ox.isNumber(args[0]) ? args[0] : 0, + ret; + if ((Ox.isNumber(filter) && level >= filter) || filter === args[0]) { + args.unshift( + (arguments.callee.caller && arguments.callee.caller.name) + || '(anonymous)' + ); + ret = Ox.print.apply(null, args); + } + return ret; }; return that; }());