added time filter

This commit is contained in:
Marian Oancea
2015-02-05 03:33:58 +02:00
parent f36a5dda1a
commit ad42e1c389
3 changed files with 25 additions and 3 deletions

View File

@@ -49,4 +49,21 @@ angular.module('netStatsApp.filters', [])
return function(current, best) {
return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger'));
};
})
.filter('timeClass', function() {
return function(timestamp) {
var time = Math.floor((new Date()).getTime() / 1000);
var diff = time - timestamp;
if(diff <= 12)
return 'text-success';
if(diff <= 20)
return 'text-info';
if(diff <= 30)
return 'text-warning';
return 'text-danger';
};
});