Browse Source

Remove arrow functions.

pull/6/head
t123yh 7 years ago
parent
commit
da3bf556b0
  1. 4
      views/contest_edit.ejs
  2. 2
      views/problem_data.ejs
  3. 2
      views/problem_edit.ejs
  4. 25
      views/submission.ejs
  5. 16
      views/submissions.ejs

4
views/contest_edit.ejs

@ -85,7 +85,7 @@ $(function () {
onResponse: function (response) { onResponse: function (response) {
var a = $('#search_admins').val().map(function (x) { return parseInt(x) }); var a = $('#search_admins').val().map(function (x) { return parseInt(x) });
if (response.results) { if (response.results) {
response.results = response.results.filter(x => !a.includes(parseInt(x.value))); response.results = response.results.filter(function(x){ return !a.includes(parseInt(x.value))});
} }
return response; return response;
}, },
@ -100,7 +100,7 @@ $(function () {
onResponse: function (response) { onResponse: function (response) {
var a = $('#search_problems').val().map(function (x) { return parseInt(x) }); var a = $('#search_problems').val().map(function (x) { return parseInt(x) });
if (response.results) { if (response.results) {
response.results = response.results.filter(x => !a.includes(parseInt(x.value))); response.results = response.results.filter(function(x) {return !a.includes(parseInt(x.value));});
} }
return response; return response;
}, },

2
views/problem_data.ejs

@ -145,7 +145,7 @@ function getIcon(filename) {
</div> </div>
<script> <script>
function check_replace() { function check_replace() {
var old_files = <%- JSON.stringify((testdata && testdata.files ? testdata.files : []).map(x => x.filename)) %>; var old_files = <%- JSON.stringify((testdata && testdata.files ? testdata.files : []).map(function(x) { return x.filename; })) %>;
var replaced_files = Array.prototype.slice.call($('#upload_file')[0].files).map(function (x) { return x.name; }).filter(function (x) { return old_files.includes(x); }); var replaced_files = Array.prototype.slice.call($('#upload_file')[0].files).map(function (x) { return x.name; }).filter(function (x) { return old_files.includes(x); });
var s = ''; var s = '';
for (let file of replaced_files) s += '<samp>' + file + '</samp><br>'; for (let file of replaced_files) s += '<samp>' + file + '</samp><br>';

2
views/problem_edit.ejs

@ -98,7 +98,7 @@ $(function () {
onResponse: function (response) { onResponse: function (response) {
var a = $('#search_tags').val().map(function (x) { return parseInt(x) }); var a = $('#search_tags').val().map(function (x) { return parseInt(x) });
if (response.results) { if (response.results) {
response.results = response.results.filter(x => !a.includes(parseInt(x.value))); response.results = response.results.filter(function(x) { return !a.includes(parseInt(x.value));});
} }
return response; return response;
}, },

25
views/submission.ejs

@ -173,19 +173,20 @@ const vueApp = new Vue({
return statusToString[statusCode]; return statusToString[statusCode];
}, },
firstNonAC(t) { firstNonAC(t) {
if (t.every(v => v === TestcaseResultType.Accepted)) { if (t.every(function(v){ return v === TestcaseResultType.Accepted;})) {
return TestcaseResultType.Accepted; return TestcaseResultType.Accepted;
} else { } else {
return t.find(r => r !== TestcaseResultType.Accepted); return t.find(function(r) { return r !== TestcaseResultType.Accepted;});
} }
}, },
getSubtaskResult(t) { getSubtaskResult(t) {
if (t.cases.some(c => c.status === TaskStatus.Running)) { if (t.cases.some(function(c){ return c.status === TaskStatus.Running;})) {
return "Running"; return "Running";
} else if (t.cases.some(c => c.status === TaskStatus.Waiting)) { } else if (t.cases.some(function(c) { return c.status === TaskStatus.Waiting;})) {
return "Waiting"; return "Waiting";
} else if (t.cases.every(c => c.status === TaskStatus.Done || c.status === TaskStatus.Skipped)) { } else if (t.cases.every(function(c){ return c.status === TaskStatus.Done || c.status === TaskStatus.Skipped;})) {
return this.getStatusString(this.firstNonAC(t.cases.filter(c => c.result).map(c => c.result.type))); return this.getStatusString(this.firstNonAC(t.cases.filter(function(c) { return c.result; })
.map(function(c) { return c.result.type;})));
} else { } else {
return "System Error"; return "System Error";
} }
@ -208,7 +209,7 @@ const vueApp = new Vue({
} }
}, },
mounted() { mounted() {
$(document).ready(() => $('.ui.accordion').accordion()); $(document).ready(function(){ $('.ui.accordion').accordion()});
}, },
updated() { updated() {
$('.ui.accordion').accordion("refresh"); $('.ui.accordion').accordion("refresh");
@ -218,13 +219,13 @@ if (token != null) {
const loadSocketIO = function () { const loadSocketIO = function () {
let currentVersion = 0; let currentVersion = 0;
const socket = io(socketUrl); const socket = io(socketUrl);
socket.on('connect', () => { socket.on('connect', function () {
socket.on('start', () => { socket.on('start', function () {
vueApp.roughData.running = true; vueApp.roughData.running = true;
console.log("Judge start!"); console.log("Judge start!");
vueApp.detailResult = {}; vueApp.detailResult = {};
}); });
socket.on('update', (p) => { socket.on('update', function (p) {
console.log("Delta: " + JSON.stringify(p)); console.log("Delta: " + JSON.stringify(p));
if (p.from === currentVersion) { if (p.from === currentVersion) {
currentVersion = p.to; currentVersion = p.to;
@ -234,14 +235,14 @@ if (token != null) {
setTimeout(loadSocketIO, 0); setTimeout(loadSocketIO, 0);
} }
}); });
socket.on('finish', (p) => { socket.on('finish', function (p) {
console.log("Judge finished"); console.log("Judge finished");
vueApp.roughData.running = false; vueApp.roughData.running = false;
vueApp.roughData.result = p.roughResult; vueApp.roughData.result = p.roughResult;
vueApp.detailResult = p.result; vueApp.detailResult = p.result;
socket.close(); socket.close();
}); });
socket.emit('join', token, (data) => { socket.emit('join', token, function (data) {
console.log("join! " + JSON.stringify(data)); console.log("join! " + JSON.stringify(data));
if (data && data.ok) { if (data && data.ok) {
if (data.finished) { if (data.finished) {

16
views/submissions.ejs

@ -124,24 +124,24 @@ const vueApp = new Vue({
}, },
}); });
if (itemList.some(t => t.token != null)) { if (itemList.some(function(t) {return t.token != null;})) {
const socket = io(socketUrl); const socket = io(socketUrl);
socket.on('connect', () => { socket.on('connect', function () {
for (let x of itemList.filter(x => x.token != null)){ for (let x of itemList.filter(function(x) {return x.token != null;})){
const getItem = (id) => itemList.find(x => x.info.taskId === id); const getItem = function (id){ return itemList.find(function(x){ return x.info.taskId === id; })};
socket.on('start', (data) => { socket.on('start', function (data) {
getItem(data.taskId).running = true; getItem(data.taskId).running = true;
}); });
socket.on('finish', (data) => { socket.on('finish', function (data) {
getItem(data.taskId).running = false; getItem(data.taskId).running = false;
getItem(data.taskId).result = data.result; getItem(data.taskId).result = data.result;
if (itemList.every(x => x.result)) { if (itemList.every(function(x){ return x.result; })) {
socket.close(); socket.close();
} }
}); });
socket.emit('join', x.token, (data) => { socket.emit('join', x.token, function (data) {
if (data && data.ok) { if (data && data.ok) {
if (data.running) { if (data.running) {
x.running = true; x.running = true;

Loading…
Cancel
Save