-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheventController.js
92 lines (78 loc) · 3.21 KB
/
eventController.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
app.controller('eventController', function($scope, EventService) {
$scope.eventListZen = EventService.search({
query : {
dojoId : "55a9b83e-9188-45f5-8a6a-72f0af31aad2",
status : "published",
filterPastEvents : false,
limit$ : 10,
skip$ : 0,
sort$ : {
createdAt : -1
}
}
});
$scope.eventList = eventList; // from global var in data script
$scope.pastEventList = []; // filled in init
$scope.nextEvent = null; // initialized in init
$scope.futureEventList = []; // filled in init
$scope.dateObject = new Date();
$scope.currentDate = {
'year' : $scope.dateObject.getFullYear(),
'month' : $scope.dateObject.getMonth() + 1,
'day' : $scope.dateObject.getDate()
};
$scope.processDisplayValues = function(eventElement) {
eventElement.displayYear = '' + eventElement.year;
eventElement.displayMonth = $scope.padToTwoDigits(eventElement.month);
eventElement.displayMonthTextShort = $scope.shortMonthNames[eventElement.month - 1];
eventElement.displayDay = $scope.padToTwoDigits(eventElement.day);
eventElement.displayStartTime = $scope.padToTwoDigits(eventElement.startHour) +
':' + $scope.padToTwoDigits(eventElement.startMin);
eventElement.displayEndTime = $scope.padToTwoDigits(eventElement.endHour) +
':' + $scope.padToTwoDigits(eventElement.endMin);
return eventElement;
};
$scope.shortMonthNames = ["Jan.", "Feb.", "März", "Apr.",
"Mai", "Juni", "Juli", "Aug.",
"Sep.", "Okt.", "Nov.", "Dez." ];
$scope.padToTwoDigits = function(number) {
if (number < 10 && number >= 0) {
return '0' + number;
}
else if (number < 0) {
return '00';
}
else {
return '' + number;
}
};
$scope.init = function() {
// fill split event lists
for(i=0; i < $scope.eventList.length; i++) {
if ($scope.eventList[i].year < $scope.currentDate.year) {
$scope.pastEventList.push(
$scope.processDisplayValues($scope.eventList[i]));
continue;
}
else if ($scope.eventList[i].year == $scope.currentDate.year &&
$scope.eventList[i].month < $scope.currentDate.month) {
$scope.pastEventList.push(
$scope.processDisplayValues($scope.eventList[i]));
continue;
}
else if ($scope.eventList[i].month == $scope.currentDate.month &&
$scope.eventList[i].day < $scope.currentDate.day) {
$scope.pastEventList.push(
$scope.processDisplayValues($scope.eventList[i]));
continue;
}
else {
$scope.futureEventList.push(
$scope.processDisplayValues($scope.eventList[i]));
}
}
// separate next event
$scope.nextEvent = $scope.futureEventList.shift();
};
$scope.init();
});