diff options
author | Valerio Virgillito | 2012-05-14 16:04:37 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-14 16:04:37 -0700 |
commit | 7f71c29e6558eefc5904ca0dfcb7ec898b2492a5 (patch) | |
tree | 98746bd793f3ec0c3ecc68797988ed4679fabc79 | |
parent | ba5b8238784a41099d0eb76795de2a7e5abde226 (diff) | |
download | ninja-7f71c29e6558eefc5904ca0dfcb7ec898b2492a5.tar.gz |
adding some test converters
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
-rw-r--r-- | js/components/converter/string-units-converter.js | 31 | ||||
-rw-r--r-- | js/components/converter/string-value-converter.js (renamed from js/components/converter/value-units-converter.js) | 14 |
2 files changed, 38 insertions, 7 deletions
diff --git a/js/components/converter/string-units-converter.js b/js/components/converter/string-units-converter.js new file mode 100644 index 00000000..6b97d5c5 --- /dev/null +++ b/js/components/converter/string-units-converter.js | |||
@@ -0,0 +1,31 @@ | |||
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 | var Montage = require("montage").Montage, | ||
7 | Converter = require("montage/core/converter/converter").Converter, | ||
8 | NJUtils = require("js/lib/NJUtils").NJUtils; | ||
9 | |||
10 | exports.StringUnitsConverter = Montage.create(Converter, { | ||
11 | |||
12 | // convert fahrenheit to celsius (showing our non-metric heritage here) | ||
13 | convert: { | ||
14 | value: function(value) { | ||
15 | if(value) { | ||
16 | console.log("convert string to unit ", value); | ||
17 | var tmp = NJUtils.getValueAndUnits(value); | ||
18 | return tmp[1]; | ||
19 | } | ||
20 | } | ||
21 | }, | ||
22 | |||
23 | // revert celsius to fahrenheit | ||
24 | revert: { | ||
25 | value: function(value) { | ||
26 | console.log("revert string to unit ", value); | ||
27 | return value; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | }); | ||
diff --git a/js/components/converter/value-units-converter.js b/js/components/converter/string-value-converter.js index e4f9aee9..28d7dd29 100644 --- a/js/components/converter/value-units-converter.js +++ b/js/components/converter/string-value-converter.js | |||
@@ -4,25 +4,25 @@ | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | var Montage = require("montage").Montage, | 6 | var Montage = require("montage").Montage, |
7 | Converter = require("montage/core/converter/converter").Converter; | 7 | Converter = require("montage/core/converter/converter").Converter, |
8 | NJUtils = require("js/lib/NJUtils").NJUtils; | ||
8 | 9 | ||
9 | exports.ValueUnitsConverter = Montage.create(Converter, { | 10 | exports.StringValueConverter = Montage.create(Converter, { |
10 | 11 | ||
11 | // convert fahrenheit to celsius (showing our non-metric heritage here) | 12 | // convert fahrenheit to celsius (showing our non-metric heritage here) |
12 | convert: { | 13 | convert: { |
13 | value: function(value) { | 14 | value: function(value) { |
14 | // return (parseInt(value, 10) - 32) / 1.8; | ||
15 | // console.log(value); | ||
16 | console.log(value); | 15 | console.log(value); |
17 | return parseInt(value); | 16 | console.log(parseInt(value)); |
17 | return parseInt(value); | ||
18 | } | 18 | } |
19 | }, | 19 | }, |
20 | 20 | ||
21 | // revert celsius to fahrenheit | 21 | // revert celsius to fahrenheit |
22 | revert: { | 22 | revert: { |
23 | value: function(value) { | 23 | value: function(value) { |
24 | // return (1.8 * parseInt(value, 10)) + 32; | 24 | console.log("revert string to value ", value); |
25 | console.log(value); | 25 | return value; |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||