Add live contest notification

This commit is contained in:
cuom1999 2021-07-18 20:22:44 -05:00
parent 054da6dc0d
commit ce5ea027d2
11 changed files with 229 additions and 5 deletions

View file

@ -47,11 +47,36 @@
width: 0;
height: 0;
}
#clarification_header {
color: red;
cursor: pointer;
}
#clarification_header:hover {
color: orange;
}
</style>
{% endblock %}
{% block content_js_media %}
{% include "comments/media-js.html" %}
{% if request.in_contest %}
{% if last_msg %}
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script>
function setup_event_contest(last_msg) {
var channel = ['contest_clarification_' + {{request.participation.contest.id}}]
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
channel, last_msg, function (message) {
notify_clarification(message);
}
);
}
setup_event_contest();
</script>
{% endif %}
{% endif %}
<script type="text/javascript">
$(function() {
$('#pdf_button').click(async function(e) {
@ -61,6 +86,10 @@
}
frames['raw_problem'].print();
});
$('#clarification_header').on('click', function() {
$('#clarification_header_container').hide();
window.scrollTo(0, document.body.scrollHeight);
})
});
</script>
{% endblock %}
@ -299,6 +328,15 @@
{% endblock %}
{% block description %}
{% if contest_problem and contest_problem.contest.use_clarifications and has_clarifications %}
<div id="clarification_header_container">
<i class="fa fa-question-circle"></i>
<a id="clarification_header">
{{ _('This problem has %d clarification(s)' % clarifications|length) }}
</a>
</div>
{% endif %}
{% cache 86400 'problem_html' problem.id MATH_ENGINE LANGUAGE_CODE %}
{{ description|markdown("problem", MATH_ENGINE)|reference|str|safe }}
{% endcache %}