| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Returns a list of pages defined by |pagesRangeText|. The pages are | 148 * Returns a list of pages defined by |pagesRangeText|. The pages are |
| 149 * listed in the order they appear in |pageRangeText| and duplicates are not | 149 * listed in the order they appear in |pageRangeText| and duplicates are not |
| 150 * eliminated. If |pageRangeText| is not valid according or | 150 * eliminated. If |pageRangeText| is not valid according or |
| 151 * |totalPageCount| undefined [1,2,...,totalPageCount] is returned. | 151 * |totalPageCount| undefined [1,2,...,totalPageCount] is returned. |
| 152 * See pageRangeTextToPageRanges for details. | 152 * See pageRangeTextToPageRanges for details. |
| 153 * @param {string} pageRangeText The text to be checked. | 153 * @param {string} pageRangeText The text to be checked. |
| 154 * @param {number} totalPageCount The total number of pages. | 154 * @param {number} totalPageCount The total number of pages. |
| 155 * @return {Array<number>} A list of all pages. | 155 * @return {!Array<number>} A list of all pages. |
| 156 */ | 156 */ |
| 157 function pageRangeTextToPageList(pageRangeText, totalPageCount) { | 157 function pageRangeTextToPageList(pageRangeText, totalPageCount) { |
| 158 var pageRanges = pageRangeTextToPageRanges(pageRangeText, totalPageCount); | 158 var pageRanges = pageRangeTextToPageRanges(pageRangeText, totalPageCount); |
| 159 var pageList = []; | 159 var pageList = []; |
| 160 if (pageRanges instanceof Array) { | 160 if (pageRanges instanceof Array) { |
| 161 for (var i = 0; i < pageRanges.length; ++i) { | 161 for (var i = 0; i < pageRanges.length; ++i) { |
| 162 for (var j = pageRanges[i].from; j <= Math.min(pageRanges[i].to, | 162 for (var j = pageRanges[i].from; j <= Math.min(pageRanges[i].to, |
| 163 totalPageCount); ++j) { | 163 totalPageCount); ++j) { |
| 164 pageList.push(j); | 164 pageList.push(j); |
| 165 } | 165 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 * localizedStrings An array of strings with corresponding locales. | 236 * localizedStrings An array of strings with corresponding locales. |
| 237 * @return {string} A string for the current locale. An empty string if there's | 237 * @return {string} A string for the current locale. An empty string if there's |
| 238 * no string for the current locale found. | 238 * no string for the current locale found. |
| 239 */ | 239 */ |
| 240 function getStringForCurrentLocale(localizedStrings) { | 240 function getStringForCurrentLocale(localizedStrings) { |
| 241 // First try to find an exact match and then look for the language only. | 241 // First try to find an exact match and then look for the language only. |
| 242 return getStringForLocale(localizedStrings, navigator.language) || | 242 return getStringForLocale(localizedStrings, navigator.language) || |
| 243 getStringForLocale(localizedStrings, | 243 getStringForLocale(localizedStrings, |
| 244 navigator.language.split('-')[0]); | 244 navigator.language.split('-')[0]); |
| 245 } | 245 } |
| OLD | NEW |