Browse Source

Left / right arrow keys to switch pages in problem set

pull/6/head
Menci 8 years ago
parent
commit
1cd19f73f1
  1. 4
      views/page.ejs
  2. 6
      views/problem_set.ejs

4
views/page.ejs

@ -1,7 +1,7 @@
<% if (paginate.pageCnt) { %>
<div class="ui center aligned grid">
<div class="ui buttons">
<a class="ui<% if (paginate.currPage === 1) { %> disabled<% } %> button" href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage - 1 })) %>">
<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>
<%
@ -27,7 +27,7 @@
%>
<li><span>...</span></li>
<% } %>
<a class="ui<% if (paginate.currPage === paginate.pageCnt) { %> disabled<% } %> button" href="<%= syzoj.utils.makeUrl(req, Object.assign(req.query, { page: paginate.currPage + 1 })) %>">
<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>

6
views/problem_set.ejs

@ -49,5 +49,11 @@
</tbody>
</table><br>
<% include page %>
<script>
document.addEventListener('keydown', function (event) {
if (event.keyCode === 39) document.getElementById('page_next').click();
else if (event.keyCode === 37) document.getElementById('page_prev').click();
});
</script>
</div>
<% include footer %>

Loading…
Cancel
Save