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 = '排名' %>
<% 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">
<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; ">

15
views/util.ejs

@ -4,6 +4,21 @@ this.getStatusMeta = (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) => {
let pending = [
'Waiting',

Loading…
Cancel
Save