<%
var start = Math.max(Math.min(currentPage - 2, totalPages - 4), 1);
var end = Math.min(Math.max(currentPage, 3) + 2, totalPages);
%>
<% if (start > 2) { %>
- 1…
<% } else if (start == 2) { %>
- 1
<% } %>
<% for (var i = start; i <= end; i ++) { %>
<% if (currentPage == i) { %>
- <%= i %>
<% } else { %>
- <%= i %>
<% } %>
<% } %>
<% if (end < totalPages - 1) { %>
- …<%= totalPages %>
<% } else if (end == totalPages - 1) { %>
- <%= totalPages %>
<% } %>