diff --git a/models/problem.js b/models/problem.js index 79be434..1f15fa0 100644 --- a/models/problem.js +++ b/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))); } diff --git a/views/problem_data.ejs b/views/problem_data.ejs index 2e086a7..1992a32 100644 --- a/views/problem_data.ejs +++ b/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')); + } + }); +}); <% include footer %>