OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('print_preview', function() { |
| 6 'use strict'; |
| 7 |
| 8 /** |
| 9 * @constructor |
| 10 */ |
| 11 function MeasurementSystem(thousandsDelimeter, decimalDelimeter, unitType) { |
| 12 this.thousandsDelimeter_ = thousandsDelimeter; |
| 13 this.decimalDelimeter_ = decimalDelimeter; |
| 14 this.unitType_ = unitType; |
| 15 }; |
| 16 |
| 17 /** |
| 18 * Parses |numberFormat| and extracts the symbols used for the thousands point |
| 19 * and decimal point. |
| 20 * @param {string} numberFormat The formatted version of the number 12345678. |
| 21 * @return {!Array.<string>} The extracted symbols in the order |
| 22 * [thousandsSymbol, decimalSymbol]. For example, |
| 23 * parseNumberFormat("123,456.78") returns [",", "."]. |
| 24 */ |
| 25 MeasurementSystem.parseNumberFormat = function(numberFormat) { |
| 26 if (!numberFormat) |
| 27 numberFormat = ''; |
| 28 var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/; |
| 29 var matches = numberFormat.match(regex) || ['', '', ',', '', '.']; |
| 30 return [matches[2], matches[4]]; |
| 31 }; |
| 32 |
| 33 // Export |
| 34 return { |
| 35 MeasurementSystem: MeasurementSystem |
| 36 }; |
| 37 }); |
OLD | NEW |