/**
* Builds the page navigation for collections, e.g. for search results.
* Provides a series of page numbers for direct access to page X within a collection.
* @param collName The collection's field name
* @param foundTotal The total number of documents found in the collection
* @param foundFrom The starting index of the current page
* @param foundTo The ending index of the current page
* @param maxDocs The maximum number of documents to be displayed per page. NOTE: For this parameter to be available, the extension to the "Collection" Script Library of this WebGate will be required.
*/
function buildCollNavigation (collName, foundTotal, foundFrom, foundTo, maxDocs) {
var pages = Math.ceil(foundTotal/maxDocs); // Number of pages to display in navigation
var thisPage = Math.ceil((foundFrom-1)/maxDocs) + 1; // Current page
var nextPage = "";
var startDoc = 0;
var outputString = "";
var href = new String(window.location.href);
var pathname = window.location.pathname;
var query_string = href.substring(href.indexOf(pathname) + pathname.length, href.length);
var new_query_string = "";
var new_query_string_base = "";
// Build base URL for page links
var startDocPos = query_string.indexOf(collName + "-StartDoc");
if (startDocPos == -1)
new_query_string_base = query_string;
else {
// Eliminate collName + "-StartDoc=xx" from query string
if (query_string.indexOf('&', startDocPos + 1) == -1)
new_query_string_base = query_string.substr(0, startDocPos-1);
else
new_query_string_base = query_string.substr(0, startDocPos-1) + query_string.substring(query_string.indexOf('&', startDocPos + 1),query_string.length-1);
}
// Make sure the ?Open command is contained.
if (new_query_string_base == "") new_query_string_base = "?Open";
// Construct page links
for (page = 1; page <= pages; page++) {
nextPage = page + ' ';
if (page != thisPage) {
// Create link, not current page
startDoc = (page != pages) ? (page-1) * maxDocs : (foundTotal - maxDocs);
outputString = '' + nextPage + '';
} else {
outputString = '' + nextPage + '';
}
document.write (outputString);
}
}