diff --git a/.eslintrc.json b/.eslintrc.json index 0ec52d3..4af0191 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,7 @@ { "env": { "browser": true, - "es6": true, - "jquery": true + "es6": true }, "extends": [ "standard" diff --git a/assets/html/index.html b/assets/html/index.html index 5e9162c..70e0abb 100644 --- a/assets/html/index.html +++ b/assets/html/index.html @@ -90,8 +90,6 @@ Powered by open source software - make it your own! - - diff --git a/assets/js/sort.js b/assets/js/sort.js index ad6a25f..7c9209c 100644 --- a/assets/js/sort.js +++ b/assets/js/sort.js @@ -1,5 +1,3 @@ -import { isArrayEqual } from './util' - const SORT_OPTIONS = [ { getName: () => 'Players', @@ -164,8 +162,21 @@ export class SortController { // This avoids DOM updates and graphs being redrawn const sortedServerIds = sortedServers.map(server => server.serverId) - if (isArrayEqual(sortedServerIds, this._lastSortedServers)) { - return + if (this._lastSortedServers) { + let allMatch = true + + // Test if the arrays have actually changed + // No need to length check, they are the same source data each time + for (let i = 0; i < sortedServerIds.length; i++) { + if (sortedServerIds[i] !== this._lastSortedServers[i]) { + allMatch = false + break + } + } + + if (allMatch) { + return + } } this._lastSortedServers = sortedServerIds @@ -176,7 +187,10 @@ export class SortController { // Update the DOM structure sortedServers.forEach(function (serverRegistration) { - $('#container_' + serverRegistration.serverId).appendTo('#server-list') + const parentElement = document.getElementById('server-list') + const serverElement = document.getElementById('container_' + serverRegistration.serverId) + + parentElement.appendChild(serverElement) // Set the ServerRegistration's rankIndex to its indexOf the normal sort serverRegistration.updateServerRankIndex(rankIndexSort.indexOf(serverRegistration)) diff --git a/assets/js/util.js b/assets/js/util.js index 31f89b3..be1dc8f 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -120,21 +120,6 @@ export function formatNumber (x) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') } -export function isArrayEqual (a, b) { - if (typeof a === 'undefined' || typeof a !== typeof b) { - return false - } - if (a.length !== b.length) { - return false - } - for (let i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { - return false - } - } - return true -} - // From http://detectmobilebrowsers.com/ export function isMobileBrowser () { var check = false;