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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698