Ability to categorize networks
This commit is contained in:
parent
d6d59cad12
commit
143e99876a
@ -93,7 +93,7 @@ html, body {
|
||||
}
|
||||
|
||||
/* Server listing */
|
||||
#server-container {
|
||||
.server-container {
|
||||
width: 1540px;
|
||||
margin: 10px auto;
|
||||
overflow: auto;
|
||||
@ -130,6 +130,12 @@ html, body {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.category-header {
|
||||
text-align: center;
|
||||
display: block;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
/* Charts */
|
||||
.chart {
|
||||
height: 100px;
|
||||
@ -169,30 +175,6 @@ h3 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Icon Quick jump */
|
||||
#quick-jump-container {
|
||||
position: fixed;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.quick-jump-icon {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
display: block;
|
||||
margin-bottom: 2px;
|
||||
border-radius: 2px;
|
||||
transition: all 0.1s;
|
||||
}
|
||||
|
||||
.quick-jump-icon:hover {
|
||||
cursor: pointer;
|
||||
height: 42px;
|
||||
width: 42px;
|
||||
}
|
||||
|
||||
/* The big graph */
|
||||
#big-graph, #big-graph-controls, #big-graph-checkboxes {
|
||||
width: 1540px;
|
||||
|
@ -18,52 +18,52 @@
|
||||
|
||||
<div id="push">
|
||||
|
||||
<div id="header">
|
||||
<div id="header">
|
||||
|
||||
<h1 class="text-uppercase">Minetrack</h1>
|
||||
<p class="slogan text-uppercase">All your favorite Minecraft servers, right now.</p>
|
||||
<p class="info text-uppercase">Made with <span style="color: #e74c3c;">♥</span> by <a href="http://cryptkpr.me">Cryptkeeper</a> · Open source'd on <a href="https://github.com/Cryptkeeper/Minetrack">Github</a></p>
|
||||
|
||||
<br />
|
||||
|
||||
<p class="info text-uppercase">Watching <span id="stat_totalPlayers">0</span> players on <span id="stat_networks">0</span> networks.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="tagline" class="status-connecting">
|
||||
|
||||
<span id="tagline-text" class="text-uppercase">Connecting...</span>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="big-graph"></div>
|
||||
|
||||
<div id="big-graph-controls" style="display: none;">
|
||||
|
||||
<span style="text-align: center; display: block;">
|
||||
|
||||
<a onclick="toggleControlsDrawer();">Click to toggle graph controls</a>
|
||||
|
||||
</span>
|
||||
|
||||
<div id="big-graph-controls-drawer" style="display: none;">
|
||||
|
||||
<div id="big-graph-checkboxes"></div>
|
||||
<h1 class="text-uppercase">Minetrack</h1>
|
||||
<p class="slogan text-uppercase">All your favorite Minecraft servers, right now.</p>
|
||||
<p class="info text-uppercase">Made with <span style="color: #e74c3c;">♥</span> by <a href="http://cryptkpr.me">Cryptkeeper</a> · Open source'd on <a href="https://github.com/Cryptkeeper/Minetrack">Github</a></p>
|
||||
|
||||
<br />
|
||||
|
||||
<span style="text-align: center; display: block; margin-bottom: 15px;">
|
||||
|
||||
<span onclick="setAllGraphVisibility(true);" class="button">Show All</span>
|
||||
<span onclick="setAllGraphVisibility(false);" class="button">Hide All</span>
|
||||
|
||||
</span>
|
||||
<p class="info text-uppercase">Watching <span id="stat_totalPlayers">0</span> players on <span id="stat_networks">0</span> networks.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="tagline" class="status-connecting">
|
||||
|
||||
<span id="tagline-text" class="text-uppercase">Connecting...</span>
|
||||
|
||||
<div id="server-container" class="container"></div>
|
||||
</div>
|
||||
|
||||
<div id="big-graph"></div>
|
||||
|
||||
<div id="big-graph-controls" style="display: none;">
|
||||
|
||||
<span style="text-align: center; display: block;">
|
||||
|
||||
<a onclick="toggleControlsDrawer();">Click to toggle graph controls</a>
|
||||
|
||||
</span>
|
||||
|
||||
<div id="big-graph-controls-drawer" style="display: none;">
|
||||
|
||||
<div id="big-graph-checkboxes"></div>
|
||||
|
||||
<br />
|
||||
|
||||
<span style="text-align: center; display: block; margin-bottom: 15px;">
|
||||
|
||||
<span onclick="setAllGraphVisibility(true);" class="button">Show All</span>
|
||||
<span onclick="setAllGraphVisibility(false);" class="button">Hide All</span>
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="server-container-list"></div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -73,8 +73,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="quick-jump-container"></div>
|
||||
|
||||
<!-- External JS assets -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
|
||||
@ -84,8 +82,11 @@
|
||||
|
||||
<!-- Internal JS assets -->
|
||||
<script src="js/util.js"></script>
|
||||
<script src="js/graph.js"></script>
|
||||
<script src="js/site.js"></script>
|
||||
|
||||
<script src="publicConfig.json"></script>
|
||||
|
||||
<script>
|
||||
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
|
130
assets/js/graph.js
Normal file
130
assets/js/graph.js
Normal file
@ -0,0 +1,130 @@
|
||||
// Used by the individual server entries
|
||||
var smallChartOptions = {
|
||||
series: {
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: {
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yaxis: {
|
||||
minTickSize: 75,
|
||||
tickDecimals: 0,
|
||||
show: true,
|
||||
tickLength: 10,
|
||||
tickFormatter: function(value) {
|
||||
return formatNumber(value);
|
||||
},
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
labelWidth: -10
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
color: "#696969"
|
||||
},
|
||||
colors: [
|
||||
"#E9E581"
|
||||
]
|
||||
};
|
||||
|
||||
// Used by the one chart to rule them all
|
||||
var bigChartOptions = {
|
||||
series: {
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: {
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yaxis: {
|
||||
show: true,
|
||||
tickSize: 2000,
|
||||
tickLength: 10,
|
||||
tickFormatter: function(value) {
|
||||
return formatNumber(value);
|
||||
},
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
labelWidth: -5,
|
||||
min: 0
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
color: "#696969"
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
|
||||
function toggleControlsDrawer() {
|
||||
var div = $('#big-graph-controls-drawer');
|
||||
|
||||
div.css('display', div.css('display') !== 'none' ? 'none' : 'block');
|
||||
}
|
||||
|
||||
function saveGraphControls(displayedServers) {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
var json = JSON.stringify(displayedServers);
|
||||
|
||||
localStorage.setItem('displayedServers', json);
|
||||
}
|
||||
}
|
||||
|
||||
function loadGraphControls() {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
var item = localStorage.getItem('displayedServers');
|
||||
|
||||
if (item) {
|
||||
return JSON.parse(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetGraphControls() {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
localStorage.removeItem('displayedServers');
|
||||
}
|
||||
}
|
||||
|
||||
// Called by flot.js when they hover over a data point.
|
||||
function handlePlotHover(event, pos, item) {
|
||||
if (item) {
|
||||
var text = getTimestamp(item.datapoint[0] / 1000) + '\
|
||||
<br />\
|
||||
' + formatNumber(item.datapoint[1]) + ' Players';
|
||||
|
||||
if (item.series && item.series.label) {
|
||||
text = item.series.label + '<br />' + text;
|
||||
}
|
||||
|
||||
renderTooltip(item.pageX + 5, item.pageY + 5, text);
|
||||
} else {
|
||||
hideTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
// Converts the backend data into the schema used by flot.js
|
||||
function convertGraphData(rawData) {
|
||||
var data = [];
|
||||
|
||||
var keys = Object.keys(rawData);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
data.push({
|
||||
data: rawData[keys[i]],
|
||||
yaxis: 1,
|
||||
label: keys[i],
|
||||
color: stringToColor(keys[i])
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
@ -1,69 +1,3 @@
|
||||
var smallChartOptions = {
|
||||
series: {
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: {
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yaxis: {
|
||||
minTickSize: 75,
|
||||
tickDecimals: 0,
|
||||
show: true,
|
||||
tickLength: 10,
|
||||
tickFormatter: function(value) {
|
||||
return formatNumber(value);
|
||||
},
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
labelWidth: -10
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
color: "#696969"
|
||||
},
|
||||
colors: [
|
||||
"#E9E581"
|
||||
]
|
||||
};
|
||||
|
||||
var bigChartOptions = {
|
||||
series: {
|
||||
shadowSize: 0
|
||||
},
|
||||
xaxis: {
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yaxis: {
|
||||
show: true,
|
||||
tickSize: 2000,
|
||||
tickLength: 10,
|
||||
tickFormatter: function(value) {
|
||||
return formatNumber(value);
|
||||
},
|
||||
font: {
|
||||
color: "#E3E3E3"
|
||||
},
|
||||
labelWidth: -5,
|
||||
min: 0
|
||||
},
|
||||
grid: {
|
||||
hoverable: true,
|
||||
color: "#696969"
|
||||
},
|
||||
legend: {
|
||||
show: false
|
||||
}
|
||||
};
|
||||
|
||||
var lastMojangServiceUpdate;
|
||||
|
||||
var graphs = {};
|
||||
var lastPlayerEntries = {};
|
||||
|
||||
@ -71,57 +5,6 @@ var historyPlot;
|
||||
var displayedGraphData;
|
||||
var hiddenGraphData = [];
|
||||
|
||||
// Generate (and set) the HTML that displays Mojang status.
|
||||
function updateMojangServices() {
|
||||
if (!lastMojangServiceUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
var keys = Object.keys(lastMojangServiceUpdate);
|
||||
var newStatus = 'Mojang Services: ';
|
||||
var serviceCountByType = {
|
||||
Online: 0,
|
||||
Unstable: 0,
|
||||
Offline: 0
|
||||
};
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var entry = lastMojangServiceUpdate[keys[i]];
|
||||
|
||||
serviceCountByType[entry.title] += 1;
|
||||
}
|
||||
|
||||
if (serviceCountByType['Online'] === keys.length) {
|
||||
$('#tagline').attr('class', 'status-online');
|
||||
|
||||
newStatus += 'All systems operational.';
|
||||
} else {
|
||||
if (serviceCountByType['Unstable'] > serviceCountByType['Offline']) {
|
||||
$('#tagline').attr('class', 'status-unstable');
|
||||
} else {
|
||||
$('#tagline').attr('class', 'status-offline');
|
||||
}
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var entry = lastMojangServiceUpdate[keys[i]];
|
||||
|
||||
if (entry.startTime) {
|
||||
newStatus += entry.name + ' ' + entry.title.toLowerCase() + ' for ' + msToTime((new Date()).getTime() - entry.startTime + ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#tagline-text').text(newStatus);
|
||||
}
|
||||
|
||||
function findErrorMessage(error) {
|
||||
if (error.description) {
|
||||
return error.description;
|
||||
} else if (error.errno) {
|
||||
return error.errno;
|
||||
}
|
||||
}
|
||||
|
||||
function updateServerStatus(lastEntry) {
|
||||
var info = lastEntry.info;
|
||||
var div = $('#status_' + safeName(info.name));
|
||||
@ -171,19 +54,30 @@ function updateServerStatus(lastEntry) {
|
||||
}
|
||||
|
||||
function sortServers() {
|
||||
var keys = Object.keys(lastPlayerEntries);
|
||||
var nameList = [];
|
||||
var byCategories = getServersByCategory();
|
||||
|
||||
keys.sort(function(a, b) {
|
||||
return lastPlayerEntries[b] - lastPlayerEntries[a];
|
||||
});
|
||||
var categories = Object.keys(byCategories);
|
||||
|
||||
keys.reverse();
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
var relevantPlayers = [];
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
$('#' + safeName(keys[i])).prependTo('#server-container');
|
||||
for (var x = 0; x < byCategories[categories[i]].length; x++) {
|
||||
var server = byCategories[categories[i]][x];
|
||||
|
||||
$('#ranking_' + safeName(keys[i])).text('#' + (keys.length - i));
|
||||
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++) {
|
||||
$('#' + safeName(keys[x])).appendTo('#server-container-' + categories[i]);
|
||||
|
||||
$('#ranking_' + safeName(keys[x])).text('#' + (x + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,12 +117,6 @@ function setAllGraphVisibility(visible) {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleControlsDrawer() {
|
||||
var div = $('#big-graph-controls-drawer');
|
||||
|
||||
div.css('display', div.css('display') !== 'none' ? 'none' : 'block');
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var socket = io.connect({
|
||||
reconnect: true,
|
||||
@ -239,8 +127,6 @@ $(document).ready(function() {
|
||||
var mojangServicesUpdater;
|
||||
var sortServersTask;
|
||||
|
||||
var graphDuration;
|
||||
|
||||
socket.on('connect', function() {
|
||||
$('#tagline-text').text('Loading...');
|
||||
|
||||
@ -264,18 +150,15 @@ $(document).ready(function() {
|
||||
lastPlayerEntries = {};
|
||||
graphs = {};
|
||||
|
||||
$('#server-container').html('');
|
||||
$('#quick-jump-container').html('');
|
||||
$('#server-container-list').html('');
|
||||
|
||||
createdCategories = false;
|
||||
|
||||
$('#big-graph').html('');
|
||||
$('#big-graph-checkboxes').html('');
|
||||
$('#big-graph-controls').css('display', 'none');
|
||||
});
|
||||
|
||||
socket.on('setGraphDuration', function(value) {
|
||||
graphDuration = value;
|
||||
});
|
||||
|
||||
socket.on('historyGraph', function(rawData) {
|
||||
var shownServers = loadGraphControls();
|
||||
|
||||
@ -335,14 +218,14 @@ $(document).ready(function() {
|
||||
|
||||
socket.on('updateHistoryGraph', function(rawData) {
|
||||
// Prevent race conditions.
|
||||
if (!graphDuration || !displayedGraphData || !hiddenGraphData) {
|
||||
if (!displayedGraphData || !hiddenGraphData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If it's not in our display group, use the hidden group instead.
|
||||
var targetGraphData = displayedGraphData[rawData.name] ? displayedGraphData : hiddenGraphData;
|
||||
|
||||
trimOldPings(targetGraphData, graphDuration);
|
||||
trimOldPings(targetGraphData, publicConfig.graphDuration);
|
||||
|
||||
targetGraphData[rawData.name].push([rawData.timestamp, rawData.players]);
|
||||
|
||||
@ -356,6 +239,8 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
socket.on('add', function(servers) {
|
||||
createCategories();
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
var history = servers[i];
|
||||
var listing = [];
|
||||
@ -396,7 +281,7 @@ $(document).ready(function() {
|
||||
<div class="column" style="float: right;">\
|
||||
<div class="chart" id="chart_' + safeName(info.name) + '"></div>\
|
||||
</div>'
|
||||
}).appendTo("#server-container");
|
||||
}).appendTo("#server-container-" + getServerByIp(info.ip).category);
|
||||
|
||||
var favicon = MISSING_FAVICON_BASE64;
|
||||
|
||||
@ -406,8 +291,6 @@ $(document).ready(function() {
|
||||
|
||||
$('#favicon_' + safeName(info.name)).attr('src', favicon);
|
||||
|
||||
$('#quick-jump-container').append('<img id="quick-jump-' + safeName(info.name) + '" data-target-network="' + safeName(info.name) + '" title="' + info.name + '" alt="' + info.name + '" class="quick-jump-icon" src="' + favicon + '">');
|
||||
|
||||
graphs[lastEntry.info.name] = {
|
||||
listing: listing,
|
||||
plot: $.plot('#chart_' + safeName(info.name), [listing], smallChartOptions)
|
||||
@ -430,7 +313,6 @@ $(document).ready(function() {
|
||||
// We have a new favicon, update the old one.
|
||||
if (update.result && update.result.favicon) {
|
||||
$('#favicon_' + safeName(update.info.name)).attr('src', update.result.favicon);
|
||||
$('#quick-jump-' + safeName(update.info.name)).attr('src', update.result.favicon);
|
||||
}
|
||||
|
||||
var graph = graphs[update.info.name];
|
||||
@ -451,31 +333,11 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('updateMojangServices', function(data) {
|
||||
// Store the update and force an update.
|
||||
lastMojangServiceUpdate = data;
|
||||
|
||||
updateMojangServices();
|
||||
});
|
||||
socket.on('updateMojangServices', updateMojangServices);
|
||||
|
||||
// Start any special updating tasks.
|
||||
mojangServicesUpdater = setInterval(function() {
|
||||
updateMojangServices();
|
||||
}, 1000);
|
||||
|
||||
sortServersTask = setInterval(function() {
|
||||
sortServers();
|
||||
}, 10 * 1000);
|
||||
|
||||
// Our super fancy scrolly thing!
|
||||
$(document).on('click', '.quick-jump-icon', function(e) {
|
||||
var serverName = $(this).attr('data-target-network');
|
||||
var target = $('#server-' + serverName);
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: target.offset().top
|
||||
}, 100);
|
||||
});
|
||||
mojangServicesUpdater = setInterval(updateMojangServices, 1000);
|
||||
sortServersTask = setInterval(sortServers, 10000);
|
||||
|
||||
$(document).on('click', '.graph-control', function(e) {
|
||||
var serverIp = $(this).attr('data-target-network');
|
||||
|
@ -2,28 +2,111 @@ var MISSING_FAVICON_BASE64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAA
|
||||
|
||||
var tooltip = $('#tooltip');
|
||||
|
||||
function saveGraphControls(displayedServers) {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
var json = JSON.stringify(displayedServers);
|
||||
var lastMojangServiceUpdate;
|
||||
var publicConfig;
|
||||
|
||||
localStorage.setItem('displayedServers', json);
|
||||
}
|
||||
var createdCategories = false;
|
||||
|
||||
function setPublicConfig(json) {
|
||||
publicConfig = json;
|
||||
}
|
||||
|
||||
function loadGraphControls() {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
var item = localStorage.getItem('displayedServers');
|
||||
function createCategories() {
|
||||
if (!createdCategories) {
|
||||
createdCategories = true;
|
||||
|
||||
if (item) {
|
||||
return JSON.parse(item);
|
||||
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>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetGraphControls() {
|
||||
if (typeof(localStorage) !== undefined) {
|
||||
localStorage.removeItem('displayedServers');
|
||||
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 getServerByIp(ip) {
|
||||
for (var i = 0; i < publicConfig.servers.length; i++) {
|
||||
var entry = publicConfig.servers[i];
|
||||
|
||||
if (entry.ip === ip) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate (and set) the HTML that displays Mojang status.
|
||||
// If nothing is passed, re-render the last update.
|
||||
// If something is passed, update and then re-render.
|
||||
function updateMojangServices(currentUpdate) {
|
||||
if (currentUpdate) {
|
||||
lastMojangServiceUpdate = currentUpdate;
|
||||
}
|
||||
|
||||
if (!lastMojangServiceUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
var keys = Object.keys(lastMojangServiceUpdate);
|
||||
var newStatus = 'Mojang Services: ';
|
||||
|
||||
var serviceCountByType = {
|
||||
Online: 0,
|
||||
Unstable: 0,
|
||||
Offline: 0
|
||||
};
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var entry = lastMojangServiceUpdate[keys[i]];
|
||||
|
||||
serviceCountByType[entry.title] += 1;
|
||||
}
|
||||
|
||||
if (serviceCountByType['Online'] === keys.length) {
|
||||
$('#tagline').attr('class', 'status-online');
|
||||
|
||||
newStatus += 'All systems operational.';
|
||||
} else {
|
||||
if (serviceCountByType['Unstable'] > serviceCountByType['Offline']) {
|
||||
$('#tagline').attr('class', 'status-unstable');
|
||||
} else {
|
||||
$('#tagline').attr('class', 'status-offline');
|
||||
}
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var entry = lastMojangServiceUpdate[keys[i]];
|
||||
|
||||
if (entry.startTime) {
|
||||
newStatus += entry.name + ' ' + entry.title.toLowerCase() + ' for ' + msToTime((new Date()).getTime() - entry.startTime + ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#tagline-text').text(newStatus);
|
||||
}
|
||||
|
||||
function findErrorMessage(error) {
|
||||
if (error.description) {
|
||||
return error.description;
|
||||
} else if (error.errno) {
|
||||
return error.errno;
|
||||
}
|
||||
}
|
||||
|
||||
function getTimestamp(ms, timeOnly) {
|
||||
@ -84,39 +167,6 @@ function trimOldPings(data, graphDuration) {
|
||||
}
|
||||
}
|
||||
|
||||
function handlePlotHover(event, pos, item) {
|
||||
if (item) {
|
||||
var text = getTimestamp(item.datapoint[0] / 1000) + '\
|
||||
<br />\
|
||||
' + formatNumber(item.datapoint[1]) + ' Players';
|
||||
|
||||
if (item.series && item.series.label) {
|
||||
text = item.series.label + '<br />' + text;
|
||||
}
|
||||
|
||||
renderTooltip(item.pageX + 5, item.pageY + 5, text);
|
||||
} else {
|
||||
hideTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
function convertGraphData(rawData) {
|
||||
var data = [];
|
||||
|
||||
var keys = Object.keys(rawData);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
data.push({
|
||||
data: rawData[keys[i]],
|
||||
yaxis: 1,
|
||||
label: keys[i],
|
||||
color: stringToColor(keys[i])
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function stringToColor(base) {
|
||||
var hash;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
"/images/compass.png": "assets/images/compass.png",
|
||||
"/js/site.js": "assets/js/site.js",
|
||||
"/js/util.js": "assets/js/util.js",
|
||||
"/js/config.js": "assets/js/config.js",
|
||||
"/css/main.css": "assets/css/main.css",
|
||||
"/favicons/hypixelpe.png": "assets/images/favicons/hypixelpe.png",
|
||||
"/favicons/mineplex.png": "assets/images/favicons/mineplex.png",
|
||||
@ -25,5 +26,10 @@
|
||||
"connectTimeout": 2500
|
||||
},
|
||||
"logToDatabase": false,
|
||||
"graphDuration": 86400000
|
||||
"graphDuration": 86400000,
|
||||
"serverCategories": {
|
||||
"major": "Major Networks",
|
||||
"midsized": "Midsized Networks",
|
||||
"small": "Small Networks"
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ var io = require('socket.io');
|
||||
var logger = require('./logger');
|
||||
|
||||
var config = require('../config.json');
|
||||
var servers = require('../servers.json');
|
||||
|
||||
var urlMapping = [];
|
||||
|
||||
@ -34,6 +35,41 @@ function handleRequest(req, res) {
|
||||
message: 'API deprecated.'
|
||||
}));
|
||||
|
||||
res.end();
|
||||
} else if (requestUrl === '/publicConfig.json') {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
||||
var categories = config.serverCategories;
|
||||
|
||||
// Legacy support for people without categories configured.
|
||||
if (!categories) {
|
||||
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
|
||||
};
|
||||
|
||||
res.write('setPublicConfig(' + JSON.stringify(publicConfig) + ');');
|
||||
|
||||
res.end();
|
||||
} else if (requestUrl in urlMapping) {
|
||||
var file = urlMapping[requestUrl];
|
||||
|
102
servers.json
102
servers.json
@ -2,171 +2,205 @@
|
||||
{
|
||||
"name": "Hypixel",
|
||||
"ip": "mc.hypixel.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "HiveMC",
|
||||
"ip": "play.hivemc.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "CubeCraft",
|
||||
"ip": "play.cubecraft.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "Overcast",
|
||||
"ip": "us.oc.tc",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Shotbow",
|
||||
"ip": "us.shotbow.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Badlion",
|
||||
"ip": "na.badlion.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "MCGamer",
|
||||
"ip": "play.mcgamer.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Olimpocraft",
|
||||
"ip": "olimpo.me",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Minecade",
|
||||
"ip": "mineca.de",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "The Nexus",
|
||||
"ip": "hub.thenexusmc.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Kohi",
|
||||
"ip": "kohi.us",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Wynncraft",
|
||||
"ip": "play.wynncraft.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "Mineplex",
|
||||
"ip": "us.mineplex.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "Hypixel PE",
|
||||
"ip": "pe.hypixel.net",
|
||||
"type": "PE"
|
||||
"type": "PE",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "Cosmic PVP",
|
||||
"ip": "cosmicpvp.me",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "PartyZone",
|
||||
"ip": "play.mcpz.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Brawl",
|
||||
"ip": "brawl.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "SaicoPvP",
|
||||
"ip": "saicopvp.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "TheArchon",
|
||||
"ip": "pvp.thearchon.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "GotPvP",
|
||||
"ip": "play.gotpvp.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Rewinside",
|
||||
"ip": "mc.rewinside.tv",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Woodycraft",
|
||||
"ip": "woodycraft.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Battlemine",
|
||||
"ip": "mc.battlemine.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Arkham",
|
||||
"ip": "mc.arkhamnetwork.org",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "MCMagic",
|
||||
"ip": "mcmagic.us",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "GommeHD",
|
||||
"ip": "gommehd.net",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "Island Clash",
|
||||
"ip": "play.islandclash.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Playminity",
|
||||
"ip": "mc.playminity.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Mobcrush Land",
|
||||
"ip": "play.mobcrush.com",
|
||||
"type": "PE"
|
||||
"type": "PE",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Epicube",
|
||||
"ip": "play.epicube.fr",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "major"
|
||||
},
|
||||
{
|
||||
"name": "BeanBlockz",
|
||||
"ip": "mc.beanblockz.com",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "GuildCraft",
|
||||
"ip": "play.guildcraft.org",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
},
|
||||
{
|
||||
"name": "Empire MC",
|
||||
"ip": "play.emc.gs",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "small"
|
||||
},
|
||||
{
|
||||
"name": "Timolia",
|
||||
"ip": "play.timolia.de",
|
||||
"type": "PC"
|
||||
"type": "PC",
|
||||
"category": "midsized"
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user