small code cleanups

This commit is contained in:
RaidMax 2019-07-19 14:54:39 -05:00
parent 38f1169061
commit 50ba71c6fb
8 changed files with 44 additions and 45 deletions

View File

@ -27,7 +27,7 @@ namespace IW4MAdmin.Application
{
public class ApplicationManager : IManager
{
private ConcurrentBag<Server> _servers;
private readonly ConcurrentBag<Server> _servers;
public List<Server> Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
public ILogger Logger => GetLogger(0);
public bool Running { get; private set; }
@ -46,15 +46,14 @@ namespace IW4MAdmin.Application
public string ExternalIPAddress { get; private set; }
public bool IsRestartRequested { get; private set; }
static ApplicationManager Instance;
List<Command> Commands;
readonly List<MessageToken> MessageTokens;
ClientService ClientSvc;
private readonly List<Command> Commands;
private readonly List<MessageToken> MessageTokens;
private readonly ClientService ClientSvc;
readonly AliasService AliasSvc;
readonly PenaltyService PenaltySvc;
public BaseConfigurationHandler<ApplicationConfiguration> ConfigHandler;
GameEventHandler Handler;
readonly IPageList PageList;
readonly SemaphoreSlim ProcessingEvent = new SemaphoreSlim(1, 1);
readonly Dictionary<long, ILogger> Loggers = new Dictionary<long, ILogger>();
private readonly MetaService _metaService;
private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0);

View File

@ -61,8 +61,7 @@ namespace SharedLibraryCore.Commands
if (Args[0][0] == '@') // user specifying target by database ID
{
int dbID = -1;
int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out dbID);
int.TryParse(Args[0].Substring(1, Args[0].Length - 1), out int dbID);
var found = await Manager.GetClientService().Get(dbID);
if (found != null)

View File

@ -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)`);
}
});

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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);

View File

@ -39,7 +39,7 @@
lineThickness: 0,
tickThickness: 0,
margin: 0,
valueFormatString: ' ',
valueFormatString: ' '
},
axisY: {
labelFontSize: 12,