增加比赛排名页面的自动刷新

This commit is contained in:
virusdefender 2015-09-08 17:34:21 +08:00
parent 4529ce191c
commit 2334982f31
2 changed files with 10 additions and 1 deletions

View File

@ -416,4 +416,5 @@ def contest_rank_page(request, contest_id):
return render(request, "oj/contest/contest_rank.html",
{"contest": contest, "contest_problems": contest_problems,
"result": sorted(result, cmp=_cmp, reverse=True)})
"result": sorted(result, cmp=_cmp, reverse=True),
"auto_refresh": request.GET.get("auto_refresh", None) == "true"})

View File

@ -50,6 +50,7 @@
{% endfor %}
</tbody>
</table>
<input type="checkbox" id="auto-refresh" {% if auto_refresh %}checked{% endif %} onchange="if(this.checked){location.href='?auto_refresh=true'}else{location.href=location.href.split('?')[0]}"> 自动刷新
{% else %}
<p>还没有结果</p>
{% endif %}
@ -60,4 +61,11 @@
{% block js_block %}
{% if auto_refresh %}
<script>
setTimeout(function(){
location.reload();
}, 5000);
</script>
{% endif %}
{% endblock %}