small code cleanups
This commit is contained in:
@ -33,7 +33,7 @@ $(document).ready(function () {
|
||||
$('.profile-action').click(function (e) {
|
||||
const actionType = $(this).data('action');
|
||||
const actionId = $(this).data('action-id');
|
||||
const actionIdKey = actionId == undefined ? '' : '?id=' + actionId;
|
||||
const actionIdKey = actionId === undefined ? '' : '?id=' + actionId;
|
||||
$.get('/Action/' + actionType + 'Form' + actionIdKey)
|
||||
.done(function (response) {
|
||||
$('#actionModal .modal-message').fadeOut('fast');
|
||||
@ -90,12 +90,12 @@ $(document).ready(function () {
|
||||
*/
|
||||
$('#actionModal').off('action_form_received');
|
||||
$('#actionModal').on('action_form_received', function (e, actionType) {
|
||||
if (actionType == 'RecentClients') {
|
||||
if (actionType === 'RecentClients') {
|
||||
const ipAddresses = $('.client-location-flag');
|
||||
$.each(ipAddresses, function (index, address) {
|
||||
$.get('https://ip2c.org/' + $(address).data('ip'), function (result) {
|
||||
const countryCode = result.split(';')[1].toLowerCase();
|
||||
if (countryCode != 'zz') {
|
||||
if (countryCode !== 'zz') {
|
||||
$(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`);
|
||||
}
|
||||
});
|
||||
|
@ -41,6 +41,20 @@ function loadMoreItems() {
|
||||
loaderOffset += loadCount;
|
||||
}
|
||||
|
||||
function ScrollHandler(e) {
|
||||
//throttle event:
|
||||
hasScrollBar = true;
|
||||
clearTimeout(_throttleTimer);
|
||||
_throttleTimer = setTimeout(function () {
|
||||
|
||||
//do work
|
||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||
loadMoreItems();
|
||||
}
|
||||
|
||||
}, _throttleDelay);
|
||||
}
|
||||
|
||||
function setupListeners() {
|
||||
if ($(loaderResponseId).length === 1) {
|
||||
/*
|
||||
@ -73,21 +87,7 @@ function setupListeners() {
|
||||
if (!isLoaderLoading) {
|
||||
loadMoreItems();
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
function ScrollHandler(e) {
|
||||
//throttle event:
|
||||
hasScrollBar = true;
|
||||
clearTimeout(_throttleTimer);
|
||||
_throttleTimer = setTimeout(function () {
|
||||
|
||||
//do work
|
||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||
loadMoreItems();
|
||||
}
|
||||
|
||||
}, _throttleDelay);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,21 @@
|
||||
let offset = 15;
|
||||
let isLoading = false;
|
||||
|
||||
|
||||
function ScrollHandler(e) {
|
||||
//throttle event:
|
||||
hasScrollBar = true;
|
||||
clearTimeout(_throttleTimer);
|
||||
_throttleTimer = setTimeout(function () {
|
||||
|
||||
//do work
|
||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||
loadMorePenalties();
|
||||
}
|
||||
|
||||
}, _throttleDelay);
|
||||
}
|
||||
|
||||
function loadMorePenalties() {
|
||||
if (isLoading) {
|
||||
return false;
|
||||
@ -34,7 +49,7 @@ if ($('#penalty_table').length === 1) {
|
||||
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
|
||||
*/
|
||||
$('html').bind('mousewheel DOMMouseScroll', function (e) {
|
||||
var delta = (e.originalEvent.wheelDelta || -e.originalEvent.detail);
|
||||
var delta = e.originalEvent.wheelDelta || -e.originalEvent.detail;
|
||||
|
||||
if (delta < 0 && !hasScrollBar) {
|
||||
loadMorePenalties();
|
||||
@ -59,18 +74,4 @@ if ($('#penalty_table').length === 1) {
|
||||
loadMorePenalties();
|
||||
});
|
||||
});
|
||||
|
||||
function ScrollHandler(e) {
|
||||
//throttle event:
|
||||
hasScrollBar = true;
|
||||
clearTimeout(_throttleTimer);
|
||||
_throttleTimer = setTimeout(function () {
|
||||
|
||||
//do work
|
||||
if ($window.scrollTop() + $window.height() > $document.height() - 100) {
|
||||
loadMorePenalties();
|
||||
}
|
||||
|
||||
}, _throttleDelay);
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@
|
||||
showLoader();
|
||||
const location = $(this).parent();
|
||||
$.get('/Stats/GetAutomatedPenaltyInfoAsync', {
|
||||
'clientId': $(this).data('clientid'),
|
||||
'clientId': $(this).data('clientid')
|
||||
})
|
||||
.done(function (response) {
|
||||
$('.penalty-info-context').remove();
|
||||
|
@ -55,7 +55,7 @@ $('.server-history-row').each(function (index, element) {
|
||||
let clientHistory = $(this).data('clienthistory');
|
||||
let serverId = $(this).data('serverid');
|
||||
let maxClients = parseInt($('#server_header_' + serverId + ' .server-maxclients').text());
|
||||
let color = $(this).data('online') === 'True' ? 'rgba(0, 122, 204, 0.432)' : '#ff6060'
|
||||
let color = $(this).data('online') === 'True' ? 'rgba(0, 122, 204, 0.432)' : '#ff6060';
|
||||
let width = $('.server-header').first().width();
|
||||
let historyChart = getPlayerHistoryChart(clientHistory, serverId, width, color, maxClients);
|
||||
historyChart.render();
|
||||
@ -89,10 +89,10 @@ function refreshClientActivity() {
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
$('.server-join-button').click(function (e) {
|
||||
$(this).children('.server-header-ip-address').show();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
setInterval(refreshClientActivity, 2000);
|
||||
|
@ -39,7 +39,7 @@
|
||||
lineThickness: 0,
|
||||
tickThickness: 0,
|
||||
margin: 0,
|
||||
valueFormatString: ' ',
|
||||
valueFormatString: ' '
|
||||
},
|
||||
axisY: {
|
||||
labelFontSize: 12,
|
||||
|
Reference in New Issue
Block a user