Browse Source

Left / right arrow keys to switch pages in problem set

master
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) { %> <% if (paginate.pageCnt) { %>
<div class="ui center aligned grid"> <div class="ui center aligned grid">
<div class="ui buttons"> <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> <i class="left chevron icon"></i>
</a> </a>
<% <%
@ -27,7 +27,7 @@
%> %>
<li><span>...</span></li> <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> <i class="right chevron icon"></i>
</a> </a>
</div> </div>

6
views/problem_set.ejs

@ -49,5 +49,11 @@
</tbody> </tbody>
</table><br> </table><br>
<% include page %> <% 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> </div>
<% include footer %> <% include footer %>

Loading…
Cancel
Save