OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * Returns true if |toTest| contains only digits. Leading and trailing | 6 * Returns true if |toTest| contains only digits. Leading and trailing |
7 * whitespace is allowed. | 7 * whitespace is allowed. |
8 * @param {string} toTest The string to be tested. | 8 * @param {string} toTest The string to be tested. |
9 */ | 9 */ |
10 function isInteger(toTest) { | 10 function isInteger(toTest) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 | 182 |
183 /** | 183 /** |
184 * Constructs a url for getting a specific page. | 184 * Constructs a url for getting a specific page. |
185 * @param {string} id The id of the preview data. | 185 * @param {string} id The id of the preview data. |
186 * @param {number} pageNumber The number of the desired page. | 186 * @param {number} pageNumber The number of the desired page. |
187 * @return {string} The constructed URL. | 187 * @return {string} The constructed URL. |
188 */ | 188 */ |
189 function getPageSrcURL(id, pageNumber) { | 189 function getPageSrcURL(id, pageNumber) { |
190 return 'chrome://print/' + id + '/' + pageNumber + '/print.pdf'; | 190 return 'chrome://print/' + id + '/' + pageNumber + '/print.pdf'; |
191 } | 191 } |
192 | |
193 | |
194 /** | |
195 * Returns a random integer within the specified range, |endPointA| and | |
196 * |endPointB| are included. | |
197 * @param {number} endPointA One end of the desired range. | |
198 * @param {number} endPointB The other end of the desired range. | |
199 * @return {number} The random integer. | |
200 */ | |
201 function getRandomIntegerWithinRange(endPointA, endPointB) { | |
Lei Zhang
2011/08/10 03:26:07
I think most people call this function "randInt()"
dpapad
2011/08/10 15:47:10
Renamed to randomInteger() instead of randInt(). A
| |
202 from = Math.min(endPointA, endPointB); | |
203 to = Math.max(endPointA, endPointB); | |
204 return Math.floor(Math.random() * (to - from + 1) + from); | |
205 } | |
OLD | NEW |