summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/Format.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/MochiKit/Format.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/Format.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/frontend/gamma/js/MochiKit/Format.js b/frontend/gamma/js/MochiKit/Format.js
index 122845e..58877e7 100644
--- a/frontend/gamma/js/MochiKit/Format.js
+++ b/frontend/gamma/js/MochiKit/Format.js
@@ -5,13 +5,13 @@ MochiKit.Format 1.5
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
***/
-MochiKit.Base._module('Format', '1.5', ['Base']);
+MochiKit.Base.module(MochiKit, 'Format', '1.5', ['Base']);
MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) {
return function (num) {
num = parseFloat(num);
if (typeof(num) == "undefined" || num === null || isNaN(num)) {
return placeholder;
@@ -101,13 +101,13 @@ MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, loca
var fn = arguments.callee;
var args = m.concat(arguments);
rval.repr = function () {
return [
self.NAME,
"(",
- map(m.repr, args).join(", "),
+ m.map(m.repr, args).join(", "),
")"
].join("");
};
}
return rval;
};
@@ -139,13 +139,13 @@ MochiKit.Format.twoDigitAverage = function (numerator, denominator) {
}
return "0";
};
/** @id MochiKit.Format.twoDigitFloat */
MochiKit.Format.twoDigitFloat = function (aNumber) {
- var res = roundToFixed(aNumber, 2);
+ var res = MochiKit.Format.roundToFixed(aNumber, 2);
if (res.indexOf(".00") > 0) {
return res.substring(0, res.length - 3);
} else if (res.charAt(res.length - 1) == "0") {
return res.substring(0, res.length - 1);
} else {
return res;
@@ -190,25 +190,25 @@ MochiKit.Format.truncToFixed = function (aNumber, precision) {
var fracPos = fixed.indexOf(".");
if (fracPos > 0 && fracPos + precision + 1 < fixed.length) {
fixed = fixed.substring(0, fracPos + precision + 1);
fixed = MochiKit.Format._shiftNumber(fixed, 0);
}
return fixed;
-}
+};
/** @id MochiKit.Format.roundToFixed */
MochiKit.Format.roundToFixed = function (aNumber, precision) {
var fixed = MochiKit.Format._numberToFixed(aNumber, precision);
var fracPos = fixed.indexOf(".");
if (fracPos > 0 && fracPos + precision + 1 < fixed.length) {
var str = MochiKit.Format._shiftNumber(fixed, precision);
str = MochiKit.Format._numberToFixed(Math.round(parseFloat(str)), 0);
fixed = MochiKit.Format._shiftNumber(str, -precision);
}
return fixed;
-}
+};
/**
* Converts a number to a fixed format string. This function handles
* conversion of exponents by shifting the decimal point to the left
* or the right. It also guarantees a specified minimum number of
* fractional digits (but no maximum).
@@ -218,26 +218,26 @@ MochiKit.Format.roundToFixed = function (aNumber, precision) {
*
* @return {String} the fixed format number string
*/
MochiKit.Format._numberToFixed = function (aNumber, precision) {
var str = aNumber.toString();
var parts = str.split(/[eE]/);
- var exp = (parts.length === 1) ? 0 : parseInt(parts[1]) || 0;
+ var exp = (parts.length === 1) ? 0 : parseInt(parts[1], 10) || 0;
var fixed = MochiKit.Format._shiftNumber(parts[0], exp);
parts = fixed.split(/\./);
var whole = parts[0];
var frac = (parts.length === 1) ? "" : parts[1];
while (frac.length < precision) {
frac += "0";
}
if (frac.length > 0) {
return whole + "." + frac;
} else {
return whole;
}
-}
+};
/**
* Shifts the decimal dot location in a fixed format number string.
* This function handles negative values and will add and remove
* leading and trailing zeros as needed.
*
@@ -272,13 +272,13 @@ MochiKit.Format._shiftNumber = function (num, exp) {
num = num.substring(1);
}
while (/^-0[^.]/.test(num)) {
num = "-" + num.substring(2);
}
return num;
-}
+};
/** @id MochiKit.Format.percentFormat */
MochiKit.Format.percentFormat = function (aNumber) {
return MochiKit.Format.twoDigitFloat(100 * aNumber) + '%';
};