Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4325)

Unified Diff: chrome/browser/resources/print_preview/data/measurement_system.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698