2014-03-14 13:38:27 -07:00
|
|
|
'use strict';
|
2014-05-16 13:18:25 -07:00
|
|
|
|
|
|
|
angular.module('copay.filters', [])
|
|
|
|
.filter('amTimeAgo', ['amMoment', function(amMoment) {
|
2014-05-16 15:34:27 -07:00
|
|
|
return function(input) {
|
|
|
|
return amMoment.preprocessDate(input).fromNow();
|
|
|
|
};
|
|
|
|
}])
|
|
|
|
.filter('groupByAddress', function() {
|
|
|
|
return function(inputs) {
|
|
|
|
function reduce(dic, input) {
|
|
|
|
if(!dic[input.addr]) dic[input.addr] = 0;
|
|
|
|
dic[input.addr] += input.value;
|
|
|
|
return dic;
|
|
|
|
}
|
|
|
|
|
|
|
|
var dic = inputs.reduce(reduce, {});
|
|
|
|
return Object.keys(dic).map(function(key) {
|
|
|
|
return { addr: key, value: dic[key] };
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|