Add toggle button for ongoing contests

This commit is contained in:
cuom1999 2021-02-18 23:32:54 -06:00
parent 50f506cd93
commit f7fd4cae50

View file

@ -14,6 +14,18 @@
.content-description ul {
padding: 0 !important;
}
.btn-contest {
display: inline-block;
padding: 1px 6px;
}
{% if page_obj and page_obj.number > 1%}
#ongoing-table {
display: none;
}
{% endif %}
</style>
{% endblock %}
@ -32,6 +44,21 @@
'{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}');
});
function makeToggleBtn(btn, divElement) {
btn.click(function() {
divElement.toggle(300);
if (btn.html().trim() === '{{ _('Hide')}}') {
btn.html('{{ _('Show')}}');
}
else {
btn.html('{{ _('Hide')}}');
}
});
}
makeToggleBtn($("#ongoing-btn"), $("#ongoing-table"));
// var tooltip_classes = 'tooltipped tooltipped-e';
//
// $('.contest-tag').each(function () {
@ -187,41 +214,52 @@
{% endif %}
{% if current_contests %}
<h4>{{ _('Ongoing Contests') }}</h4>
<table class="contest-list table striped">
<thead>
<tr>
<th style="width:90%">{{ _('Contest') }}</th>
<th>{{ _('Users') }}</th>
{% if not request.in_contest %}
<th style="width:15%"></th>
<h4>
{{ _('Ongoing Contests') }}
<button class="btn-contest" id="ongoing-btn">
{% if page_obj and page_obj.number > 1%}
{{_('Show')}}
{% else %}
{{_('Hide')}}
{% endif %}
</tr>
</thead>
<tbody>
{% for contest in current_contests %}
</button>
</h4>
<div id="ongoing-table">
<table class="contest-list table striped">
<thead>
<tr>
<td>
<div class="contest-block">
{{ contest_head(contest) }}
{% if contest.start_time %}
<br>
{% if contest.time_before_end %}
<span class="time">{{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }}</span>
{% endif %}
{{ time_left(contest) }}
{% endif %}
</div>
</td>
<td>
{{ user_count(contest, request.user) }}
</td>
{{ contest_join(contest, request) }}
<th style="width:90%">{{ _('Contest') }}</th>
<th>{{ _('Users') }}</th>
{% if not request.in_contest %}
<th style="width:15%"></th>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<br>
</thead>
<tbody>
{% for contest in current_contests %}
<tr>
<td>
<div class="contest-block">
{{ contest_head(contest) }}
{% if contest.start_time %}
<br>
{% if contest.time_before_end %}
<span class="time">{{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }}</span>
{% endif %}
{{ time_left(contest) }}
{% endif %}
</div>
</td>
<td>
{{ user_count(contest, request.user) }}
</td>
{{ contest_join(contest, request) }}
</tr>
{% endfor %}
</tbody>
</table>
<br>
</div>
{% endif %}
<h4>{{ _('Upcoming Contests') }}</h4>