You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

105 lines
4.3 KiB

<% this.title = '编辑题目'; %>
<% include header %>
<style type="text/css">
.problem_header{
text-align: center;
}
</style>
<div class="padding">
<form class="ui form" method="post" action="<%= syzoj.utils.makeUrl(['problem', req.params.id, 'edit']) %>">
<div class="ui top attached tabular menu">
<a class="item active" data-tab="edit">编辑</a>
<a class="item" data-tab="preview" id="preview_tab">预览</a>
</div>
<div class="ui bottom attached tab segment active" data-tab="edit">
<div class="field">
<% if (problem.new || user.is_admin) { %>
<label for="id">
<% if (problem.new) { %>
题目编号
<% } else { %>
修改题目编号
<% } %>
</label>
<input type="text" id="id" name="id" placeholder="<% if (problem.new) { %>留空则自动延伸<% } else { %>留空则不修改<% } %>" value="<%= problem.id ? problem.id : '' %>">
<div style="margin-top: 15px; "></div>
<% } %>
<label for="title">题目名称</label>
<input type="text" id="title" name="title" value="<%= problem.title %>">
<label style="margin-top: 15px; " for="description">题目描述</label>
<textarea rows="15" id="description" name="description"><%= problem.description %></textarea>
<label style="margin-top: 15px; " for="input_format">输入格式</label>
<textarea rows="3" id="input" name="input_format"><%= problem.input_format %></textarea>
<label style="margin-top: 15px; " for="output_format">输出格式</label>
<textarea rows="3" id="output" name="output_format"><%= problem.output_format %></textarea>
<label style="margin-top: 15px; ">样例</label>
<textarea rows="15" id="example" name="example"><%= problem.example %></textarea>
<label style="margin-top: 15px; ">数据范围与提示</label>
<textarea rows="10" id="hint" name="limit_and_hint"><%= problem.limit_and_hint %></textarea>
<label style="margin-top: 15px; ">标签</label>
<select class="ui fluid search dropdown" multiple="" id="search_tags" name="tags">
<% for (let tag of problem.tags) { %>
<option value="<%= tag.id %>" selected><%= tag.name %></option>
<% } %>
</select>
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="preview" id="preview">
<h1 class="ui header problem_header" id="pv-title"></h1>
<h2 class="ui header">题目描述</h2>
<div id="pv-description"></div>
<h2 class="ui header">输入格式</h2>
<div id="pv-input"></div>
<h2 class="ui header">输出格式</h2>
<div id="pv-output"></div>
<h2 class="ui header">样例</h2>
<div id="pv-example"></div>
<h2 class="ui header">数据范围与提示</h2>
<div id="pv-hint"></div>
</div>
<% if (problem.allowedEdit) { %>
<button type="submit" class="ui button">提交</button>
<% } %>
</form>
</div>
<script type="text/javascript">
$(function () {
function render(output, input) {
$.post('/api/markdown', { s: input.val() }, function (s) {
// console.log(s);
output.html(s);
});
}
$("#preview_tab").click(function () {
$("#pv-title").text($("#title").val());
$("#pv-description, #pv-input, #pv-output, #pv-example, #pv-hint").text('Loading...');
render($("#pv-description"), $("#description"));
render($("#pv-input"), $("#input"));
render($("#pv-output"), $("#output"));
render($("#pv-example"), $("#example"));
render($("#pv-hint"), $("#hint"));
});
$('.tabular.menu .item').tab();
});
</script>
<script>
$(function () {
$('#search_tags')
.dropdown({
debug: true,
apiSettings: {
url: '/api/v2/search/tags/{query}',
onResponse: function (response) {
var a = $('#search_tags').val().map(function (x) { return parseInt(x) });
if (response.results) {
response.results = response.results.filter(x => !a.includes(parseInt(x.value)));
}
return response;
},
cache: false
}
});
});
</script>
<% include footer %>