-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
65 lines (57 loc) · 1.85 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
angular.module('pghpy', [])
.filter('trusted', ['$sce', function($sce) {
return function(text) {
return $sce.trustAsHtml(text);
};
}])
.filter('isPast', [function() {
return function(input) {
date = new Date(input);
today = new Date();
if (date < today) {
return 'past';
}
return false;
};
}])
.filter('htmlify', ['$sce', function($sce) {
var htmlify = function(input, lookup) {
console.log('Lookup', lookup);
if (Object.prototype.toString.call(input) === '[object Object]') {
text = input.name;
if ('url' in input) {
output = link = document.createElement('a');
link.href = input.url;
link.appendChild(document.createTextNode(text));
return link.outerHTML;
}
return text;
} else if (Object.prototype.toString.call(input) === '[object Array]') {
length = input.length;
output = '';
for (i in input) {
if (i > 0 && i < length - 1) {
output += ', ';
} else if (i > 0 && i == length - 1) {
output += ' & ';
}
output += htmlify(input[i], lookup);
}
return output;
} else if (Object.prototype.toString.call(input) === '[object String]') {
if (input in lookup) {
return htmlify(lookup[input], lookup);
}
return input;
}
};
return htmlify;
}])
.controller('EventListCtrl', ['$http', '$scope', function($http, $scope) {
$scope.events = [];
$http.get('/events.json').then(function(data) {
$scope.events = data.data.events;
$scope.presenters = data.data.presenters;
$scope.locations = data.data.locations;
});
}]);