diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index a05c89280..f81ebf639 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -27,7 +27,7 @@ namespace IW4MAdmin.Application { public class ApplicationManager : IManager { - private ConcurrentBag _servers; + private readonly ConcurrentBag _servers; public List 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 Commands; - readonly List MessageTokens; - ClientService ClientSvc; + private readonly List Commands; + private readonly List MessageTokens; + private readonly ClientService ClientSvc; readonly AliasService AliasSvc; readonly PenaltyService PenaltySvc; public BaseConfigurationHandler ConfigHandler; GameEventHandler Handler; readonly IPageList PageList; - readonly SemaphoreSlim ProcessingEvent = new SemaphoreSlim(1, 1); readonly Dictionary Loggers = new Dictionary(); private readonly MetaService _metaService; private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0); diff --git a/SharedLibraryCore/Commands/CommandProcessing.cs b/SharedLibraryCore/Commands/CommandProcessing.cs index 5d05b22de..c5bc4e101 100644 --- a/SharedLibraryCore/Commands/CommandProcessing.cs +++ b/SharedLibraryCore/Commands/CommandProcessing.cs @@ -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) diff --git a/WebfrontCore/wwwroot/js/action.js b/WebfrontCore/wwwroot/js/action.js index 3450d9438..857847de5 100644 --- a/WebfrontCore/wwwroot/js/action.js +++ b/WebfrontCore/wwwroot/js/action.js @@ -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)`); } }); diff --git a/WebfrontCore/wwwroot/js/loader.js b/WebfrontCore/wwwroot/js/loader.js index b3c3e2bc9..167935b50 100644 --- a/WebfrontCore/wwwroot/js/loader.js +++ b/WebfrontCore/wwwroot/js/loader.js @@ -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); - } } } \ No newline at end of file diff --git a/WebfrontCore/wwwroot/js/penalty.js b/WebfrontCore/wwwroot/js/penalty.js index f9662c518..f42a710bc 100644 --- a/WebfrontCore/wwwroot/js/penalty.js +++ b/WebfrontCore/wwwroot/js/penalty.js @@ -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); - } } \ No newline at end of file diff --git a/WebfrontCore/wwwroot/js/profile.js b/WebfrontCore/wwwroot/js/profile.js index 5e19c8946..a914f9956 100644 --- a/WebfrontCore/wwwroot/js/profile.js +++ b/WebfrontCore/wwwroot/js/profile.js @@ -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(); diff --git a/WebfrontCore/wwwroot/js/server.js b/WebfrontCore/wwwroot/js/server.js index da19c018f..3599fd186 100644 --- a/WebfrontCore/wwwroot/js/server.js +++ b/WebfrontCore/wwwroot/js/server.js @@ -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); diff --git a/WebfrontCore/wwwroot/js/stats.js b/WebfrontCore/wwwroot/js/stats.js index 6338176a6..d6a711a3a 100644 --- a/WebfrontCore/wwwroot/js/stats.js +++ b/WebfrontCore/wwwroot/js/stats.js @@ -39,7 +39,7 @@ lineThickness: 0, tickThickness: 0, margin: 0, - valueFormatString: ' ', + valueFormatString: ' ' }, axisY: { labelFontSize: 12,