Skip to content

Commit 6c2aac4

Browse files
committed
Merge branch 'viewer' into 'master'
Viewer See merge request CBCTF/bullseye-web!65
2 parents 4813f54 + 687a29e commit 6c2aac4

File tree

4 files changed

+165
-9
lines changed

4 files changed

+165
-9
lines changed

app/assets/stylesheets/viewer.css

+98-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,98 @@
33
100% {transform: rotate(360deg);}
44
}
55

6+
#bullseye-loading {
7+
display: block;
8+
position: fixed;
9+
top: 0;
10+
left: 0;
11+
width: 100%;
12+
height: 100%;
13+
text-align: center;
14+
z-index: 2;
15+
background: rgba(0,64,128,0.3);
16+
}
17+
#bullseye-loading .loader {
18+
color: rgba(255,255,255,0.6);
19+
font-size: 128px;
20+
text-indent: -9999em;
21+
overflow: hidden;
22+
width: 1em;
23+
height: 1em;
24+
border-radius: 50%;
25+
margin: 180px auto;
26+
position: relative;
27+
-webkit-transform: translateZ(0);
28+
-ms-transform: translateZ(0);
29+
transform: translateZ(0);
30+
-webkit-animation: load6 1.7s infinite ease, round 1.7s infinite ease;
31+
animation: load6 1.7s infinite ease, round 1.7s infinite ease;
32+
}
33+
@-webkit-keyframes load6 {
34+
0% {
35+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
36+
}
37+
5%,
38+
95% {
39+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
40+
}
41+
10%,
42+
59% {
43+
box-shadow: 0 -0.83em 0 -0.4em, -0.087em -0.825em 0 -0.42em, -0.173em -0.812em 0 -0.44em, -0.256em -0.789em 0 -0.46em, -0.297em -0.775em 0 -0.477em;
44+
}
45+
20% {
46+
box-shadow: 0 -0.83em 0 -0.4em, -0.338em -0.758em 0 -0.42em, -0.555em -0.617em 0 -0.44em, -0.671em -0.488em 0 -0.46em, -0.749em -0.34em 0 -0.477em;
47+
}
48+
38% {
49+
box-shadow: 0 -0.83em 0 -0.4em, -0.377em -0.74em 0 -0.42em, -0.645em -0.522em 0 -0.44em, -0.775em -0.297em 0 -0.46em, -0.82em -0.09em 0 -0.477em;
50+
}
51+
100% {
52+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
53+
}
54+
}
55+
@keyframes load6 {
56+
0% {
57+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
58+
}
59+
5%,
60+
95% {
61+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
62+
}
63+
10%,
64+
59% {
65+
box-shadow: 0 -0.83em 0 -0.4em, -0.087em -0.825em 0 -0.42em, -0.173em -0.812em 0 -0.44em, -0.256em -0.789em 0 -0.46em, -0.297em -0.775em 0 -0.477em;
66+
}
67+
20% {
68+
box-shadow: 0 -0.83em 0 -0.4em, -0.338em -0.758em 0 -0.42em, -0.555em -0.617em 0 -0.44em, -0.671em -0.488em 0 -0.46em, -0.749em -0.34em 0 -0.477em;
69+
}
70+
38% {
71+
box-shadow: 0 -0.83em 0 -0.4em, -0.377em -0.74em 0 -0.42em, -0.645em -0.522em 0 -0.44em, -0.775em -0.297em 0 -0.46em, -0.82em -0.09em 0 -0.477em;
72+
}
73+
100% {
74+
box-shadow: 0 -0.83em 0 -0.4em, 0 -0.83em 0 -0.42em, 0 -0.83em 0 -0.44em, 0 -0.83em 0 -0.46em, 0 -0.83em 0 -0.477em;
75+
}
76+
}
77+
@-webkit-keyframes round {
78+
0% {
79+
-webkit-transform: rotate(0deg);
80+
transform: rotate(0deg);
81+
}
82+
100% {
83+
-webkit-transform: rotate(360deg);
84+
transform: rotate(360deg);
85+
}
86+
}
87+
@keyframes round {
88+
0% {
89+
-webkit-transform: rotate(0deg);
90+
transform: rotate(0deg);
91+
}
92+
100% {
93+
-webkit-transform: rotate(360deg);
94+
transform: rotate(360deg);
95+
}
96+
}
97+
698
html, body {
799
height: 100%;
8100
}
@@ -163,11 +255,16 @@ h1, h1 a, #bullseye-logo a {
163255
background: rgba(64,64,64,0.6);
164256
}
165257

