From fbf02bc0b2cd82c5814ee2307b5302e1777e2077 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 2 Mar 2013 12:52:27 +0000 Subject: [PATCH] add span type number, pass state.type to getSpan --- source/Ox.UI/js/Core/URL.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Core/URL.js b/source/Ox.UI/js/Core/URL.js index d437ad38..f3f7fb1c 100644 --- a/source/Ox.UI/js/Core/URL.js +++ b/source/Ox.UI/js/Core/URL.js @@ -16,7 +16,7 @@ Ox.URL URL controller callback callback function id Matching item id, or empty getSpan Tests if a string matches a span - (item, view, string, callback) -> undefined + (type, item, view, string, callback) -> undefined item The item id, or empty view The view, or empty string The string to be tested @@ -56,7 +56,7 @@ Ox.URL URL controller getItem: function(type, str, callback) { callback(/^\d+$/.test(str) ? str : ''); }, - getSpan: function(item, view, str, callback) { + getSpan: function(type, item, view, str, callback) { if (!item && (!view || view == 'map')) { callback(str.replace(/^@/, ''), 'map'); } else { @@ -473,6 +473,7 @@ Ox.URL = function(options) { return Ox.isNumber(point) ? ( spanType == 'date' ? constructDate(point) : spanType == 'duration' ? constructDuration(point) + : spanType == 'number' ? point : constructLocation(point) ) : point; }).join(','); @@ -544,6 +545,7 @@ Ox.URL = function(options) { var canBeDate = types.indexOf('date') > -1, canBeDuration = types.indexOf('duration') > -1, canBeLocation = types.indexOf('location') > -1, + canBeNumber = types.indexOf('number') > -1, length = str.split(',').length; return canBeDate && /\d-/.test(str) ? 'date' : canBeDuration && /:/.test(str) ? 'duration' @@ -551,7 +553,9 @@ Ox.URL = function(options) { // leaves us with [-]D[.D][,[-]D[.D]] : canBeDuration ? 'duration' : canBeDate && !/\./.test(str) ? 'date' - : canBeLocation && length == 2 ? 'location' : ':' + : canBeLocation && length == 2 ? 'location' + : canBeNumber && /\d-/.test(str) ? 'number' + : ':' } function parseCondition(str) { @@ -611,6 +615,10 @@ Ox.URL = function(options) { return Ox.parseDuration(str); } + function parseNumber(str) { + return parseFloat(str); + } + function parseFind(str) { str = (str || '').replace(/%7C/g, '|'); var conditions, counter = 0, @@ -698,6 +706,7 @@ Ox.URL = function(options) { return split.map( type == 'date' ? parseDate : type == 'duration' ? parseDuration + : type == 'number' ? parseNumber : parseLocation ); } @@ -796,7 +805,7 @@ Ox.URL = function(options) { } if (!state.span && /^[A-Z@]/.test(parts[0])) { // test for span id or name - self.options.getSpan(state.item, state.view, decodeValue(parts[0]), function(span, view) { + self.options.getSpan(state.type, state.item, state.view, decodeValue(parts[0]), function(span, view) { Ox.Log('Core', 'span/view', span, view) if (span) { if (!state.view) {