var directives = angular.module('core.directives', []); directives.filter('countBadgeByLevel', function () { return function (badges) { // 5 levels var levels = [0, 0, 0, 0, 0]; angular.forEach(badges, function (value, key) { levels[value.level - 1]++; }); return levels; } }); directives.filter('isodate', function () { return function (date) { return date.toISOString(); } }); directives.filter('gz', function () { return function (num) { if (angular.isArray(num)) { var out = []; angular.forEach(num, function (x) { if (x > 0) { out.push(x); } }); return out; } else if (angular.isNumber(num)) { return num > 0; } console.log("fail"); return undefined; } }); directives.directive('navbar', function () { return { restrict: 'E', templateUrl: '/apps/core/navbar.html?noCache=' + noCache }; }); directives.directive('badge', function () { return { restrict: 'E', scope: { badgeDetail: '=badgeDetail' }, template: '' + ' {{badgeDetail.badge.name}}' + ' ' + '' + ' awarded to ' + '{{badgeDetail.person.name}}. ' + 'More' } }); directives.directive('badgeSpan', function () { var template = '' + ' {{badge.name}}' + ' ' + ''; return { restrict: 'E', scope: { badge: '=badge' }, template: template } }); directives.directive('personLink', function () { return { restrict: 'E', scope: { person: '=person' }, template: '{{person.name}}' } }); directives.directive('personAvatar', function () { return { restrict: 'E', scope: { person: '=person' }, template: '' } });