算法评测平台前端。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.7 KiB

8 years ago
<% if (paginate.pageCnt) { %>
<div class="ui center aligned grid">
<div class="ui buttons">
<a class="ui<% if (paginate.currPage === 1) { %> disabled<% } %> button" <% if (paginate.currPage !== 1) { %>href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage - 1 })) %>" <% } %>id="page_prev">
<i class="left chevron icon"></i>
</a>
8 years ago
<%
8 years ago
let leftCnt = paginate.currPage - 1, rightCnt = paginate.pageCnt - paginate.currPage, omitLeft = leftCnt > 4, omitRight = rightCnt > 4;
8 years ago
if (omitLeft) leftCnt = 3;
if (omitRight) rightCnt = 3;
if (omitLeft) {
%>
<li><span>...</span></li>
<%
}
8 years ago
for (let i = paginate.currPage - leftCnt; i < paginate.currPage; i++) { %>
<a class="ui button" href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: i })) %>"><%= i %></a>
8 years ago
<%
}
%>
8 years ago
<a class="ui primary button" href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage })) %>"><%= paginate.currPage %></a>
<% for (let i = paginate.currPage + 1; i <= paginate.currPage + rightCnt; i++) { %>
<a class="ui button" href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: i })) %>"><%= i %></a>
8 years ago
<%
}
if (omitRight) {
%>
<li><span>...</span></li>
<% } %>
<a class="ui<% if (paginate.currPage === paginate.pageCnt) { %> disabled<% } %> button" <% if (paginate.currPage !== paginate.pageCnt) { %>href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage + 1 })) %>" <% } %>id="page_next">
<i class="right chevron icon"></i>
</a>
</div>
8 years ago
</div>
<% } %>