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

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-01-22 13:49:12 -05:00
function refreshScoreboard() {
2022-04-19 19:43:58 -04:00
const serverPanel = $('.scoreboard-container');
2022-01-22 13:49:12 -05:00
const serverId = $(serverPanel).data('server-id');
2022-01-24 10:56:48 -05:00
const scoreboardTable = $(serverPanel).children('.table-sort');
2022-04-19 19:43:58 -04:00
$.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;
}
setInterval(refreshScoreboard, 5000);
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();
})
}