diff options
author | xue <> | 2006-04-21 12:36:06 +0000 |
---|---|---|
committer | xue <> | 2006-04-21 12:36:06 +0000 |
commit | e392ecbf6e422825083bc7204eacb7090619a47c (patch) | |
tree | 8f2dcc8302f223ac2c71efd762417eddf84d62aa /framework/Web/Javascripts/extended/string.js | |
parent | c54a230a5926086ff1b69a0dd7e6352dbc0b40ff (diff) |
Merge from 3.0 branch till 953.
Diffstat (limited to 'framework/Web/Javascripts/extended/string.js')
-rw-r--r-- | framework/Web/Javascripts/extended/string.js | 13 |
1 files changed, 10 insertions, 3 deletions
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 |