-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
220 lines (216 loc) · 6.68 KB
/
index.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8" />
<title>TLE</title>
<script src="js/react.min.js"></script>
<script src="js/react-dom.min.js"></script>
<script src="js/browser.min.js"></script>
<link href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<style>
* {
padding: 0;
margin: 0;
}
body { padding-top: 70px; }
.card h4 {
margin-top: 0;
}
.label {
vertical-align: calc(1px);
}
.panel-body {
padding: 15px 10px;
}
.panel {
margin-bottom: 15px;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">TLE</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</header>
<main id="main" class="container"></main>
<script src="https://cdn.jsdelivr.net/g/[email protected],[email protected]"></script>
<script type="text/babel">
var Icon = React.createClass({
render: function() {
var classStr = "glyphicon glyphicon-" + this.props.name;
return <span className = {classStr} />;
}
});
var ItemUsername = React.createClass({
render: function() {
return <div className = "col-md-4 col-sm-6">
<Icon name="user" />
{this.props.username}
</div>
}
});
var ItemLanguage = React.createClass({
render: function() {
return <div className = "col-md-2 col-sm-6">
<Icon name="comment" />
{this.props.language}
</div>
}
});
var ItemTime = React.createClass({
render: function() {
var time = new Date(this.props.time),
formattedTime = time.getUTCHours() + ":" + time.getUTCMinutes() + ":" + time.getUTCSeconds();
return <div className = "col-md-2 col-sm-6">
<Icon name="time" />
{formattedTime}
</div>
}
});
var ItemVerdict = React.createClass({
render: function() {
var verdict = this.props.verdict,
label = "default",
labelMapping = {
"accepted": "success",
"wrong answer": "danger",
"time limit exceeded": "danger",
"memory limit exceeded": "danger",
"run time error": "danger"
}, scoreFormatted = "";
if (verdict.toLowerCase() in labelMapping) {
label = labelMapping[verdict.toLowerCase()];
}
label = "label label-" + label;
if (this.props.problemType === "IOI") {
scoreFormatted = " (" + this.props.score + ")";
}
return <div className = "col-md-4 col-sm-6">
<Icon name = "certificate" />
<div className = {label}>{verdict}{scoreFormatted}</div>
</div>
}
});
var Item = React.createClass({
render: function() {
return <div className = "card panel panel-default">
<div className = "panel-body">
<h4>
<a href={this.props.data.problem_url}>{this.props.data.problem_name}</a>
</h4>
<div className = "flex">
<ItemTime time={this.props.data.submission_time} />
<ItemUsername username={this.props.data.submission_user} />
<ItemLanguage language={this.props.data.submission_language} />
<ItemVerdict
verdict = {this.props.data.submission_verdict}
score = {this.props.data.submission_score}
problemType = {this.props.data.problem_type}
/>
</div>
</div>
</div>
}
});
var ItemContainer = React.createClass({
render: function() {
var items = [];
for (var datum of this.props.data) {
items.push(
<Item data = {datum} />
);
}
return <div> {items} </div>
}
});
/*
- problem_id ?
- problem_name
- problem_type (ICPC or IOI)
- problem_url
- submission_time
- submission_user
- submission_language
- submission_verdict
- submission_score (0 if ICPC)
*/
var Main = React.createClass({
getInitialState: function() {
return {data: [{
problem_id: 217,
problem_name: "Robot Penjaga",
problem_type: "IOI",
problem_url: "https://training.ia-toki.org/training/curriculums/2/courses/9/sessions/49/problems/217/",
submission_time: "2016-02-07T09:32:42Z",
submission_user: "vincentsthe",
submission_language: "Pascal",
submission_verdict: "Accepted",
submission_score: 100
}, {
problem_id: 217,
problem_name: "Robot Penjaga",
problem_type: "IOI",
problem_url: "https://training.ia-toki.org/training/curriculums/2/courses/9/sessions/49/problems/217/",
submission_time: "2016-02-07T09:41:42Z",
submission_user: "Kenrick95",
submission_language: "Pascal",
submission_verdict: "Memory Limit Exceeded",
submission_score: 99
}, {
problem_id: 17,
problem_name: "Kawal Pemilu",
problem_type: "ICPC",
problem_url: "https://training.ia-toki.org/problemsets/9/problems/17/",
submission_time: "2016-02-05T23:41:42Z",
submission_user: "Lorem ipsum dolor sit amet",
submission_language: "Python 3",
submission_verdict: "Time Limit Exceeded",
submission_score: 0
}] };
},
componentDidMount: function() {
document.addEventListener("keypress", this.handleKeydown, false);
},
componentDidUpdate: function() {
localStorage.reactState = JSON.stringify(this.state);
},
render: function() {
return (<div>
<ItemContainer
id="itemContainer"
data={this.state.data}
/>
</div>);
}
});
ReactDOM.render(
<Main/>,
document.getElementById('main')
);
</script>
</body>
</html>