diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 7639de6e..1df0636f 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -288,25 +288,23 @@ function isPrivateIP(ip_address) { } function humanTime(seconds) { - var text; - if (seconds >= 86400) { - text = '

' + Math.floor(moment.duration(seconds, 'seconds').asDays()) + '

days

' + '

' + - Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()) + '

hrs

' + '

' + - Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) + '

mins

'; - return text; - } else if (seconds >= 3600) { - text = '

' + Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()) + '

hrs

' + - '

' + Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) + - '

mins

'; - return text; - } else if (seconds >= 60) { - text = '

' + Math.floor(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()) + - '

mins

'; - return text; + var d = Math.floor(moment.duration(seconds, 'seconds').asDays()); + var h = Math.floor(moment.duration((seconds % 86400), 'seconds').asHours()); + var m = Math.round(moment.duration(((seconds % 86400) % 3600), 'seconds').asMinutes()); + + var text = ''; + if (d > 0) { + text = '

' + d + '

day' + ((d > 1) ? 's' : '') + '

' + + '

' + h + '

hr' + ((h > 1) ? 's' : '') + '

' + + '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; + } else if (h > 0) { + text = '

' + h + '

hr' + ((h > 1) ? 's' : '') + '

' + + '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; } else { - text = '

0

mins

'; - return text; + text = '

' + m + '

min' + ((m > 1) ? 's' : '') + '

'; } + + return text } String.prototype.toProperCase = function () {