You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.4 KiB
85 lines
3.4 KiB
<% 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; "> |
|
<i class="search icon"></i><input name="nickname" placeholder="用户名" type="text"> |
|
<button class="ui mini button" type="submit">查找用户</button> |
|
</div> |
|
</form> |
|
<table class="ui very basic center aligned table" style="table-layout: fixed; "> |
|
<thead> |
|
<tr> |
|
<th style="width: 60px; ">#</th> |
|
<th style="width: 60px; "><%- createSortableTitle('id', 'ID', true) %></th> |
|
<th style="width: 150px; "><%- createSortableTitle('username', '用户名', true) %></th> |
|
<th>个性签名</th> |
|
<th style="width: 100px; "><%- createSortableTitle('ac_num', '通过数量', false) %></th> |
|
<th style="width: 100px; "><%- createSortableTitle('rating', 'Rating', false) %></th> |
|
</tr> |
|
</thead> |
|
<script> |
|
var lineHeight = 0; |
|
(function () { |
|
var div = document.createElement('div'); |
|
div.style.position = 'fixed'; |
|
div.style.left = -10000; |
|
div.style.visibility = 'hidden'; |
|
div.innerText = '测试,Test.'; |
|
document.body.appendChild(div); |
|
lineHeight = div.clientHeight; |
|
})(); |
|
</script> |
|
<tbody> |
|
<% |
|
let i = (paginate.currPage - 1) * paginate.perPage; |
|
for (let user of ranklist) { |
|
++i; |
|
%> |
|
<tr> |
|
<td><%= i %></td> |
|
<td><%= user.id %></td> |
|
<td><a href="<%= syzoj.utils.makeUrl(['user', user.id]) %>"><%= user.username %></a><% if (user.nameplate) { %><%- user.nameplate %><% } %></td> |
|
<td class="font-content"> |
|
<script id="user-infomation-script-<%= i %>"> |
|
(function () { |
|
var html = <%- JSON.stringify(user.information) %>; |
|
var elem = document.createElement('div'); |
|
elem.style = 'overflow: hidden; width: 100%; position: relative; '; |
|
elem.style.maxHeight = lineHeight + 'px'; |
|
elem.innerHTML = html; |
|
var imgs = Array.prototype.slice.call(elem.getElementsByTagName('img')); |
|
for (var i in imgs) imgs[i].parentNode.removeChild(imgs[i]); |
|
var script = document.getElementById('user-infomation-script-<%= i %>'); |
|
script.parentNode.replaceChild(elem, script); |
|
})(); |
|
</script> |
|
</td> |
|
<td><%= user.ac_num %></td> |
|
<td><%= user.rating %></td> |
|
</tr> |
|
<% } %> |
|
</tbody> |
|
</table> |
|
<br> |
|
<% include page %> |
|
</div> |
|
<% include footer %>
|
|
|