IW4M-Admin/WebfrontCore/wwwroot/js/scoreboard.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-01-22 13:49:12 -05:00
function refreshScoreboard() {
const serverPanel = $('.scoreboard-container.active');
const serverId = $(serverPanel).data('server-id');
2022-01-24 10:56:48 -05:00
const scoreboardTable = $(serverPanel).children('.table-sort');
$.get(`../Server/${serverId}/Scoreboard?order=${scoreboardTable.data('sort-column')}&down=${scoreboardTable.data('sort-down')}`, (response) => {
2022-01-22 13:49:12 -05:00
$(serverPanel).html(response);
2022-01-24 10:56:48 -05:00
setupDataSorting();
2022-01-22 13:49:12 -05:00
});
}
$(document).ready(() => {
if ($('.scoreboard-container').length === 0) {
return 0;
}
2022-01-22 13:49:12 -05:00
$(window.location.hash).tab('show');
$(`${window.location.hash}_nav`).addClass('active');
2022-01-24 10:56:48 -05:00
setupDataSorting();
2022-01-22 13:49:12 -05:00
})
2022-01-24 10:56:48 -05:00
function setupDataSorting() {
const tableColumn = $('.table-sort-column');
$(tableColumn).off('click');
$(tableColumn).on('click', function() {
const columnName = $(this).data('column-name');
const table = $('.table-sort');
$(table).data('sort-column', columnName);
$(table).data('sort-down', $(table).data('sort-down') !== true);
refreshScoreboard();
})
}
2022-01-22 13:49:12 -05:00
setInterval(refreshScoreboard, 5000);