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

33 lines
1.0 KiB
JavaScript
Raw Permalink 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(() => {
$(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);