% if (_.isNumber(totalRecords)) { %>
<% } %>
<%
if (_.isNumber(totalPages)) {
var start = Math.max(Math.min(currentPage - 2, totalPages - 4), 1);
var end = Math.min(Math.max(currentPage, 3) + 2, totalPages);
} else {
var start = Math.max(currentPage - 2, 1);
// If we don't have a count, they are only allowed to go forward one page
// at a time, to avoid going "off the end".
// The link for the next page is below.
var end = currentPage;
}
%>
<% if (start > 2) { %>
- 1…
<% } else if (start == 2) { %>
- 1
<% } %>
<% for (var i = start; i <= end; i ++) { %>
<% if (currentPage == i) { %>
- <%= i %>
<% } else { %>
- <%= i %>
<% } %>
<% } %>
<% if (_.isNumber(totalPages)) { %>
<% if (end < totalPages - 1) { %>
- …<%= totalPages %>
<% } else if (end == totalPages - 1) { %>
- <%= totalPages %>
<% } %>
<% } else { %>
- <%= i %>…
<% } %>