Allow custom Graph colors (#76)
This commit is contained in:

committed by
Cryptkeeper!

parent
42c744b9dd
commit
0955e8dbcd
@ -117,12 +117,12 @@ function convertGraphData(rawData) {
|
||||
|
||||
var keys = Object.keys(rawData);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
data.push({
|
||||
data: rawData[keys[i]],
|
||||
yaxis: 1,
|
||||
label: keys[i],
|
||||
color: stringToColor(keys[i])
|
||||
color: getServerColor(keys[i])
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ function updatePercentageBar() {
|
||||
id: 'perc_bar_part_' + safeNameCopy,
|
||||
class: 'perc-bar-part',
|
||||
html: '',
|
||||
style: 'background: ' + stringToColor(server) + ';'
|
||||
style: 'background: ' + getServerColor(server) + ';'
|
||||
}).appendTo(parent);
|
||||
|
||||
div = $('#perc_bar_part_' + safeNameCopy);
|
||||
|
@ -76,16 +76,30 @@ function getServersByCategory() {
|
||||
return byCategory;
|
||||
}
|
||||
|
||||
function getServerByIp(ip) {
|
||||
function getServerByField(id, value) {
|
||||
for (var i = 0; i < publicConfig.servers.length; i++) {
|
||||
var entry = publicConfig.servers[i];
|
||||
|
||||
if (entry.ip === ip) {
|
||||
if (entry[id] === value) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getServerByIp(ip) {
|
||||
return getServerByField('ip', ip);
|
||||
}
|
||||
|
||||
function getServerByName(name) {
|
||||
return getServerByField('name', name);
|
||||
}
|
||||
|
||||
function getServerColor(name) {
|
||||
var server = getServerByName(name);
|
||||
|
||||
return server ? server.color : stringToColor(name);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
Reference in New Issue
Block a user