Browse Source

Prevent duplicate submissions on frontend

pull/6/head
Pisces000221 7 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 type="text/javascript">
var editor = ace.edit("editor");
var lastSubmitted = '';
editor.setTheme("ace/theme/tomorrow");
editor.getSession().setMode("ace/mode/" + $('#languages-menu .item.active').data('mode'));
@ -233,9 +234,10 @@ editor.setShowPrintMargin(false);
editor.renderer.updateFontSize();
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=code]').val(editor.getValue());
lastSubmitted = editor.getValue();
$('#submit_code input[name=code]').val(lastSubmitted);
return true;
}

Loading…
Cancel
Save