166-
#bullseye-problems-autoplay {
258+
#bullseye-problems-autoplay, #bullseye-problems-super-autoplay {
167259
color: #fff;
168260
cursor: pointer;
169261
margin: 12px 0 0 12px;
170262
font-size: 24px;
263+
transition: all 0.2s;
264+
}
265+
#bullseye-problems-autoplay:hover, #bullseye-problems-super-autoplay:hover {
266+
color: rgba(255,255,255,0.6);
267+
font-size: 30px;
171268
}
172269

173270
#bullseye-nowexploiting, #bullseye-result {

app/controllers/external_api/v1/viewer_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def problems
9191
rounds.each do |round|
9292
result[problem.id][:round][round.id] = {}
9393
result[problem.id][:round][round.id][:start_at] = round.start_at
94+
result[problem.id][:round][round.id][:label] = round.label
9495
result[problem.id][:round][round.id][:team_result] = {}
9596
teams.each do |team|
9697
# get score from team login name, exploit container name which is before than round started
@@ -124,6 +125,7 @@ def score
124125
name: problem.title,
125126
round_id: round&.id,
126127
round_start_at: round&.start_at,
128+
round_label: round&.label,
127129
ntrials: problem.ntrials,
128130
succeeded: score.succeeded,
129131
x11_required: problem.x11_required,

app/views/viewer/index.html.erb

+63-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<div class="items">
1212
<div id="bullseye-problems-autoplay">&#9654;</div>
1313
</div>
14+
<div class="items">
15+
<div id="bullseye-problems-super-autoplay">&#9654;&#9654;</div>
16+
</div>
1417
</div>
1518
</div>
1619
</div>
@@ -20,10 +23,11 @@
2023
<div id="bullseye-teams"></div>
2124
<div id="bullseye-nowexploiting">
2225
<div class="message">
23-
<input type="text" value="Now evaluation" class="text">
26+
<input type="text" value="Evaluating..." class="text" id="bullseye-notice-input">
2427
<!--<input type="time">-->
2528
</div>
2629
</div>
30+
<div id="bullseye-loading"><div class="loader"></div></div>
2731

