Skip to content

Commit

Permalink
templates: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
taoky committed Oct 12, 2023
1 parent b162eea commit 59fb29b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions frontend/templates/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</td>
<td class="center narrow"><span class="category" :style="{backgroundColor: category_color(challenge.category)}">{{ challenge.category }}</span></td>
<td class="center narrow">{{ challenge.score }}</td>
<td class="center narrow">{{ get_challenge_count_string(challenge) }}</td>
<td class="center narrow">{{ get_challenge_count(challenge) }}</td>
</tr>
<tr v-if="challenge===opened && challenge.flags.length>1" v-for="(flag, flag_index) in challenge.flags" class="flag">
<td>
Expand All @@ -101,7 +101,7 @@
</td>
<td></td>
<td class="center narrow">{{ flag.score }}</td>
<td class="center narrow">{{ get_subchallenge_count_string(challenge, flag_index) }}</td>
<td class="center narrow">{{ get_subchallenge_count(challenge, flag_index) }}</td>
</tr>
</template>
<tr v-if="user.is_staff">
Expand Down Expand Up @@ -216,13 +216,13 @@ <h1>{{ opened.name }}</h1>
} while (!color.valid());
return color.hex();
},
get_challenge_count_string(challenge) {
get_challenge_count(challenge) {
let count = (this.clear_count.flags.find(i => i.challenge === challenge.pk) || {count: 0}).count;
// are there any sub-flags?
if (challenge.flags.length > 1) {
let max_sub = 0;
for (let j = 0; j < challenge.flags.length; j++) {
let sub_count = this.get_subchallenge_count_string(challenge, j);
let sub_count = this.get_subchallenge_count(challenge, j);
if (sub_count > max_sub) {
max_sub = sub_count;
}
Expand All @@ -231,7 +231,7 @@ <h1>{{ opened.name }}</h1>
}
return count;
},
get_subchallenge_count_string(challenge, flag_index) {
get_subchallenge_count(challenge, flag_index) {
let count = (this.clear_count.flags.find(i => i.challenge === challenge.pk && i.flag === flag_index) || {count: 0}).count;
return count;
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/templates/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<script id="json-quiz" type="application/json">
{"header": "请选择所有不违反以上条款的内容:", "questions": [[true, "使用搜索引擎搜索以尝试解题"], [false, "问做出题目的舍友 flag"], [false, "在群聊中分享自己的解题方法"], [true, "一边听歌一边做题"]]}
</script>
{% endcomment %}{% verbatim %}
{% endverbatim %}{% csrf_token %}
{% endcomment %}
{% csrf_token %}
{% for obj in terms %}
<h1>{{ obj.name }}</h1>
<input type="hidden" name="terms" value="{{ obj.pk }}">
Expand Down

0 comments on commit 59fb29b

Please sign in to comment.