Browse Source

Move sorting to utils.

pull/6/head
t123yh 7 years ago
parent
commit
9f26ef468c
  1. 17
      views/ranklist.ejs
  2. 15
      views/util.ejs

17
views/ranklist.ejs

@ -1,23 +1,6 @@
<% this.title = '排名' %> <% this.title = '排名' %>
<% include header %> <% include header %>
<%
const getOrderString = function(order) {
return order ? 'asc' : 'desc';
}
const createSortableTitle = function(item, display, defaultOrder) {
const isCurrent = curSort === item;
console.log("IScurrent: ========> " + isCurrent);
const url = syzoj.utils.makeUrl(['ranklist'],
{
sort: item,
order: getOrderString(isCurrent ? (!curOrder) : defaultOrder)
});
const triangle = isCurrent ? `<i class="${curOrder ? "angle up" : "angle down"} icon"></i>` : "";
return `<a href="${url}">${display}${triangle}</a>`;
}
%>
<div class="padding"> <div class="padding">
<form action="<%= syzoj.utils.makeUrl(['find_user']) %>" class="ui mini form" method="get" role="form" style="margin-bottom: 25px; text-align: right; "> <form action="<%= syzoj.utils.makeUrl(['find_user']) %>" class="ui mini form" method="get" role="form" style="margin-bottom: 25px; text-align: right; ">
<div class="ui action left icon input inline" style="width: 180px; margin-right: 77px; "> <div class="ui action left icon input inline" style="width: 180px; margin-right: 77px; ">

15
views/util.ejs

@ -4,6 +4,21 @@ this.getStatusMeta = (status) => {
else return status; else return status;
}; };
const getOrderString = function(order) {
return order ? 'asc' : 'desc';
}
this.createSortableTitle = function(item, display, defaultOrder) {
const isCurrent = curSort === item;
console.log(isCurrent ? (!curOrder) : defaultOrder)
const url = syzoj.utils.makeUrl(req,
Object.assign({}, req.query, {
sort: item,
order: getOrderString(isCurrent ? (!curOrder) : defaultOrder)
}));
const triangle = isCurrent ? `<i class="${curOrder ? "angle up" : "angle down"} icon"></i>` : "";
return `<a href="${url}">${display}${triangle}</a>`;
}
this.isPending = (status) => { this.isPending = (status) => {
let pending = [ let pending = [
'Waiting', 'Waiting',

Loading…
Cancel
Save