Browse Source

Add auto-complete to data file fields

pull/6/head
Pisces000221 8 years ago
parent
commit
8421230427
  1. 4
      models/problem.js
  2. 13
      views/problem_data.ejs

4
models/problem.js

@ -223,8 +223,8 @@ class Problem extends Model {
is_public: false,
file_io: false,
file_io_input_name: 'data.in',
file_io_output_name: 'data.out'
file_io_input_name: '',
file_io_output_name: ''
}, val)));
}

13
views/problem_data.ejs

@ -134,5 +134,18 @@ function goDisable() {
document.getElementById('file-io-input-name').disabled = true;
document.getElementById('file-io-output-name').disabled = true;
}
$(document).ready(function () {
$('#file-io-input-name').on('input keyup change', function (e) {
var prob = $('#file-io-input-name').val();
if (prob.lastIndexOf('.') !== -1) prob = prob.substring(0, prob.lastIndexOf('.'));
$('#file-io-output-name').attr('placeholder', prob + '.out');
});
$('#file-io-output-name').focus(function (e) {
if (!$('#file-io-output-name').val()) {
$('#file-io-output-name').val($('#file-io-output-name').attr('placeholder'));
}
});
});
</script>
<% include footer %>

Loading…
Cancel
Save