From f7fd4cae500f737cfac82efe6f55754c9b036ee6 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Thu, 18 Feb 2021 23:32:54 -0600 Subject: [PATCH] Add toggle button for ongoing contests --- templates/contest/list.html | 102 +++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/templates/contest/list.html b/templates/contest/list.html index 51117a6..791cb54 100644 --- a/templates/contest/list.html +++ b/templates/contest/list.html @@ -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 %} + {% 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 %} -

{{ _('Ongoing Contests') }}

- - - - - - {% if not request.in_contest %} - +

+ {{ _('Ongoing Contests') }} +

- - - {% for contest in current_contests %} + + +
+
{{ _('Contest') }}{{ _('Users') }}
+ - - - {{ contest_join(contest, request) }} + + + {% if not request.in_contest %} + + {% endif %} - {% endfor %} - -
-
- {{ contest_head(contest) }} - {% if contest.start_time %} -
- {% if contest.time_before_end %} - {{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }} - {% endif %} - {{ time_left(contest) }} - {% endif %} -
-
- {{ user_count(contest, request.user) }} - {{ _('Contest') }}{{ _('Users') }}
-
+ + + {% for contest in current_contests %} + + +
+ {{ contest_head(contest) }} + {% if contest.start_time %} +
+ {% if contest.time_before_end %} + {{ _('Ends in %(countdown)s', countdown=contest.time_before_end|as_countdown) }} + {% endif %} + {{ time_left(contest) }} + {% endif %} +
+ + + {{ user_count(contest, request.user) }} + + {{ contest_join(contest, request) }} + + {% endfor %} + + +
+ {% endif %}

{{ _('Upcoming Contests') }}