inline #isArrayUtil, remove jQuery
This commit is contained in:
parent
e8b530bbb8
commit
59ec7d151f
@ -1,8 +1,7 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"jquery": true
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"standard"
|
||||
|
@ -90,8 +90,6 @@
|
||||
<span class="icon-code"></span> Powered by open source software - <a href="https://github.com/Cryptkeeper/Minetrack">make it your own!</a>
|
||||
</footer>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.min.js"></script>
|
||||
|
||||
<script src="../js/main.js" defer></script>
|
||||
|
||||
</body>
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user