summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/extended/string.js
diff options
context:
space:
mode:
authorwei <>2006-04-21 11:41:21 +0000
committerwei <>2006-04-21 11:41:21 +0000
commite1e034ced29b0b9bf11a49798b4fba4d3dd0164d (patch)
tree92120227f58c2463ddb50b1592dde0436d175189 /framework/Web/Javascripts/extended/string.js
parente57fc66ee3f5259b4f7cbd18a1cd0f6da6176f5d (diff)
Update javascript libraries, rewrote client-side validators, removed some js files, simplified javascript compression.
Diffstat (limited to 'framework/Web/Javascripts/extended/string.js')
-rw-r--r--framework/Web/Javascripts/extended/string.js13
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