diff options
author | Ananya Sen | 2012-02-10 16:05:27 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-10 16:05:27 -0800 |
commit | f3dc624fa464a79fd8e8cec1ddd16ed2109bda23 (patch) | |
tree | f716757dab75d7626297893c7f4aca3596d606de /js/helper-classes/Utils.js | |
parent | c48eeb01bd726895dc577d8b843b2a75883eee07 (diff) | |
download | ninja-f3dc624fa464a79fd8e8cec1ddd16ed2109bda23.tar.gz |
Revert "Merge from /joseeight/ninja-internal/tree/FileIO"
This reverts commit c48eeb01bd726895dc577d8b843b2a75883eee07.
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/helper-classes/Utils.js')
-rwxr-xr-x | js/helper-classes/Utils.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/helper-classes/Utils.js b/js/helper-classes/Utils.js new file mode 100755 index 00000000..1cfc390e --- /dev/null +++ b/js/helper-classes/Utils.js | |||
@@ -0,0 +1,33 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | // Adding to the String Prototype little utility function to capitalize the first Char of a String. | ||
8 | String.prototype.capitalizeFirstChar = function() { | ||
9 | return this.charAt(0).toUpperCase() + this.slice(1); | ||
10 | }; | ||
11 | |||
12 | exports.utils = Object.create(Object.prototype, { | ||
13 | |||
14 | getValueAndUnits: { | ||
15 | value: function(str) | ||
16 | { | ||
17 | var numberValue = parseFloat(str); | ||
18 | // Ignore all whitespace, digits, negative sign and "." when looking for units label | ||
19 | // The units must come after one or more digits | ||
20 | var objRegExp = /(\-*\d+\.*\d*)(\s*)(\w*\%*)/; | ||
21 | var unitsString = str.replace(objRegExp, "$3"); | ||
22 | if(unitsString) | ||
23 | { | ||
24 | var noSpaces = /(\s*)(\S*)(\s*)/; | ||
25 | // strip out spaces and convert to lower case | ||
26 | var match = (unitsString.replace(noSpaces, "$2")).toLowerCase(); | ||
27 | } | ||
28 | |||
29 | return [numberValue, match]; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | }); \ No newline at end of file | ||