From 23adaa05dfe48b769b93e701a56d42db4638f3b7 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 23 Jul 2011 15:44:11 +0200 Subject: [PATCH] exec regex --- source/Ox.UI/js/Form/Ox.Input.js | 12 ++++++------ source/Ox.UI/js/Map/Ox.Map.js | 1 - source/Ox.js | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Input.js b/source/Ox.UI/js/Form/Ox.Input.js index 14eaa231..961ed30b 100644 --- a/source/Ox.UI/js/Form/Ox.Input.js +++ b/source/Ox.UI/js/Form/Ox.Input.js @@ -473,17 +473,17 @@ Ox.Input = function(options, self) { } else if (value == '.') { value = '0.' + self.decimals; cursor = [2, value.length]; - } else if (!/\./(value)) { - value += '.' + self.decimals + } else if (!/\./.test(value)) { + value += '.' + self.decimals; cursor = [value.indexOf('.'), value.length]; - } else if (/^\./(value)) { + } else if (/^\./.test(value)) { value = '0' + value; cursor = [2, value.length]; - } else if (/\.$/(value)) { + } else if (/\.$/.test(value)) { //Ox.print('$$$$$$$$$$$') value += self.decimals; cursor = [value.indexOf('.') + 1, value.length]; - } else if (/\./(value) && self.options.decimals) { + } else if (/\./.test(value) && self.options.decimals) { length = value.split('.')[1].length; if (length > self.options.decimals) { value = value.substr(0, value.indexOf('.') + 1 + self.options.decimals); @@ -499,7 +499,7 @@ Ox.Input = function(options, self) { cursor = [0, 1]; } } - while (/^0\d/(value)) { + while (/^0\d/.test(value)) { value = value.substr(1, value.length); } if (!regexp.test(value) || value < self.options.min || value > self.options.max) { diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index 8d761b6c..68221fe6 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -1013,7 +1013,6 @@ Ox.Map = function(options, self) { if (place) { select(); } else { - Ox.print() // async && place doesn't exist yet self.options.places({ keys: self.placeKeys, diff --git a/source/Ox.js b/source/Ox.js index 6c5348b5..731d4b53 100644 --- a/source/Ox.js +++ b/source/Ox.js @@ -206,7 +206,7 @@ Ox.sort = function(arr, fn) { values = fn ? arr.map(fn) : arr; // find leading numbers values.forEach(function(val, i) { - var match = /^\d+/(val); + var match = /^\d+/.exec(val); matches[val] = match ? match[0] : ''; }); // get length of longest leading number @@ -1462,7 +1462,7 @@ Ox.parseDate Takes a string ('YYYY-MM-DD HH:MM:SS') and returns a date Ox.parseDate = function(str, utc) { var date = new Date(0), defaults = [, 1, 1, 0, 0, 0], - values = /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/(str); + values = /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/.exec(str); values.shift(); values = values.map(function(v, i) { return v || defaults[i]; @@ -1486,7 +1486,7 @@ Ox.parseDateRange = function(start, end, utc) { 'FullYear', 'Month', 'Date', 'Hours', 'Minutes', 'Seconds' ][ Ox.compact( - /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/(end) + /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/.exec(end) ).length - 2 ]; Ox['set' + part](dates[1], Ox['get' + part](dates[1], utc) + 1, utc); @@ -2320,7 +2320,7 @@ Ox.formatDateRange = function(start, end, utc) { }), parts = range.map(function(str) { var parts = Ox.compact( - /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/(str) + /(-?\d+)-?(\d+)?-?(\d+)? ?(\d+)?:?(\d+)?:?(\d+)?/.exec(str) ); parts.shift(); return parts.map(function(part) { @@ -4151,7 +4151,7 @@ Ox.parsePath Returns the components of a path {extension: '', filename: '.foo', pathname: ''} @*/ Ox.parsePath = function(str) { - var matches = /^(.+\/)?(.+?(\..+)?)?$/(str); + var matches = /^(.+\/)?(.+?(\..+)?)?$/.exec(str); return { pathname: matches[1] || '', filename: matches[2] || '', @@ -4400,7 +4400,7 @@ Ox.words = function(str) { var arr = str.toLowerCase().split(/\b/), chr = "-'", len = arr.length, - startsWithWord = !!/\w/(arr[0]); + startsWithWord = /\w/.test(arr[0]); arr.forEach(function(v, i) { // find single occurrences of "-" or "-" // that are not at the beginning or end of the string