<% 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.allowedManage) { %> <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 class="font-content" type="text" id="title" name="title" value="<%= problem.title %>"> <label style="margin-top: 15px; " for="description">题目描述</label> <textarea class="font-content" rows="15" id="description" name="description"><%= problem.description %></textarea> <label style="margin-top: 15px; " for="input_format">输入格式</label> <textarea class="font-content" rows="10" id="input" name="input_format"><%= problem.input_format %></textarea> <label style="margin-top: 15px; " for="output_format">输出格式</label> <textarea class="font-content" rows="10" id="output" name="output_format"><%= problem.output_format %></textarea> <label style="margin-top: 15px; ">样例</label> <textarea class="font-content" rows="15" id="example" name="example"><%= problem.example %></textarea> <label style="margin-top: 15px; ">数据范围与提示</label> <textarea class="font-content" 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 class="ui <% if (problem.is_anonymous) { %>checked <% } %>checkbox" style="margin-top: 15px; "> <input <% if (problem.is_anonymous) { %>checked=""<% } %> name="is_anonymous" type="checkbox"> <label><strong>匿名上传</strong></label> <p style="margin-top: 5px; ">选择后,上传者的用户名将不在题目页面中显示。</p> </div> </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 class="font-content" id="pv-description"></div> <h2 class="ui header">输入格式</h2> <div class="font-content" id="pv-input"></div> <h2 class="ui header">输出格式</h2> <div class="font-content" id="pv-output"></div> <h2 class="ui header">样例</h2> <div class="font-content" id="pv-example"></div> <h2 class="ui header">数据范围与提示</h2> <div class="font-content" 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(), _csrf: document.head.getAttribute('data-csrf-token') }, 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(function(x) { return !a.includes(parseInt(x.value));}); } return response; }, cache: false } }); }); </script> <% include footer %>