| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 /** | 136 /** |
| 137 * Returns a list of pages defined by |pagesRangeText|. The pages are | 137 * Returns a list of pages defined by |pagesRangeText|. The pages are |
| 138 * listed in the order they appear in |pageRangeText| and duplicates are not | 138 * listed in the order they appear in |pageRangeText| and duplicates are not |
| 139 * eliminated. If |pageRangeText| is not valid according or | 139 * eliminated. If |pageRangeText| is not valid according or |
| 140 * |totalPageCount| undefined [1,2,...,totalPageCount] is returned. | 140 * |totalPageCount| undefined [1,2,...,totalPageCount] is returned. |
| 141 * See pageRangeTextToPageRanges for details. | 141 * See pageRangeTextToPageRanges for details. |
| 142 * @param {string} pageRangeText The text to be checked. | 142 * @param {string} pageRangeText The text to be checked. |
| 143 * @param {number} totalPageCount The total number of pages. | 143 * @param {number} totalPageCount The total number of pages. |
| 144 * @return {Array.<number>} A list of all pages. | 144 * @return {!Array.<number>} A list of all pages. |
| 145 */ | 145 */ |
| 146 function pageRangeTextToPageList(pageRangeText, totalPageCount) { | 146 function pageRangeTextToPageList(pageRangeText, totalPageCount) { |
| 147 var pageRanges = pageRangeTextToPageRanges(pageRangeText, totalPageCount); | 147 var pageRanges = pageRangeTextToPageRanges(pageRangeText, totalPageCount); |
| 148 var pageList = []; | 148 var pageList = []; |
| 149 if (pageRanges) { | 149 if (pageRanges) { |
| 150 for (var i = 0; i < pageRanges.length; ++i) { | 150 for (var i = 0; i < pageRanges.length; ++i) { |
| 151 for (var j = pageRanges[i].from; j <= Math.min(pageRanges[i].to, | 151 for (var j = pageRanges[i].from; j <= Math.min(pageRanges[i].to, |
| 152 totalPageCount); ++j) { | 152 totalPageCount); ++j) { |
| 153 pageList.push(j); | 153 pageList.push(j); |
| 154 } | 154 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @param {!Array} array Array to check for item. | 199 * @param {!Array} array Array to check for item. |
| 200 * @param {*} item Item to look for in array. | 200 * @param {*} item Item to look for in array. |
| 201 * @return {boolean} Whether the item is in the array. | 201 * @return {boolean} Whether the item is in the array. |
| 202 */ | 202 */ |
| 203 function arrayContains(array, item) { | 203 function arrayContains(array, item) { |
| 204 return array.indexOf(item) != -1; | 204 return array.indexOf(item) != -1; |
| 205 } | 205 } |
| OLD | NEW |