Browse Source

Ctrl + A in judge detail to select all code

master
Menci 8 years ago
parent
commit
5f39780af3
  1. 14
      views/judge_detail_item.ejs

14
views/judge_detail_item.ejs

@ -39,7 +39,19 @@
</tbody>
</table>
<% if (judge.allowedSeeCode) { %>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%- judge.code %></code></pre></div>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code id="code"><%- judge.code %></code></pre></div>
<script>
document.addEventListener('keydown', function (event) {
if ((event.ctrlKey || event.metaKey) && event.key === 'a') {
var sel = window.getSelection();
var rg = document.createRange()
rg.selectNodeContents(document.getElementById('code'));
sel.removeAllRanges();
sel.addRange(rg);
event.preventDefault();
}
});
</script>
<% } %>
<% if (judge.result.compiler_output && judge.result.status === 'Compile Error' && judge.allowedSeeCode) { %>
<h3 class="ui header">编译信息</h3>

Loading…
Cancel
Save