Browse Source

Add display code length

master
Menci 8 years ago
parent
commit
6b41a8f072
  1. 1
      package.json
  2. 8
      utility.js
  3. 6
      views/judge_detail_item.ejs
  4. 4
      views/judge_state.ejs
  5. 4
      views/judge_state_item.ejs

1
package.json

@ -30,6 +30,7 @@
"ejs": "^2.5.2",
"express": "^4.14.0",
"express-session": "^1.14.1",
"file-size": "^1.0.0",
"gravatar": "^1.5.2",
"md5": "^2.2.1",
"moemark-renderer": "^1.2.0",

8
utility.js

@ -32,6 +32,7 @@ let querystring = require('querystring');
let pygmentize = require('pygmentize-bundled-cached');
let gravatar = require('gravatar');
let AdmZip = require('adm-zip');
let filesize = require('file-size');
function escapeHTML(s) {
// Code from http://stackoverflow.com/questions/5251520/how-do-i-escape-some-html-in-javascript/5251551
@ -102,6 +103,13 @@ module.exports = {
}
return util.format('%s:%s:%s', toStringWithPad(x / 3600), toStringWithPad(x / 60 % 60), toStringWithPad(x % 60));
},
formatSize(x) {
let res = filesize(x, { fixed: 1 }).calculate();
if (res.result === parseInt(res.result)) res.fixed = res.result.toString();
if (res.suffix === 'Bytes') res.suffix = 'B';
else res.suffix = res.suffix.replace('iB', '');
return res.fixed + ' ' + res.suffix;
},
parseDate(s) {
return parseInt(+new Date(s) / 1000);
},

6
views/judge_detail_item.ejs

@ -8,7 +8,7 @@
<th>分数</th>
<th>总时间</th>
<th>内存</th>
<th>语言</th>
<th>代码</th>
<th>提交者</th>
<th>提交时间</th>
</tr>
@ -24,8 +24,8 @@
</td>
<td class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= judge.result.max_memory %> KiB</td>
<td><%= syzoj.config.languages[judge.language].show %></td>
<td><%= judge.result.max_memory %> K</td>
<td><%= syzoj.config.languages[judge.language].show %> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

4
views/judge_state.ejs

@ -15,7 +15,7 @@
</div>
<% } %>
</div><br>
<table class="ui very basic center aligned table">
<table class="ui very basic center aligned table" style="white-space: nowrap; ">
<thead>
<tr>
<th>编号</th>
@ -24,7 +24,7 @@
<th>分数</th>
<th>总时间</th>
<th>内存</th>
<th>语言</th>
<th>代码</th>
<th>提交者</th>
<th>提交时间</th>
</tr>

4
views/judge_state_item.ejs

@ -10,8 +10,8 @@
</a></td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= judge.result.max_memory %> KiB</td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a></td>
<td><%= judge.result.max_memory %> K</td>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

Loading…
Cancel
Save