avalon-django/avalon/avalon_game/templates/game.html

31 lines
1.2 KiB
HTML

{% extends "base.html" %}
{% block content %}
{% block game_header %}{% endblock %}
{% block game_content %}{% endblock %}
{% block game_refresh %}
{% if not results_only %}
<div class="button-container">
<a href="{% if is_observer %}{% url 'observe' access_code=access_code %}{% else %}{% url 'game' access_code=access_code player_secret=player_secret %}{% endif %}" class="button" id="button-refresh">Refresh</a>
</div>
<script>
var statusObj = JSON.parse("{{ status|escapejs }}");
function handleNewStatus(oldStatus, newStatus) {
{% block game_handle_new_status %}
return false;
{% endblock %}
}
setInterval(function() {
$.get("{% if is_observer %}{% url 'observe_status' access_code=access_code %}{% else %}{% url 'status' access_code=access_code player_secret=player_secret %}{% endif %}", function(data, textStatus, jqXHR) {
if(JSON.stringify(data) != JSON.stringify(statusObj)) {
if(!handleNewStatus(statusObj, data)) {
document.getElementById("button-refresh").click();
}
}
}, "json");
}, 5000);
</script>
{% endif %}
{% endblock %}
{% endblock %}