summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/print_preview/print_preview_utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/resources/print_preview/print_preview_utils.js')
-rw-r--r--chrome/browser/resources/print_preview/print_preview_utils.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/chrome/browser/resources/print_preview/print_preview_utils.js b/chrome/browser/resources/print_preview/print_preview_utils.js
index e16c445..9c19241 100644
--- a/chrome/browser/resources/print_preview/print_preview_utils.js
+++ b/chrome/browser/resources/print_preview/print_preview_utils.js
@@ -3,9 +3,9 @@
// found in the LICENSE file.
/**
- * Returns true if |toTest| contains only digits. Leading and trailing
- * whitespace is allowed.
* @param {string} toTest The string to be tested.
+ * @return {boolean} True if |toTest| contains only digits. Leading and trailing
+ * whitespace is allowed.
*/
function isInteger(toTest) {
var numericExp = /^\s*[0-9]+\s*$/;
@@ -25,7 +25,7 @@ function isPositiveInteger(value) {
/**
* Returns true if the contents of the two arrays are equal.
* @param {Array} array1 The first array.
- * @param {Array} array1 The second array.
+ * @param {Array} array2 The second array.
*
* @return {boolean} true if the arrays are equal.
*/
@@ -33,7 +33,7 @@ function areArraysEqual(array1, array2) {
if (array1.length != array2.length)
return false;
for (var i = 0; i < array1.length; i++)
- if(array1[i] != array2[i])
+ if (array1[i] != array2[i])
return false;
return true;
}
@@ -41,18 +41,18 @@ function areArraysEqual(array1, array2) {
/**
* Removes duplicate elements from |inArray| and returns a new array.
* |inArray| is not affected. It assumes that |inArray| is already sorted.
- *
- * @param {Array} inArray The array to be processed.
+ * @param {array} inArray The array to be processed.
+ * @return {array} The array after processing.
*/
function removeDuplicates(inArray) {
var out = [];
- if(inArray.length == 0)
+ if (inArray.length == 0)
return out;
out.push(inArray[0]);
for (var i = 1; i < inArray.length; ++i)
- if(inArray[i] != inArray[i - 1])
+ if (inArray[i] != inArray[i - 1])
out.push(inArray[i]);
return out;
}
@@ -75,6 +75,8 @@ function removeDuplicates(inArray) {
* Example: "34853253" is valid.
* Example: "1-4, 9, 3-6, 10, 11" is valid.
*
+ * @param {string} pageRangeText The text to be checked.
+ * @param {number} totalPageCount The total number of pages.
* @return {boolean} true if the |pageRangeText| is valid.
*/
function isPageRangeTextValid(pageRangeText, totalPageCount) {
@@ -112,8 +114,9 @@ function isPageRangeTextValid(pageRangeText, totalPageCount) {
* eliminated. If |pageRangeText| is not valid according to
* isPageRangeTextValid(), or |totalPageCount| is undefined an empty list is
* returned.
- *
- * @return {Array}
+ * @param {string} pageRangeText The text to be checked.
+ * @param {number} totalPageCount The total number of pages.
+ * @return {array} A list of all pages.
*/
function pageRangeTextToPageList(pageRangeText, totalPageCount) {
var pageList = [];
@@ -146,17 +149,16 @@ function pageRangeTextToPageList(pageRangeText, totalPageCount) {
}
/**
- * Returns the contents of |pageList| in ascending order and without any
- * duplicates. |pageList| is not affected.
- *
- * @return {Array}
+ * @param {array} pageList The list to be processed.
+ * @return {array} The contents of |pageList| in ascending order and without any
+ * duplicates. |pageList| is not affected.
*/
function pageListToPageSet(pageList) {
var pageSet = [];
if (pageList.length == 0)
return pageSet;
pageSet = pageList.slice(0);
- pageSet.sort(function(a,b) { return a - b; });
+ pageSet.sort(function(a, b) { return a - b; });
pageSet = removeDuplicates(pageSet);
return pageSet;
}
@@ -165,6 +167,8 @@ function pageListToPageSet(pageList) {
* Converts |pageSet| to page ranges. It squashes whenever possible.
* Example: '1-2,3,5-7' becomes 1-3,5-7.
*
+ * @param {array} pageSet The set of pages to be processed. Callers should
+ * ensure that no duplicates exist.
* @return {Array} an array of page range objects. A page range object has
* fields 'from' and 'to'.
*/