2832
<script type="text/x-jsrender" id="bullseye-template-problems-list">
2933
<div id="bullseye-problems-selected" class="bullseye-btn" data-problem-id="0">Select problem</div>
@@ -34,7 +38,7 @@
3438
</div>
3539
{{/for}}
3640
<div class="problems bullseye-panel-items" data-problem-id="-1" id="bullseye-nowexploiting-trigger">
37-
<div class="name">Now exploting...</div>
41+
<div class="name">notice</div>
3842
</div>
3943
</div>
4044
</script>
@@ -110,15 +114,16 @@ $(() => {
110114

111115
let formatRound = (problem_id, round_id) => {
112116
if (PROBLEMS[problem_id]['round'][round_id] === undefined) {
113-
return `R-`
117+
return `-`
114118
}
115119

120+
let label = PROBLEMS[problem_id]['round'][round_id]['label']
116121
let start_date = new Date(Date.parse(PROBLEMS[problem_id]['round'][1]['start_at']))
117122
let date = new Date(Date.parse(PROBLEMS[problem_id]['round'][round_id]['start_at']))
118123
let day = (date.getDate() - start_date.getDate() + 1)
119124
let hour = ('0' + date.getHours()).slice(-2)
120125
let min = ('0' + date.getMinutes()).slice(-2)
121-
return `R${round_id} (${day}day ${hour}:${min})`
126+
return `${label} (${day}day ${hour}:${min})`
122127
}
123128

124129
let selectProblem = (problem_id, current_round) => {
@@ -236,6 +241,34 @@ $(() => {
236241
localStorage.currentRound = current_round
237242
location.href = "<%= url_for :action => 'play' %>#" + first_id + '&' + mode + '&' + schedule_ids.join(',')
238243
})
244+
245+
$('#bullseye-problems-super-autoplay').click((e) => {
246+
if (confirm('PLAY ALL PROBLEMS, YES?') === false) {
247+
return
248+
}
249+
250+
let current_round = getRound()
251+
let schedule_ids = []
252+
for (let problem_id in PROBLEMS) {
253+
for (let schedule_team_id in PROBLEMS[problem_id]['round'][current_round]['team_result']) {
254+
schedule_id = PROBLEMS[problem_id]['round'][current_round]['team_result'][schedule_team_id]
255+
schedule_ids.push(schedule_id)
256+
setPlayed(schedule_team_id, schedule_id, problem_id, current_round)
257+
}
258+
}
259+
260+
if (schedule_ids.length === 0) {
261+
alert('This round result not found')
262+
return
263+
}
264+
265+
schedule_ids.sort(() => { return Math.random() - .5 }) // what??
266+
let first_id = schedule_ids.shift()
267+
let mode = $('#bullseye-problems-mode').text() === 'play' ? 'play' : 'skip'
268+
269+
localStorage.currentRound = current_round
270+
location.href = "<%= url_for :action => 'play' %>#" + first_id + '&' + mode + '&' + schedule_ids.join(',')
271+
})
239272

240273
if (localStorage.currentProblemId !== undefined) {
241274
selectProblem(localStorage.currentProblemId, localStorage.currentRound)
@@ -297,19 +330,43 @@ $(() => {
297330
})
298331
}
299332

333+
$('#bullseye-notice-input').change((e) => {
334+
let self = $(e.currentTarget)
335+
localStorage.notice = self.val()
336+
self.blur()
337+
})
338+
if (localStorage.notice) {
339+
$('#bullseye-notice-input').val(localStorage.notice)
340+
}
341+
342+
/**
343+
* loading
344+
*/
345+
let _loading = 2
346+
347+
let endLoading = () => {
348+
_loading--
349+
if (_loading <= 0) {
350+
$('#bullseye-loading').hide()
351+
}
352+
}
353+
354+
$('#bullseye-loading').show()
300355
$.getJSON(CONFIG.API_BASE + '/teams.json', (r) => {
356+
localStorage.teams = JSON.stringify(r)
301357
loadTeams(r)
358+
endLoading()
302359
})
303-
304360
$.getJSON(CONFIG.API_BASE + '/problems.json', (r) => {
361+
localStorage.problems = JSON.stringify(r)
305362
PROBLEMS = r
306363
for (let problem_id in r) {
307364
let round = Object.keys(r[problem_id]['round'])
308365
PROBLEMS[problem_id]['min_round'] = Math.min(...round)
309366
PROBLEMS[problem_id]['max_round'] = Math.max(...round)
310367
}
311368
loadProblems()
369+
endLoading()
312370
})
313-
314371
})
315372
</script>

app/views/viewer/play.html.erb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</script>
2020

2121
<script type="text/x-jsrender" id="bullseye-template-problem-round">
22-
<div class="round">Round {{>round}}</div>
22+
<div class="round">{{>round}}</div>
2323
<div class="separate"></div>
2424
<div class="time">{{>time}}</div>
2525
</script>
@@ -275,7 +275,7 @@ $(() => {
275275
$('#bullseye-team').append($('#bullseye-template-team').render(r.team))
276276
$('#bullseye-problem').append($('#bullseye-template-problem').render(r.problem))
277277

278-
let round = {'round': parseInt(r.problem.round_id), 'time': formatTime(r.problem.round_start_at)}
278+
let round = {'round': r.problem.round_label, 'time': formatTime(r.problem.round_start_at)}
279279
$('#bullseye-problem-round').append($('#bullseye-template-problem-round').render(round))
280280

281281
action(r)

0 commit comments

Comments
 (0)