<% var paginationAmount = Math.ceil(totalpages / perpages); var pageNR = Math.ceil(current/perpages); var pages = []; pages.push.apply(pages, [pageNR-2,pageNR-1,pageNR,pageNR+1,pageNR+2]); %> 1 <% if(totalpages > perpages) { %> <% $.each(pages, function(index, page){ %> <% if (page > 0 && page < paginationAmount-1) { %> <% if ( index == 0 || index == 4) {%> ... <% } else if (index > 0 && index < 4) { %> <%= page+1 %> <%} %> <% }else if(page == 0){ %> <% } %> <% }); %> <% if (pageNR != paginationAmount) { %> <%=paginationAmount%> <%} %> <%} %> <% // this view is built from prepareSeachResults() in searchpage.js %>