automatically set peak label using publicConfig.graphDuration

This commit is contained in:
Nick Krecklow 2020-04-01 22:36:44 -05:00
parent ad6907b0cc
commit 9f5827f06c
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
3 changed files with 13 additions and 2 deletions

View File

@ -246,7 +246,8 @@ function updateServerPeak(name, time, playerCount) {
if (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() {

View File

@ -163,8 +163,18 @@ function msToTime(timer) {
var minutes = timer % 60;
var hours = (timer - minutes) / 60;
var days = Math.floor(hours / 24);
hours -= days * 24;
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) {
string += hours + 'h';
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "minetrack",
"version": "4.0.2",
"version": "4.0.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {