Make time since last event rendering clearer.
This commit is contained in:
@@ -638,11 +638,11 @@ BabyStats.prototype.buildGrid_ = function() {
|
|||||||
*/
|
*/
|
||||||
BabyStats.prototype.secondsToHuman_ = function(seconds) {
|
BabyStats.prototype.secondsToHuman_ = function(seconds) {
|
||||||
if (seconds > 60 * 60 * 24) {
|
if (seconds > 60 * 60 * 24) {
|
||||||
return Math.round(seconds / (60 * 60 * 24)).toString() + 'd';
|
return Math.floor(seconds / (60 * 60 * 24)).toString() + 'd';
|
||||||
} else if (seconds > 60 * 60) {
|
} else if (seconds > 60 * 60) {
|
||||||
return Math.round(seconds / (60 * 60)).toString() + 'h';
|
return Math.floor(seconds / (60 * 60)).toString() + 'h';
|
||||||
} else {
|
} else {
|
||||||
return Math.round(seconds / 60).toString() + 'm';
|
return Math.floor(seconds / 60).toString() + 'm';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -655,7 +655,8 @@ BabyStats.prototype.updateTileStatus_ = function() {
|
|||||||
this.tiles_.forEach(function(tile) {
|
this.tiles_.forEach(function(tile) {
|
||||||
if (tile.lastSeen) {
|
if (tile.lastSeen) {
|
||||||
var timeSince = now - tile.lastSeen;
|
var timeSince = now - tile.lastSeen;
|
||||||
tile.statusBox.textContent = this.secondsToHuman_(timeSince) + ' ago';
|
tile.statusBox.textContent = (
|
||||||
|
timeSince < 60 ? 'just now' : this.secondsToHuman_(timeSince) + ' ago');
|
||||||
var timedOut = tile.timeout && (now - tile.timeout > tile.lastSeen);
|
var timedOut = tile.timeout && (now - tile.timeout > tile.lastSeen);
|
||||||
if (tile.canceled || timedOut) {
|
if (tile.canceled || timedOut) {
|
||||||
this.removeCSSClass_(tile.statusBox, 'babyStatsCellStatusActive');
|
this.removeCSSClass_(tile.statusBox, 'babyStatsCellStatusActive');
|
||||||
|
|||||||
Reference in New Issue
Block a user