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 { .content-description ul {
padding: 0 !important; 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> </style>
{% endblock %} {% endblock %}
@ -32,6 +44,21 @@
'{{ _('Joining a contest for the first time starts your timer, after which it becomes unstoppable.') }}'); '{{ _('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'; // var tooltip_classes = 'tooltipped tooltipped-e';
// //
// $('.contest-tag').each(function () { // $('.contest-tag').each(function () {
@ -187,41 +214,52 @@
{% endif %} {% endif %}
{% if current_contests %} {% if current_contests %}
<h4>{{ _('Ongoing Contests') }}</h4> <h4>
<table class="contest-list table striped"> {{ _('Ongoing Contests') }}
<thead> <button class="btn-contest" id="ongoing-btn">
<tr> {% if page_obj and page_obj.number > 1%}
<th style="width:90%">{{ _('Contest') }}</th> {{_('Show')}}
<th>{{ _('Users') }}</th> {% else %}
{% if not request.in_contest %} {{_('Hide')}}
<th style="width:15%"></th>
{% endif %} {% endif %}
</tr> </button>
</thead> </h4>
<tbody> <div id="ongoing-table">
{% for contest in current_contests %} <table class="contest-list table striped">
<thead>
<tr> <tr>
<td> <th style="width:90%">{{ _('Contest') }}</th>
<div class="contest-block"> <th>{{ _('Users') }}</th>
{{ contest_head(contest) }} {% if not request.in_contest %}
{% if contest.start_time %} <th style="width:15%"></th>
<br> {% endif %}
{% 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> </tr>
{% endfor %} </thead>
</tbody> <tbody>
</table> {% for contest in current_contests %}
<br> <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 %} {% endif %}
<h4>{{ _('Upcoming Contests') }}</h4> <h4>{{ _('Upcoming Contests') }}</h4>