算法评测平台前端。
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.

126 lines
5.0 KiB

<% include util %>
<% include status_label %>
<script src="https://cdnjs.loli.net/ajax/libs/textfit/2.3.1/textFit.min.js"></script>
7 years ago
<script>
const submissionUrl = <%- JSON.stringify(displayConfig.inContest ?
7 years ago
syzoj.utils.makeUrl(['contest', 'submission', 'VanDarkholme']) :
syzoj.utils.makeUrl(['submission', 'VanDarkholme'])) %>;
const problemUrl = <%- JSON.stringify(displayConfig.inContest ?
syzoj.utils.makeUrl(['contest', contest.id, 'problem', 'VanDarkholme']) :
syzoj.utils.makeUrl(['problem', 'VanDarkholme'])) %>;
const userUrl = <%- JSON.stringify(syzoj.utils.makeUrl(['user', 'VanDarkholme'])) %>;
Vue.component('submission-item', {
template: '#submissionItemTemplate',
props: ['data', 'config', 'showRejudge'],
computed: {
statusString() {
const data = this.data;
if (data.result) {
return data.result.result;
} else if (data.running) {
7 years ago
return this.config.showResult ? 'Running' : 'Compiling';
} else return 'Waiting';
},
submissionLink() {
return submissionUrl.replace('VanDarkholme', this.data.info.submissionId);
},
problemLink() {
return problemUrl.replace('VanDarkholme', this.data.info.problemId);
},
userLink() {
return userUrl.replace('VanDarkholme', this.data.info.userId);
},
scoreClass() {
return "score_" + (parseInt(this.data.result.score / 10) || 0).toString();
}
},
methods: {
alpha(number) {
if (number && parseInt(number) == number && parseInt(number) > 0) return String.fromCharCode('A'.charCodeAt(0) + parseInt(number) - 1);
}
7 years ago
},
mounted() {
7 years ago
textFit(this.$refs.problemLabelTextFit, { maxFontSize: 14 });
}
});
</script>
<script id="submissionItemTemplate" type="text/x-template">
<tr>
<% if (active === 'submissions') { %>
6 years ago
<td><a :href="submissionLink"><b>#{{ data.info.submissionId }}</b></a></td>
<% } else { %>
<td><b>#{{ data.info.submissionId }}</b></td>
<% } %>
<td ref="problemLabel"><a ref="problemLabelTextFit" style="width: 230px; height: 22px; display: block; margin: 0 auto; line-height: 22px;" :href="problemLink"><b>#{{ config.inContest ? alpha(data.info.problemId) : data.info.problemId }}.</b> {{ data.info.problemName }}</a></td>
<% if (active === 'submissions') { %>
6 years ago
<td><a :href="submissionLink"><b><status-label :status="statusString"></status-label></b></a></td>
<% } else { %>
<td><b><status-label :status="statusString"></status-label></b></td>
<% } %>
<template v-if="data.result">
<% if (active === 'submissions') { %>
<td v-if="config.showScore"><a :href="submissionLink"><span class="score" :class="scoreClass">{{ Math.floor(data.result.score || 0) }}</span></a></td>
<% } else { %>
<td v-if="config.showScore"><span class="score" :class="scoreClass">{{ Math.floor(data.result.score || 0) }}</span></td>
<% } %>
<td v-if="config.showUsage">{{ (data.result.time || 0).toString() + ' ms' }}</td>
<td v-if="config.showUsage">{{ (data.result.memory || 0).toString() + ' KiB' }}</td>
</template> <template v-else>
7 years ago
<td v-if="config.showScore"/> <td v-if="config.showUsage"/> <td v-if="config.showUsage"/>
</template>
<td v-if="config.showCode">
<% if (active === 'submissions') { %>
<span v-if="data.info.language"><a :href="submissionLink"><b>{{ data.info.language }}</b></a> / </span>
<% } else { %>
<span v-if="data.info.language"><b>{{ data.info.language }}</b> / </span>
<% } %>
{{ data.info.codeSize }}
</td>
<td><a :href="userLink">{{ data.info.user }}</a></td>
<td>{{ data.info.submitTime }}</td>
<td v-if="showRejudge">
<a id="rejudge-button" :onclick="'check_rejudge(' + (statusString === 'Waiting' || statusString.startsWith('Running')).toString() + ')'" style="color: #000; " href="#"><i class="repeat icon"></i></a>
<% if (active === 'submission') { %>
<div class="ui basic modal" id="modal-rejudge">
<div class="ui icon header">
<i class="retweet icon"></i>
<p style="margin-top: 15px; ">重新评测</p>
</div>
<div class="content" style="text-align: center; ">
<p>确认重新评测该提交记录吗?</p>
<p id="warning_pending"><strong>警告:只有管理员可以重新评测一个未评测完成的记录,<br>这种情况一般发生在评测服务中断后,如果一个提交正在被评测,<br>则将其重新评测会导致系统错乱!</strong></p>
</div>
<div class="actions">
<div class="ui red basic cancel inverted button">
<i class="remove icon"></i>
</div>
<a class="ui green ok inverted button" :href-post="submissionLink + '/rejudge'">
<i class="checkmark icon"></i>
</a>
</div>
</div>
<% } %>
</td>
</tr>
7 years ago
</script>
<% if (active === 'submission') { %>
<script>
function check_rejudge(pending) {
if (pending) {
$('#warning_pending').css('display', '');
} else {
$('#warning_pending').css('display', 'none');
}
$('#modal-rejudge').modal('show');
}
</script>
<% } %>