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(() => {
|
2022-02-01 10:09:29 -05:00
|
|
|
|
if ($('.scoreboard-container').length === 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-27 22:35:16 -05:00
|
|
|
|
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();
|
|
|
|
|
})
|
|
|
|
|
}
|