From e392ecbf6e422825083bc7204eacb7090619a47c Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 21 Apr 2006 12:36:06 +0000 Subject: Merge from 3.0 branch till 953. --- framework/Web/Javascripts/extended/string.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'framework/Web/Javascripts/extended/string.js') diff --git a/framework/Web/Javascripts/extended/string.js b/framework/Web/Javascripts/extended/string.js index 46274256..5cd1bd8e 100644 --- a/framework/Web/Javascripts/extended/string.js +++ b/framework/Web/Javascripts/extended/string.js @@ -79,13 +79,14 @@ Object.extend(String.prototype, { if(command[new String(action)]) command=command[new String(action)]; }); - if(isFunction(command)) + if(typeof(command) == "function") return command; else { if(typeof Logger != "undefined") Logger.error("Missing function", this); - return Prototype.emptyFunction; + + throw new Error ("Missing function '"+this+"'"); } }, @@ -110,11 +111,17 @@ Object.extend(String.prototype, { */ toDouble : function(decimalchar) { + if(this.length <= 0) return null; decimalchar = decimalchar || "."; var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + decimalchar + "(\\d+))?\\s*$"); var m = this.match(exp); + if (m == null) return null; + m[1] = m[1] || ""; + m[2] = m[2] || "0"; + m[4] = m[4] || "0"; + var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4]; var num = parseFloat(cleanInput); return (isNaN(num) ? null : num); @@ -161,4 +168,4 @@ Object.extend(String.prototype, { { return Date.SimpleParse(this, format); } -}); +}); \ No newline at end of file -- cgit v1.2.3