automatically set peak label using publicConfig.graphDuration
This commit is contained in:
parent
ad6907b0cc
commit
9f5827f06c
@ -246,7 +246,8 @@ function updateServerPeak(name, time, playerCount) {
|
|||||||
if (end) {
|
if (end) {
|
||||||
timestamp += ' ' + end;
|
timestamp += ' ' + end;
|
||||||
}
|
}
|
||||||
$('#peak_' + safeNameCopy).html('24h Peak: ' + formatNumber(playerCount) + ' @ ' + timestamp);
|
var timeLabel = msToTime(publicConfig.graphDuration);
|
||||||
|
$('#peak_' + safeNameCopy).html(timeLabel + ' Peak: ' + formatNumber(playerCount) + ' @ ' + timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
@ -163,8 +163,18 @@ function msToTime(timer) {
|
|||||||
var minutes = timer % 60;
|
var minutes = timer % 60;
|
||||||
var hours = (timer - minutes) / 60;
|
var hours = (timer - minutes) / 60;
|
||||||
|
|
||||||
|
var days = Math.floor(hours / 24);
|
||||||
|
hours -= days * 24;
|
||||||
|
|
||||||
var string = '';
|
var string = '';
|
||||||
|
|
||||||
|
// hack: only format days if >1, if === 1 it will format as "24h" instead
|
||||||
|
if (days > 1) {
|
||||||
|
string += days + 'd';
|
||||||
|
} else if (days === 1) {
|
||||||
|
hours += 24;
|
||||||
|
}
|
||||||
|
|
||||||
if (hours > 0) {
|
if (hours > 0) {
|
||||||
string += hours + 'h';
|
string += hours + 'h';
|
||||||
}
|
}
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "minetrack",
|
"name": "minetrack",
|
||||||
"version": "4.0.2",
|
"version": "4.0.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user