From 7f71c29e6558eefc5904ca0dfcb7ec898b2492a5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 14 May 2012 16:04:37 -0700 Subject: adding some test converters Signed-off-by: Valerio Virgillito --- js/components/converter/string-units-converter.js | 31 +++++++++++++++++++++++ js/components/converter/string-value-converter.js | 29 +++++++++++++++++++++ js/components/converter/value-units-converter.js | 29 --------------------- 3 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 js/components/converter/string-units-converter.js create mode 100644 js/components/converter/string-value-converter.js delete mode 100644 js/components/converter/value-units-converter.js 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 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +var Montage = require("montage").Montage, + Converter = require("montage/core/converter/converter").Converter, + NJUtils = require("js/lib/NJUtils").NJUtils; + +exports.StringUnitsConverter = Montage.create(Converter, { + + // convert fahrenheit to celsius (showing our non-metric heritage here) + convert: { + value: function(value) { + if(value) { + console.log("convert string to unit ", value); + var tmp = NJUtils.getValueAndUnits(value); + return tmp[1]; + } + } + }, + + // revert celsius to fahrenheit + revert: { + value: function(value) { + console.log("revert string to unit ", value); + return value; + } + } + +}); diff --git a/js/components/converter/string-value-converter.js b/js/components/converter/string-value-converter.js new file mode 100644 index 00000000..28d7dd29 --- /dev/null +++ b/js/components/converter/string-value-converter.js @@ -0,0 +1,29 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ +var Montage = require("montage").Montage, + Converter = require("montage/core/converter/converter").Converter, + NJUtils = require("js/lib/NJUtils").NJUtils; + +exports.StringValueConverter = Montage.create(Converter, { + + // convert fahrenheit to celsius (showing our non-metric heritage here) + convert: { + value: function(value) { + console.log(value); + console.log(parseInt(value)); + return parseInt(value); + } + }, + + // revert celsius to fahrenheit + revert: { + value: function(value) { + console.log("revert string to value ", value); + return value; + } + } + +}); diff --git a/js/components/converter/value-units-converter.js b/js/components/converter/value-units-converter.js deleted file mode 100644 index e4f9aee9..00000000 --- a/js/components/converter/value-units-converter.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - This file contains proprietary software owned by Motorola Mobility, Inc.
- No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
- (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ -var Montage = require("montage").Montage, -Converter = require("montage/core/converter/converter").Converter; - -exports.ValueUnitsConverter = Montage.create(Converter, { - - // convert fahrenheit to celsius (showing our non-metric heritage here) - convert: { - value: function(value) { -// return (parseInt(value, 10) - 32) / 1.8; -// console.log(value); - console.log(value); - return parseInt(value); - } - }, - - // revert celsius to fahrenheit - revert: { - value: function(value) { -// return (1.8 * parseInt(value, 10)) + 32; - console.log(value); - } - } - -}); -- cgit v1.2.3