src/main/webapp/js/singlepage-interface.js
/**
	 * Create pagination buttons based on a set of results.
	 *
	 * Buttons contain a data-page attribute containing the page index they're displaying - 1.
	 *
	 * @param {any} $pagination <ul> element where the generated pagination will be placed.
	 * @param {any} data a blacklab-server search response containing either groups, docs, or hits.
	 */
Create pagination buttons based on a set of results.
Buttons contain a data-page attribute containing the page index they're displaying - 1.

@param {any} $pagination  element where the generated pagination will be placed.
@param {any} data a blacklab-server search response containing either groups, docs, or hits.
Create pagination buttons based on a set of results . Buttons contain a data - page attribute containing the page index they ' re displaying - 1 . @param { any } $pagination element where the generated pagination will be placed . @param { any } data a blacklab - server search response containing either groups docs or hits .
function updatePagination($pagination, data) {
		var beginIndex = data.summary.windowFirstResult;
		var pageSize = data.summary.requestedWindowSize;
		var totalResults;
		if (data.summary.numberOfGroups != null)
			totalResults = data.summary.numberOfGroups;
		else
			totalResults = (data.hits ? data.summary.numberOfHitsRetrieved : data.summary.numberOfDocsRetrieved);
		if (totalResults < beginIndex)
			beginIndex = totalResults+1;
		var totalPages =  Math.ceil(totalResults / pageSize);
		var currentPage = Math.ceil(beginIndex / pageSize);
		var startPage = Math.max(currentPage - 10, 0);
		var endPage = Math.min(currentPage + 10, totalPages);
		var html = [];
		if (currentPage == 0)
			html.push('<li class="disabled"><a>Prev</a></li>');
		else
			html.push('<li><a href="javascript:void(0)" data-page="', currentPage-1, '">Prev</a></li>');
		if (startPage > 0)
			html.push('<li class="disabled"><a>...</a></li>');
		for (var i = startPage; i < endPage; i++) {
			var showPageNumber = i + 1;
			if (i == currentPage)
				html.push('<li class="active"><a>', showPageNumber, '</a></li>');
			else
				html.push('<li><a href="javascript:void(0)" data-page="', i, '">', showPageNumber, '</a></li>');
		}
		if (endPage < totalPages)
			html.push('<li class="disabled"><a>...</a></li>');
		if (currentPage == (totalPages - 1) || totalPages == 0)
			html.push('<li class="disabled"><a>Next</a></li>');
		else
			html.push('<li><a href="javascript:void(0)" data-page="', currentPage + 1, '">Next</a></li>');
		$pagination.html(html.join(''));
	}
function updatePagination ( $pagination , data ) { var beginIndex = data . summary . windowFirstResult ; var pageSize = data . summary . requestedWindowSize ; var totalResults ; if ( data . summary . numberOfGroups != null ) totalResults = data . summary . numberOfGroups ; else totalResults = ( data . hits ? data . summary . numberOfHitsRetrieved : data . summary . numberOfDocsRetrieved ) ; if ( totalResults < beginIndex ) beginIndex = totalResults + 1 ; var totalPages = Math . ceil ( totalResults / pageSize ) ; var currentPage = Math . ceil ( beginIndex / pageSize ) ; var startPage = Math . max ( currentPage - 10 , 0 ) ; var endPage = Math . min ( currentPage + 10 , totalPages ) ; var html = [ ] ; if ( currentPage == 0 ) html . push ( '<li class="disabled"><a>Prev</a></li>' ) ; else html . push ( '<li><a href="javascript:void(0)" data-page="' , currentPage - 1 , '">Prev</a></li>' ) ; if ( startPage > 0 ) html . push ( '<li class="disabled"><a>...</a></li>' ) ; for ( var i = startPage ; i < endPage ; i ++ ) { var showPageNumber = i + 1 ; if ( i == currentPage ) html . push ( '<li class="active"><a>' , showPageNumber , '</a></li>' ) ; else html . push ( '<li><a href="javascript:void(0)" data-page="' , i , '">' , showPageNumber , '</a></li>' ) ; } if ( endPage < totalPages ) html . push ( '<li class="disabled"><a>...</a></li>' ) ; if ( currentPage == ( totalPages - 1 ) || totalPages == 0 ) html . push ( '<li class="disabled"><a>Next</a></li>' ) ; else html . push ( '<li><a href="javascript:void(0)" data-page="' , currentPage + 1 , '">Next</a></li>' ) ; $pagination . html ( html . join ( '' ) ) ; }
Create pagination buttons based on a set of results.
Create pagination buttons based on a set of results .
// when out of bounds results, draw at least the last few pages so the user can go back