Skip to content

Commit e8050eb

Browse files
authored
Fix bugs
1 parent 59f2714 commit e8050eb

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

onbrowserjudge.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const OnBrowserJudge = {
106106

107107
nextTest: function() {
108108
const testCase = this.restTests.shift()
109-
const input = document.getElementById(`${testCase}_input`).innerText
109+
const input = document.getElementById(`${testCase}_input`).innerText.trim()
110110
const program = this.process(this.getProgram(), testCase, input)
111111
this.timer = setTimeout(() => this.tle(testCase), this.timeLimit * 2)
112112
this.worker.postMessage(["execute", { testCase, program, input }])
@@ -124,7 +124,7 @@ const OnBrowserJudge = {
124124
result = error == 1 ? "CE" : "RE"
125125
} else {
126126
if (execTime > this.timeLimit) result = "TLE"
127-
const expected = document.getElementById(`${testCase}_output`).innerText
127+
const expected = document.getElementById(`${testCase}_output`).innerText.trim()
128128
if (! this.assertEqual(expected, output)) result = "WA"
129129
}
130130

@@ -190,15 +190,11 @@ window.addEventListener("DOMContentLoaded", () => {
190190
}
191191
OnBrowserJudge.tests = getTestNames()
192192

193-
function trimAllTestCases(tests) {
194-
for (const test of tests) {
195-
const input = document.getElementById(`${test}_input`)
196-
const output = document.getElementById(`${test}_output`)
197-
input.innerText = input.innerText.trim()
198-
output.innerText = output.innerText.trim()
199-
}
193+
function trimAllSampleCases() {
194+
const samples = document.getElementsByClassName("sample")
195+
for (const elm of samples) elm.innerText = elm.innerText.trim()
200196
}
201-
trimAllTestCases(OnBrowserJudge.tests)
197+
trimAllSampleCases()
202198

203199
function addCopyButton(elms) {
204200
for (const elm of elms) {

style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ button.copy {
4343
float: right;
4444
}
4545

46-
pre.testcase {
46+
.testcase {
4747
display: none;
4848
}
4949

0 commit comments

Comments
 (0)