From c5d0cd2824e3c3bb2f6f3834177a71c1d7b78519 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 27 Mar 2007 00:47:38 +0000 Subject: merge from 3.0 branch till 1779. --- framework/Web/Javascripts/extended/string.js | 172 --------------------------- 1 file changed, 172 deletions(-) delete mode 100644 framework/Web/Javascripts/extended/string.js (limited to 'framework/Web/Javascripts/extended/string.js') diff --git a/framework/Web/Javascripts/extended/string.js b/framework/Web/Javascripts/extended/string.js deleted file mode 100644 index 2bb40759..00000000 --- a/framework/Web/Javascripts/extended/string.js +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @class String extensions - */ -Object.extend(String.prototype, -{ - /** - * @param {String} "left" to pad the string on the left, "right" to pad right. - * @param {Number} minimum string length. - * @param {String} character(s) to pad - * @return {String} padded character(s) on the left or right to satisfy minimum string length - */ - - pad : function(side, len, chr) { - if (!chr) chr = ' '; - var s = this; - var left = side.toLowerCase()=='left'; - while (s.lengthInternationalization - * is not supported - * @param {String} the decimal character - * @return {Double} null if string does not represent a float value - */ - 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); - }, - - /** - * Convert strings that represent a currency value (e.g. a float with grouping - * characters) to float. E.g. "10,000.50" will become "10000.50". The number - * of dicimal digits, grouping and decimal characters can be specified. - * The currency input format is very strict, null will be returned if - * the pattern does not match. - * @param {String} the grouping character, default is "," - * @param {Number} number of decimal digits - * @param {String} the decimal character, default is "." - * @type {Double} the currency value as float. - */ - toCurrency : function(groupchar, digits, decimalchar) - { - groupchar = groupchar || ","; - decimalchar = decimalchar || "."; - digits = typeof(digits) == "undefined" ? 2 : digits; - - var exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + groupchar + ")*)(\\d+)" - + ((digits > 0) ? "(\\" + decimalchar + "(\\d{1," + digits + "}))?" : "") - + "\\s*$"); - var m = this.match(exp); - if (m == null) - return null; - var intermed = m[2] + m[5] ; - var cleanInput = m[1] + intermed.replace( - new RegExp("(\\" + groupchar + ")", "g"), "") - + ((digits > 0) ? "." + m[7] : ""); - var num = parseFloat(cleanInput); - return (isNaN(num) ? null : num); - }, - - /** - * Converts the string to a date by finding values that matches the - * date format pattern. - * @param string date format pattern, e.g. MM-dd-yyyy - * @return {Date} the date extracted from the string - */ - toDate : function(format) - { - return Date.SimpleParse(this, format); - } -}); \ No newline at end of file -- cgit v1.2.3