Commit c7c7589b authored by Vladimir Zhukov's avatar Vladimir Zhukov
Browse files

render leaderboard

parent 6229a019
Pipeline #1484 passed with stage
in 3 seconds
......@@ -199,6 +199,19 @@ function renderState(state) {
}
}
function renderLeaderboard(leaderboard) {
var html = '';
for (const item of leaderboard) {
console.log(item);
html += '<tr>';
html += '<th scope="row">' + item.n + '</th>';
html += '<td>' + item.user + '</td>';
html += '<td>' + renderExpAmount(item.tflops) + '</td>';
html += '</tr>';
}
$("#leaderboardTable").html(html);
}
function update() {
$.ajax({
url: "update",
......@@ -236,6 +249,19 @@ function getGrant(grant_key) {
ajaxCall("get_grant/" + grant_key);
}
function showLeaderboard() {
$.ajax({
url: 'leaderboard/',
success: function (response) {
if (response.data != null) {
renderLeaderboard(response.data);
$("#settingsModal").modal('hide');
$("#leaderboardModal").modal('show');
}
},
});
}
function debugSkipTime(seconds) {
ajaxCall("debug_skip_time/" + seconds);
}
......@@ -248,10 +274,15 @@ $(function () {
});
});
$('#expCharModeCheckbox').click(function (event) {
$("#expCharModeCheckbox").click(function (event) {
event.preventDefault();
ajaxCall("toggle_char_mode");
});
$("#showLeaderboardLink").click(function (event) {
event.preventDefault();
showLeaderboard();
});
setTimeout(update, 1000);
});
......@@ -82,7 +82,8 @@
{% endblock %}
{% block modals %}
{% include 'modals/settings.html' %}
{% include 'modals/leaderboard.html' %}
{% endblock %}
{% block scripts %}
<script src="{% static 'script.js' %}?v=1"></script>
<script src="{% static 'script.js' %}?v=2"></script>
{% endblock %}
<div class="modal fade" id="leaderboardModal" tabindex="-1" aria-labelledby="leaderboardModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="leaderboardModalLabel">Топ игроков</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table text-center">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Пользователь</th>
<th scope="col">TFLOPS</th>
</tr>
</thead>
<tbody id="leaderboardTable"></tbody>
</table>
</div>
<div class="modal-footer d-flex flex-column align-items-center">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Закрыть</button>
</div>
</div>
</div>
</div>
......@@ -7,8 +7,11 @@
</div>
<div class="modal-body">
<div class="d-flex flex-column align-items-center">
<p>Аккаунт: {{ request.user }}</p>
<div class="form-check form-switch">
<p class="m-0">
Аккаунт: {{ request.user }}
</p>
<a id="showLeaderboardLink" href="#">(топ игроков)</a>
<div class="form-check form-switch mt-3">
<input
class="form-check-input"
type="checkbox"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment