inline #isArrayUtil, remove jQuery
This commit is contained in:
parent
e8b530bbb8
commit
59ec7d151f
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true,
|
"es6": true
|
||||||
"jquery": true
|
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"standard"
|
"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>
|
<span class="icon-code"></span> Powered by open source software - <a href="https://github.com/Cryptkeeper/Minetrack">make it your own!</a>
|
||||||
</footer>
|
</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>
|
<script src="../js/main.js" defer></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import { isArrayEqual } from './util'
|
|
||||||
|
|
||||||
const SORT_OPTIONS = [
|
const SORT_OPTIONS = [
|
||||||
{
|
{
|
||||||
getName: () => 'Players',
|
getName: () => 'Players',
|
||||||
@ -164,8 +162,21 @@ export class SortController {
|
|||||||
// This avoids DOM updates and graphs being redrawn
|
// This avoids DOM updates and graphs being redrawn
|
||||||
const sortedServerIds = sortedServers.map(server => server.serverId)
|
const sortedServerIds = sortedServers.map(server => server.serverId)
|
||||||
|
|
||||||
if (isArrayEqual(sortedServerIds, this._lastSortedServers)) {
|
if (this._lastSortedServers) {
|
||||||
return
|
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
|
this._lastSortedServers = sortedServerIds
|
||||||
@ -176,7 +187,10 @@ export class SortController {
|
|||||||
|
|
||||||
// Update the DOM structure
|
// Update the DOM structure
|
||||||
sortedServers.forEach(function (serverRegistration) {
|
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
|
// Set the ServerRegistration's rankIndex to its indexOf the normal sort
|
||||||
serverRegistration.updateServerRankIndex(rankIndexSort.indexOf(serverRegistration))
|
serverRegistration.updateServerRankIndex(rankIndexSort.indexOf(serverRegistration))
|
||||||
|
@ -120,21 +120,6 @@ export function formatNumber (x) {
|
|||||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
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/
|
// From http://detectmobilebrowsers.com/
|
||||||
export function isMobileBrowser () {
|
export function isMobileBrowser () {
|
||||||
var check = false;
|
var check = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user