Index: chrome/browser/resources/print_preview/data/measurement_system.js |
diff --git a/chrome/browser/resources/print_preview/data/measurement_system.js b/chrome/browser/resources/print_preview/data/measurement_system.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d476ca4eedcb5fc50ce9e7e4f2ac5f68649c9489 |
--- /dev/null |
+++ b/chrome/browser/resources/print_preview/data/measurement_system.js |
@@ -0,0 +1,37 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+cr.define('print_preview', function() { |
+ 'use strict'; |
+ |
+ /** |
+ * @constructor |
+ */ |
+ function MeasurementSystem(thousandsDelimeter, decimalDelimeter, unitType) { |
+ this.thousandsDelimeter_ = thousandsDelimeter; |
+ this.decimalDelimeter_ = decimalDelimeter; |
+ this.unitType_ = unitType; |
+ }; |
+ |
+ /** |
+ * Parses |numberFormat| and extracts the symbols used for the thousands point |
+ * and decimal point. |
+ * @param {string} numberFormat The formatted version of the number 12345678. |
+ * @return {!Array.<string>} The extracted symbols in the order |
+ * [thousandsSymbol, decimalSymbol]. For example, |
+ * parseNumberFormat("123,456.78") returns [",", "."]. |
+ */ |
+ MeasurementSystem.parseNumberFormat = function(numberFormat) { |
+ if (!numberFormat) |
+ numberFormat = ''; |
+ var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/; |
+ var matches = numberFormat.match(regex) || ['', '', ',', '', '.']; |
+ return [matches[2], matches[4]]; |
+ }; |
+ |
+ // Export |
+ return { |
+ MeasurementSystem: MeasurementSystem |
+ }; |
+}); |