From 39636be7b018b9121696ce7bdc462ab2c3c8185d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 11 Jan 2013 17:11:28 +0100 Subject: o Creating bin/web for running the web application. --- src/main/resources/webapp/apps/app.js | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 src/main/resources/webapp/apps/app.js (limited to 'src/main/resources/webapp/apps/app.js') diff --git a/src/main/resources/webapp/apps/app.js b/src/main/resources/webapp/apps/app.js new file mode 100755 index 0000000..068f454 --- /dev/null +++ b/src/main/resources/webapp/apps/app.js @@ -0,0 +1,97 @@ +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: '' + } +}); -- cgit v1.2.3