Make contest ranking dynamic

This commit is contained in:
cuom1999 2021-06-16 21:57:27 -05:00
parent 47e82adbad
commit b224b015a6
2 changed files with 30 additions and 4 deletions

View file

@ -227,6 +227,7 @@
});
</script>
{% endif %}
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script type="text/javascript">
function isFaster(time1, time2) {
@ -283,7 +284,35 @@
}
}
function update_ranking() {
$.get({
url: 'ajax',
success: function(HTML) {
$('#users-table').html(HTML);
highlightFirstSolve();
},
fail: function() {
console.log('Fail to update ranking');
}
});
}
window.load_dynamic_update = function (last_msg) {
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['contest_{{contest.id}}'], last_msg, function (message) {
switch (message.type) {
case 'update':
update_ranking();
break;
}
}
);
}
$(function () {
load_dynamic_update({{last_msg}});
var url = '{{ url('contest_participation', contest.key, '__username__') }}';
var placeholder = $('#search-contest').replaceWith($('<select>').attr({
id: 'search-contest'
@ -341,6 +370,7 @@
highlightFirstSolve();
});
</script>
{% include "contest/media-js.html" %}