Skip to content

Commit f398b2d

Browse files
author
András Németh
committed
Code und Daten für Angular trennen
1 parent 7170e20 commit f398b2d

File tree

4 files changed

+95
-87
lines changed

4 files changed

+95
-87
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
<!-- AngularJS base and data scripts -->
3333
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
34-
<script src="js-data/webApp.js"></script>
35-
<script src="js-data/eventController.js"></script>
34+
<script src="js-angular/webApp.js"></script>
35+
<script src="js-angular/eventController.js"></script>
3636

3737
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
3838
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,22 @@
11
app.controller('eventController', function($scope) {
22

3-
$scope.eventList = [ // MANUALLY EDITED RAW DATA
4-
/** This is an example entry:
5-
* (Time values must be integers.)
6-
{
7-
'year' : 2000,
8-
'month' : 1,
9-
'day' : 1,
10-
'startHour' : 17,
11-
'startMin' : 0,
12-
'endHour' : 19,
13-
'endMin' : 0,
14-
'location' : 'Raum',
15-
'isIntroEvent' : false
16-
}**/
17-
18-
{
19-
'year' : 2016,
20-
'month' : 9,
21-
'day' : 16,
22-
'startHour' : 17,
23-
'startMin' : 0,
24-
'endHour' : 19,
25-
'endMin' : 0,
26-
'location' : 'Seminarraum 236',
27-
'isIntroEvent' : true
28-
},
29-
{
30-
'year' : 2016,
31-
'month' : 9,
32-
'day' : 30,
33-
'startHour' : 17,
34-
'startMin' : 0,
35-
'endHour' : 19,
36-
'endMin' : 0,
37-
'location' : 'Seminarraum 236',
38-
'isIntroEvent' : false
39-
},
40-
{
41-
'year' : 2016,
42-
'month' : 10,
43-
'day' : 14,
44-
'startHour' : 17,
45-
'startMin' : 0,
46-
'endHour' : 19,
47-
'endMin' : 0,
48-
'location' : 'Seminarraum 236',
49-
'isIntroEvent' : false
50-
},
51-
{
52-
'year' : 2016,
53-
'month' : 10,
54-
'day' : 28,
55-
'startHour' : 17,
56-
'startMin' : 0,
57-
'endHour' : 19,
58-
'endMin' : 0,
59-
'location' : 'Seminarraum 236',
60-
'isIntroEvent' : true
61-
},
62-
{
63-
'year' : 2016,
64-
'month' : 11,
65-
'day' : 11,
66-
'startHour' : 17,
67-
'startMin' : 0,
68-
'endHour' : 19,
69-
'endMin' : 0,
70-
'location' : 'Seminarraum 236',
71-
'isIntroEvent' : false
72-
},
73-
{
74-
'year' : 2016,
75-
'month' : 11,
76-
'day' : 25,
77-
'startHour' : 17,
78-
'startMin' : 0,
79-
'endHour' : 19,
80-
'endMin' : 0,
81-
'location' : 'Seminarraum 236',
82-
'isIntroEvent' : true
83-
}
84-
85-
];
3+
/*
4+
Expected structure for "eventList" entries:
5+
(Time values must be integers.)
6+
{
7+
"year" : 2000,
8+
"month" : 1,
9+
"day" : 1,
10+
"startHour" : 17,
11+
"startMin" : 0,
12+
"endHour" : 19,
13+
"endMin" : 0,
14+
"location" : "Raum",
15+
"isIntroEvent" : false
16+
}
17+
*/
8618

19+
$scope.eventList = null; // initialized in init
8720
$scope.pastEventList = []; // filled in init
8821
$scope.nextEvent = null; // initialized in init
8922
$scope.futureEventList = []; // filled in init
@@ -123,7 +56,9 @@ app.controller('eventController', function($scope) {
12356
}
12457
};
12558

126-
$scope.init = function() {
59+
$scope.init = function(argEventList) {
60+
61+
$scope.eventList = argEventList;
12762

12863
// fill split event lists
12964

@@ -157,6 +92,8 @@ app.controller('eventController', function($scope) {
15792

15893
};
15994

160-
$scope.init();
95+
$.getJSON("js-data/events.json", function (data) {
96+
$scope.init(data.eventList);
97+
});
16198

16299
});
File renamed without changes.

js-data/events.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"eventList" : [
3+
{
4+
"year" : 2016,
5+
"month" : 9,
6+
"day" : 16,
7+
"startHour" : 17,
8+
"startMin" : 0,
9+
"endHour" : 19,
10+
"endMin" : 0,
11+
"location" : "Seminarraum 236",
12+
"isIntroEvent" : true
13+
},
14+
{
15+
"year" : 2016,
16+
"month" : 9,
17+
"day" : 30,
18+
"startHour" : 17,
19+
"startMin" : 0,
20+
"endHour" : 19,
21+
"endMin" : 0,
22+
"location" : "Seminarraum 236",
23+
"isIntroEvent" : false
24+
},
25+
{
26+
"year" : 2016,
27+
"month" : 10,
28+
"day" : 14,
29+
"startHour" : 17,
30+
"startMin" : 0,
31+
"endHour" : 19,
32+
"endMin" : 0,
33+
"location" : "Seminarraum 236",
34+
"isIntroEvent" : false
35+
},
36+
{
37+
"year" : 2016,
38+
"month" : 10,
39+
"day" : 28,
40+
"startHour" : 17,
41+
"startMin" : 0,
42+
"endHour" : 19,
43+
"endMin" : 0,
44+
"location" : "Seminarraum 236",
45+
"isIntroEvent" : true
46+
},
47+
{
48+
"year" : 2016,
49+
"month" : 11,
50+
"day" : 11,
51+
"startHour" : 17,
52+
"startMin" : 0,
53+
"endHour" : 19,
54+
"endMin" : 0,
55+
"location" : "Seminarraum 236",
56+
"isIntroEvent" : false
57+
},
58+
{
59+
"year" : 2016,
60+
"month" : 11,
61+
"day" : 25,
62+
"startHour" : 17,
63+
"startMin" : 0,
64+
"endHour" : 19,
65+
"endMin" : 0,
66+
"location" : "Seminarraum 236",
67+
"isIntroEvent" : true
68+
}
69+
70+
]
71+
}

0 commit comments

Comments
 (0)