From 7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 6 Jan 2013 23:57:14 +0100 Subject: o Creating a recent badges view. --- src/main/webapp/apps/app.js | 58 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 7 deletions(-) (limited to 'src/main/webapp/apps/app.js') diff --git a/src/main/webapp/apps/app.js b/src/main/webapp/apps/app.js index 3d200ec..36736cd 100644 --- a/src/main/webapp/apps/app.js +++ b/src/main/webapp/apps/app.js @@ -4,26 +4,32 @@ directives.filter('countBadgeByLevel', function () { return function (badges) { // 5 levels var levels = [0, 0, 0, 0, 0]; - angular.forEach(badges, function(value, key){ + 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)) { + if (angular.isArray(num)) { var out = []; - angular.forEach(num, function(x){ - if(x > 0) { + angular.forEach(num, function (x) { + if (x > 0) { out.push(x); } }); return out; } - else if(angular.isNumber(num)) { + else if (angular.isNumber(num)) { return num > 0; } console.log("fail"); @@ -44,9 +50,47 @@ directives.directive('badge', function () { scope: { badgeDetail: '=badgeDetail' }, - template: '{{badgeDetail.badge.name}}' + - '' + + template: '' + + ' {{badgeDetail.badge.name}}' + + ' ' + + '' + ' awarded to ' + '{{badgeDetail.person.name}}' } }); + +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: '' + } +}); -- cgit v1.2.3