remove legacy category system
This commit is contained in:
parent
a458038075
commit
f63d9bba4b
@ -110,7 +110,9 @@ strong {
|
||||
/* Server listing */
|
||||
.server-container {
|
||||
overflow: auto;
|
||||
display: flex; flex-wrap: wrap; justify-content: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.server {
|
||||
@ -155,13 +157,6 @@ strong {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
margin-bottom: 10px;
|
||||
margin-left: 15px;
|
||||
text-align: left;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.server-meta {
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="server-container-list"></div>
|
||||
<div id="server-container-list" class="server-container"></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -83,49 +83,22 @@ function updateServerStatus(lastEntry) {
|
||||
}
|
||||
|
||||
function sortServers() {
|
||||
if (categoriesVisible) {
|
||||
var byCategories = getServersByCategory();
|
||||
var serverNames = [];
|
||||
|
||||
var categories = Object.keys(byCategories);
|
||||
var keys = Object.keys(lastPlayerEntries);
|
||||
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
var relevantPlayers = [];
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
serverNames.push(keys[i]);
|
||||
}
|
||||
|
||||
for (var x = 0; x < byCategories[categories[i]].length; x++) {
|
||||
var server = byCategories[categories[i]][x];
|
||||
serverNames.sort(function(a, b) {
|
||||
return (lastPlayerEntries[b] || 0) - (lastPlayerEntries[a] || 0);
|
||||
});
|
||||
|
||||
relevantPlayers[server.name] = lastPlayerEntries[server.name];
|
||||
}
|
||||
|
||||
var keys = Object.keys(relevantPlayers);
|
||||
|
||||
keys.sort(function(a, b) {
|
||||
return relevantPlayers[b] - relevantPlayers[a];
|
||||
});
|
||||
|
||||
for (var x = 0; x < keys.length; x++) {
|
||||
$('#container_' + safeName(keys[x])).appendTo('#server-container-' + categories[i]);
|
||||
$('#ranking_' + safeName(keys[x])).text('#' + (x + 1));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var serverNames = [];
|
||||
|
||||
var keys = Object.keys(lastPlayerEntries);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
serverNames.push(keys[i]);
|
||||
}
|
||||
|
||||
serverNames.sort(function(a, b) {
|
||||
return (lastPlayerEntries[b] || 0) - (lastPlayerEntries[a] || 0);
|
||||
});
|
||||
|
||||
for (var i = 0; i < serverNames.length; i++) {
|
||||
$('#container_' + safeName(serverNames[i])).appendTo('#server-container-all');
|
||||
$('#ranking_' + safeName(serverNames[i])).text('#' + (i + 1));
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < serverNames.length; i++) {
|
||||
$('#container_' + safeName(serverNames[i])).appendTo('#server-container-list');
|
||||
$('#ranking_' + safeName(serverNames[i])).text('#' + (i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
function updatePercentageBar() {
|
||||
@ -295,8 +268,6 @@ $(document).ready(function() {
|
||||
|
||||
$('#server-container-list').html('');
|
||||
|
||||
createdCategories = false;
|
||||
|
||||
$('#big-graph').html('');
|
||||
$('#big-graph-checkboxes').html('');
|
||||
$('#big-graph-controls').css('display', 'none');
|
||||
@ -437,7 +408,7 @@ $(document).ready(function() {
|
||||
<div class="column" style="float: right;">\
|
||||
<div class="chart" id="chart_' + safeNameCopy + '"></div>\
|
||||
</div>'
|
||||
}).appendTo("#server-container-" + getServerByIp(info.ip).category);
|
||||
}).appendTo("#server-container-list");
|
||||
|
||||
var favicon = MISSING_FAVICON_BASE64;
|
||||
|
||||
|
@ -5,9 +5,6 @@ var tooltip = $('#tooltip');
|
||||
var lastMojangServiceUpdate;
|
||||
var publicConfig;
|
||||
|
||||
var createdCategories = false;
|
||||
var categoriesVisible;
|
||||
|
||||
function showCaption(html) {
|
||||
var tagline = $('#tagline-text');
|
||||
tagline.stop(true, false);
|
||||
@ -23,51 +20,7 @@ function hideCaption() {
|
||||
|
||||
function setPublicConfig(json) {
|
||||
publicConfig = json;
|
||||
|
||||
$('#server-container-list').html('');
|
||||
|
||||
createdCategories = false;
|
||||
|
||||
createCategories();
|
||||
|
||||
if (publicConfig.categoriesVisible) {
|
||||
$('.category-header').css('display', 'block');
|
||||
$('.server-container').css('margin', '10px auto');
|
||||
|
||||
sortServers();
|
||||
}
|
||||
}
|
||||
|
||||
function createCategories() {
|
||||
if (!createdCategories) {
|
||||
createdCategories = true;
|
||||
|
||||
var keys = Object.keys(publicConfig.categories);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var title = publicConfig.categories[keys[i]];
|
||||
|
||||
$('#server-container-list').append('<div id="server-container-' + keys[i] + '" class="container server-container"><h3 class="category-header">' + title + '</h3></div>');
|
||||
}
|
||||
|
||||
$('#server-container-list').append('<div id="server-container-all" class="container server-container"></div>');
|
||||
}
|
||||
}
|
||||
|
||||
function getServersByCategory() {
|
||||
var byCategory = {};
|
||||
|
||||
for (var i = 0; i < publicConfig.servers.length; i++) {
|
||||
var entry = publicConfig.servers[i];
|
||||
|
||||
if (!byCategory[entry.category]) {
|
||||
byCategory[entry.category] = [];
|
||||
}
|
||||
|
||||
byCategory[entry.category].push(entry);
|
||||
}
|
||||
|
||||
return byCategory;
|
||||
}
|
||||
|
||||
function getServerByField(id, value) {
|
||||
|
@ -22,10 +22,6 @@
|
||||
},
|
||||
"logToDatabase": false,
|
||||
"graphDuration": 86400000,
|
||||
"serverCategories": {
|
||||
"minigames": "Minigame Networks",
|
||||
"pocket": "Pocket Edition Networks"
|
||||
},
|
||||
"versions": {
|
||||
"PC": [
|
||||
4,
|
||||
@ -42,6 +38,5 @@
|
||||
0
|
||||
]
|
||||
},
|
||||
"categoriesVisible": true,
|
||||
"serverTypesVisible": true
|
||||
}
|
||||
|
@ -41,35 +41,10 @@ function handleRequest(req, res) {
|
||||
} else if (requestUrl === '/publicConfig.json') {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
||||
var categories = config.serverCategories;
|
||||
|
||||
// Legacy support for people without categories configured.
|
||||
if (!categories || Object.keys(categories).length === 0) {
|
||||
categories = {
|
||||
'default': 'All Networks'
|
||||
};
|
||||
}
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
var entry = servers[i];
|
||||
|
||||
if (!entry.category) {
|
||||
entry.category = 'default';
|
||||
|
||||
logger.warn('%s has no category, defaulting!', entry.name);
|
||||
} else if (!categories[entry.category]) {
|
||||
logger.warn('%s has an unknown category (%s), defaulting!', entry.name, entry.category);
|
||||
|
||||
entry.category = 'default';
|
||||
}
|
||||
}
|
||||
|
||||
var publicConfig = {
|
||||
categories: categories,
|
||||
graphDuration: config.graphDuration,
|
||||
servers: servers,
|
||||
bootTime: util.getBootTime(),
|
||||
categoriesVisible: config.categoriesVisible || false,
|
||||
serverTypesVisible: config.serverTypesVisible || false,
|
||||
minecraftVersions: minecraft.versions
|
||||
};
|
||||
|
@ -2,13 +2,11 @@
|
||||
{
|
||||
"name": "Hypixel",
|
||||
"ip": "mc.hypixel.net",
|
||||
"type": "PC",
|
||||
"category": "minigames"
|
||||
"type": "PC"
|
||||
},
|
||||
{
|
||||
"name": "HiveMC",
|
||||
"ip": "play.hivemc.com",
|
||||
"type": "PC",
|
||||
"category": "minigames"
|
||||
"type": "PC"
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user