OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @param {string} toTest The string to be tested. | 6 * @param {string} toTest The string to be tested. |
7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing | 7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing |
8 * whitespace is allowed. | 8 * whitespace is allowed. |
9 */ | 9 */ |
10 function isInteger(toTest) { | 10 function isInteger(toTest) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 /** | 244 /** |
245 * Converts |value| from points to millimeters. | 245 * Converts |value| from points to millimeters. |
246 * @param {number} value The number in points. | 246 * @param {number} value The number in points. |
247 * @return {number} |value| in millimeters. | 247 * @return {number} |value| in millimeters. |
248 */ | 248 */ |
249 function convertPointsToMillimeters(value) { | 249 function convertPointsToMillimeters(value) { |
250 return value / POINTS_PER_MILLIMETER; | 250 return value / POINTS_PER_MILLIMETER; |
251 } | 251 } |
252 | 252 |
253 /** | 253 /** |
254 * Parses |numberFormat| and extracts the symbols used for the thousands point | 254 * Shows or hides an element. |
255 * and decimal point. | 255 * @param {Element} element Element to show or hide. |
256 * @param {string} numberFormat The formatted version of the number 12345678. | 256 * @param {boolean} isVisible Whether the element should be visible or not. |
257 * @return {!Array.<string>} The extracted symbols in the order | |
258 * [thousandsSymbol, decimalSymbol]]. For example | |
259 * parseNumberFormat("123,456.78") returns [",", "."]. | |
260 */ | 257 */ |
261 function parseNumberFormat(numberFormat) { | 258 function setIsVisible(element, isVisible) { |
262 if (!numberFormat) | 259 element.style.display = isVisible ? '' : 'none'; |
263 numberFormat = ''; | |
264 var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/; | |
265 var matches = numberFormat.match(regex) || ['', '', ',', '', '.']; | |
266 return [matches[2], matches[4]]; | |
267 } | 260 } |
| 261 |
| 262 /** |
| 263 * @param {Array.<object>} array Array to check for item. |
| 264 * @param {object} item Item to look for in array. |
| 265 * @return {boolean} Whether the item is in the array. |
| 266 */ |
| 267 function arrayContains(array, item) { |
| 268 return array.indexOf(item) != -1; |
| 269 } |
OLD | NEW |