From 9ed960b9fa7d26178fd7a9106548bfb0c6b59a73 Mon Sep 17 00:00:00 2001 From: Menci Date: Sun, 23 Apr 2017 00:04:41 +0800 Subject: [PATCH] New pagination UI --- views/page.ejs | 74 ++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/views/page.ejs b/views/page.ejs index c3c89bf..8eae36b 100644 --- a/views/page.ejs +++ b/views/page.ejs @@ -1,35 +1,45 @@ <% if (paginate.pageCnt) { %> -
-
- href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage - 1 })) %>" <% } %>id="page_prev"> - - - <% - let leftCnt = paginate.currPage - 1, rightCnt = paginate.pageCnt - paginate.currPage, omitLeft = leftCnt > 4, omitRight = rightCnt > 4; - if (omitLeft) leftCnt = 3; - if (omitRight) rightCnt = 3; - if (omitLeft) { - %> -
  • ...
  • - <% - } - for (let i = paginate.currPage - leftCnt; i < paginate.currPage; i++) { %> - <%= i %> - <% - } - %> - <%= paginate.currPage %> - <% for (let i = paginate.currPage + 1; i <= paginate.currPage + rightCnt; i++) { %> - <%= i %> - <% - } - if (omitRight) { - %> -
  • ...
  • - <% } %> - href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage + 1 })) %>" <% } %>id="page_next"> - - -
    +
    +
    <% } %>