| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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 } |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 if (pageList.length == 0) { | 157 if (pageList.length == 0) { |
| 158 for (var j = 1; j <= totalPageCount; ++j) | 158 for (var j = 1; j <= totalPageCount; ++j) |
| 159 pageList.push(j); | 159 pageList.push(j); |
| 160 } | 160 } |
| 161 return pageList; | 161 return pageList; |
| 162 } | 162 } |
| 163 | 163 |
| 164 /** | 164 /** |
| 165 * @param {!Array.<number>} pageList The list to be processed. | 165 * @param {!Array.<number>} pageList The list to be processed. |
| 166 * @return {!Array.<number>} The contents of |pageList| in ascending order and | 166 * @return {!Array.<number>} The contents of |pageList| in ascending order and |
| 167 * without any duplicates. |pageList| is not affected. | 167 * without any duplicates. |pageList| is not affected. |
| 168 */ | 168 */ |
| 169 function pageListToPageSet(pageList) { | 169 function pageListToPageSet(pageList) { |
| 170 var pageSet = []; | 170 var pageSet = []; |
| 171 if (pageList.length == 0) | 171 if (pageList.length == 0) |
| 172 return pageSet; | 172 return pageSet; |
| 173 pageSet = pageList.slice(0); | 173 pageSet = pageList.slice(0); |
| 174 pageSet.sort(function(a, b) { | 174 pageSet.sort(function(a, b) { |
| 175 return (/** @type {number} */ a) - (/** @type {number} */ b); | 175 return /** @type {number} */(a) - /** @type {number} */(b); |
| 176 }); | 176 }); |
| 177 pageSet = removeDuplicates(pageSet); | 177 pageSet = removeDuplicates(pageSet); |
| 178 return pageSet; | 178 return pageSet; |
| 179 } | 179 } |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * @param {!HTMLElement} element Element to check for visibility. | 182 * @param {!HTMLElement} element Element to check for visibility. |
| 183 * @return {boolean} Whether the given element is visible. | 183 * @return {boolean} Whether the given element is visible. |
| 184 */ | 184 */ |
| 185 function getIsVisible(element) { | 185 function getIsVisible(element) { |
| (...skipping 10 matching lines...) Expand all 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 |