Browse Source

Prevent duplicate submissions on frontend

pull/6/head
Pisces000221 8 years ago
parent
commit
fa9745b567
  1. 6
      views/problem.ejs

6
views/problem.ejs

@ -221,6 +221,7 @@ if (contest) {
<script src="/libs/ace/ace.js"></script> <script src="/libs/ace/ace.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var editor = ace.edit("editor"); var editor = ace.edit("editor");
var lastSubmitted = '';
editor.setTheme("ace/theme/tomorrow"); editor.setTheme("ace/theme/tomorrow");
editor.getSession().setMode("ace/mode/" + $('#languages-menu .item.active').data('mode')); editor.getSession().setMode("ace/mode/" + $('#languages-menu .item.active').data('mode'));
@ -233,9 +234,10 @@ editor.setShowPrintMargin(false);
editor.renderer.updateFontSize(); editor.renderer.updateFontSize();
function submit_code() { function submit_code() {
if (!editor.getValue().trim()) return false; if (!editor.getValue().trim() || editor.getValue().trim() == lastSubmitted) return false;
$('#submit_code input[name=language]').val($('#languages-menu .item.active').data('value')); $('#submit_code input[name=language]').val($('#languages-menu .item.active').data('value'));
$('#submit_code input[name=code]').val(editor.getValue()); lastSubmitted = editor.getValue();
$('#submit_code input[name=code]').val(lastSubmitted);
return true; return true;
} }

Loading…
Cancel
Save