-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.html
180 lines (175 loc) · 6.63 KB
/
post.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>codetest</title>
<style>
body {
font-family: Arial;
}
.dinput{
display: flex;
margin: 5px;
}
.linput{
margin-top: 10px;
margin-right: 10px;
width: 50px;
text-align: right;
}
.dcontrol{
margin-top: 10px;
margin-left: 10px;
}
.lnummode{
margin-right: 5px;
}
.tresult{
background-color: #eee;
color: #555;
border: solid 1px;
border-radius: 2px;
}
.dcontents{
display: flex;
}
.pproblem{
border: dashed 1px;
margin-top: 5px;
padding: 5px;
}
.pcode{
border: dashed 1px;
background-color: #eee;
margin-top: 5px;
padding: 5px;
}
.dpane{
margin: 10px;
box-shadow: 0px 0px 10px 0 #0002;
padding: 10px;
min-width: 500px;
}
</style>
</head>
<body>
<div class="dcontents">
<div class="dpane">
<div class="dinputs">
<div class="dinput">
<label class="linput" for="tcode" >code: </label>
<textarea id="tcode" rows="10" cols="40"></textarea>
</div>
<div class="dinput">
<label class="linput" for="tstdin">stdin:</label>
<textarea id="tstdin" rows="10" cols="40"></textarea>
</div>
</div>
<div class="dcontrol">
<label class="lnummode" id="lnummode" for="cnummode">number mode:<input type="checkbox" id="cnummode"></label>
<input type="button" onclick="run();" id="brun" value="run">
<input type="button" onclick="submit();" id="bsubmit" value="submit" disabled>
</div>
<div class="dinput">
<textarea id="tresult" class="tresult" rows="5" cols="60" disabled></textarea>
</div>
</div>
<div class="dpane">
<select id="sproblems" onchange="select();">
<option>loading...</option>
</select>
<br>
<br>
<div id="dproblem">
<span class="ssample">problem : </span>
<pre class="pcode" id="pproblem"></pre>
<span class="ssample">sample_in : </span>
<pre class="pcode" id="psamplein"></pre>
<span class="ssample">sample_out : </span>
<pre class="pcode" id="psampleout"></pre>
</div>
</div>
</div>
<script>
const interpreter = "https://script.google.com/macros/s/AKfycbyWQ2vBq09Imy7kW7nHowEq8XSB1a6UgNxYcdENkc_nIBTiUm_XBwm5jQn0tk8zbQgJ/exec";
const judge = "https://script.google.com/macros/s/AKfycbyuf5r0Bsdx0At0UX0jsmB-sYNw1oKaQ1J1OVr3BrbDLzeE--11bgLotST-nksKzG3-NQ/exec";
let tcode = document.getElementById("tcode");
let tstdin = document.getElementById("tstdin");
let tresult = document.getElementById("tresult");
let cnummode = document.getElementById("cnummode");
let brun = document.getElementById("brun");
let bsubmit = document.getElementById("bsubmit");
let sproblems = document.getElementById("sproblems");
let dproblem = document.getElementById("dproblem");
let pproblem = document.getElementById("pproblem");
let psamplein = document.getElementById("psamplein");
let psampleout = document.getElementById("psampleout");
function run(){
brun.disabled = true;
bsubmit.disabled = true;
tresult.value = "wait...";
fetch(interpreter,
{
"method" : "POST",
headers: {
Accept: 'application/json',
'Content-Type': 'text/plain',
},
"body" : JSON.stringify({code:tcode.value, input:tstdin.value, nummode:cnummode.checked})
})
.then( raw => raw.json())
.then( result => tresult.value = result.log.join("\n"))
.finally(()=>{brun.disabled=false;bsubmit.disabled=false;});
}
function submit(){
brun.disabled = true;
bsubmit.disabled = true;
tresult.value = "judge...";
fetch(judge,
{
"method" : "POST",
headers: {
Accept: 'application/json',
'Content-Type': 'text/plain',
},
"body" : JSON.stringify({code:tcode.value, id:sproblems.value})
})
.then( raw => raw.json())
.then( result => tresult.value = "["+result.summary+"]\n\n"+ result.results.map((c,i) => "test " + (i+1) + "/" + result.results.length + " : " + "["+c+"]").join("\n"))
.finally(()=>{brun.disabled=false;bsubmit.disabled=false;});
}
bsubmit.disabled = true;
let problemsCache = [];
fetch(judge,
{
"method" : "GET",
headers: {
Accept: 'application/json',
'Content-Type': 'text/plain',
}
}).then(raw=> raw.json()).then(_v=>{
let v = _v.concat();
v.sort((a,b)=> a.name > b.name ? 1 : -1);
sproblems.innerHTML = "";
v.forEach(e => {
let opt = document.createElement("option");
opt.appendChild(document.createTextNode(e.name));
opt.value = e.name;
sproblems.appendChild(opt);
});
problemsCache = v;
select();
bsubmit.disabled = false;
});
function select(){
let problemData = problemsCache.find(e=>e.name == sproblems.value);
pproblem.innerText = problemData.info + (problemData.nummode ? "\n\n(number mode)" : "");
psamplein.innerText = problemData.samplein;
psampleout.innerText = problemData.sampleout;
cnummode.checked = problemData.nummode;
}
</script>
</body>
</html>