Make repo pull and push counts on the info page be abbreviated
This commit is contained in:
parent
1979f87384
commit
be9906167a
2 changed files with 30 additions and 4 deletions
26
static/js/directives/filters/abbreviated.js
Normal file
26
static/js/directives/filters/abbreviated.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Filter which displays numbers with suffixes.
|
||||
*
|
||||
* Based on: https://gist.github.com/pedrorocha-net/9aa21d5f34d9cc15d18f
|
||||
*/
|
||||
angular.module('quay').filter('abbreviated', function() {
|
||||
return function(number) {
|
||||
if (number >= 10000000) {
|
||||
return (number / 1000000).toFixed(0) + 'M'
|
||||
}
|
||||
|
||||
if (number >= 1000000) {
|
||||
return (number / 1000000).toFixed(1) + 'M'
|
||||
}
|
||||
|
||||
if (number >= 10000) {
|
||||
return (number / 1000).toFixed(0) + 'K'
|
||||
}
|
||||
|
||||
if (number >= 1000) {
|
||||
return (number / 1000).toFixed(1) + 'K'
|
||||
}
|
||||
|
||||
return number
|
||||
}
|
||||
});
|
Reference in a new issue