From 84212304276ef55602ac7e190f60ae5898f6dea7 Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Sat, 18 Feb 2017 23:05:26 +0800 Subject: [PATCH 1/4] Add auto-complete to data file fields --- models/problem.js | 4 ++-- views/problem_data.ejs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) 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 %> From 1d8733fff29118b5b45afb162d536e075b884b80 Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Sun, 19 Feb 2017 15:31:48 +0800 Subject: [PATCH 2/4] Prevent pending cases from being expanded --- views/submission_content.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/submission_content.ejs b/views/submission_content.ejs index 0bdec16..3236511 100644 --- a/views/submission_content.ejs +++ b/views/submission_content.ejs @@ -106,7 +106,7 @@ for (let s of judge.result.subtasks) { <% } %> <% for (let i = 0; i < subtask_cases.case_num; i++) { %> <% let testcase = subtask_cases[i]; %> -
style="cursor: auto; "<% } %>> +
style="cursor: auto; "<% } %>>
测试点 #<%= i + 1 %>
From a485ea82b9fdfaf60e3a8bfd897cb809c488983c Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Sun, 19 Feb 2017 15:42:49 +0800 Subject: [PATCH 3/4] A minor change to wording --- views/problem_data.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/problem_data.ejs b/views/problem_data.ejs index 1992a32..81c1a31 100644 --- a/views/problem_data.ejs +++ b/views/problem_data.ejs @@ -116,7 +116,7 @@ let subtaskType = {
<% } %>
- +
From a0ade9138a2d0d5e0b372ee65186dc69b41e0568 Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Sun, 19 Feb 2017 19:50:44 +0800 Subject: [PATCH 4/4] Disable problem creation when not logged in --- modules/problem.js | 1 + views/problems.ejs | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/problem.js b/modules/problem.js index ddc4028..6766fb6 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -84,6 +84,7 @@ app.get('/problem/:id/edit', async (req, res) => { let problem = await Problem.fromID(id); if (!problem) { + if (!res.locals.user) throw 'Permission denied.'; problem = await Problem.create(); problem.id = id; problem.allowedEdit = true; diff --git a/views/problems.ejs b/views/problems.ejs index c253b53..bbbf7e2 100644 --- a/views/problems.ejs +++ b/views/problems.ejs @@ -1,13 +1,15 @@ <% this.title = '题库' %> <% include header %>
-
-
-
- 添加题目 + <% if (user) { %> +
+
+
-
+ <% } %>