-
Notifications
You must be signed in to change notification settings - Fork 0
/
controllers.js
124 lines (92 loc) · 4.32 KB
/
controllers.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var matchControllers = angular.module("matchControllers", []);
matchControllers.controller("ListController", [ '$http', '$q', function($http, $q){
var main =this;
main.loadAllData = function(){
// main.tmpResult =[];
/* Define vraible */
var first = $http.get("2015-2016.json.txt"),
second = $http.get("2016-2017.json.txt");
$q.all([first, second]).then(function(result) {
// console.log(result);
main.tmpResult =[];
angular.forEach(result, function(responsedata) {
main.tmp=responsedata.data;
main.tmpResult.push(main.tmp);
});
console.log(main.tmpResult);
/*return tmp;*/
})
}
}]
);
/*--- match details page on click on coutry page */
matchControllers.controller("DetailsController", ['$http', '$q', '$routeParams',function( $http, $q, $routeParams){
// define the context
var main =this;
main.loadOneMatchData = function(){
main.yearId = $routeParams.yearId;
main.roundsId = $routeParams.roundsId;
main.matchId = $routeParams.matchId;
var first = $http.get("2015-2016.json.txt"),
second = $http.get("2016-2017.json.txt");
$q.all([first, second]).then(function(result) {
main.matchData = [];
main.mainData = result[main.yearId].data.rounds[main.roundsId].matches[main.matchId] ;
console.log(main.mainData.date );
});
}
}]);
/* ------------ Team by details ----------------------- */
matchControllers.controller("teamDetailsController", ['$http','$q', '$routeParams', function($http, $q, $routeParams){
// define
var main = this;
main.loadOneTeamData=function() {
// main.allMatchDatas = [];
// route param define team name
main.teamId = $routeParams.teamId;
var first = $http.get("2015-2016.json.txt"),
second = $http.get("2016-2017.json.txt");
$q.all([first, second]).then(function(result){
/*total match palyed*/ var count = 0;
/*total Win match palyed*/ var winMatchCount = 0;
/*total Loss match palyed*/ var losMatchCount = 0;
/*total Loss match palyed*/ var drawMatchCount = 0;
/*Toal Goal Match */ var goalMatch=0;
angular.forEach(result, function(matchData){
main.matchData1 = matchData.data.rounds
angular.forEach(main.matchData1, function(allMatchData){
angular.forEach(allMatchData.matches, function(value){
// taotal match palyed
if(value.team1.name=== main.teamId || value.team2.name=== main.teamId){
count++;
}
document.getElementById("totalMatch").innerText= count;
// Total win matched
if(value.team1.name === main.teamId && value.score1 > value.score2 || value.team2.name === main.teamId && value.score2 > value.score1 ){
winMatchCount++;
}
document.getElementById("winMatch").innerText=winMatchCount;
// Total loss Match
if(value.team1.name === main.teamId && value.score1 < value.score2 || value.team2.name === main.teamId && value.score2 < value.score1){
losMatchCount++;
}
document.getElementById("lossMatch").innerText=losMatchCount;
// Total Draw Match
if(value.team1.name=== main.teamId && value.score1 == value.score2 || value.team2.name === main.teamId && value.score2 == value.score1){
drawMatchCount++;
}
document.getElementById("drawMatch").innerText=drawMatchCount;
// Total goal of matches
if(value.team1.name === main.teamId){
goalMatch += value.score1;
}
if(value.team2.name === main.teamId){
goalMatch += value.score2;
}
document.getElementById("totalGoalMatch").innerText=goalMatch;
});
});
})
});
}
}]);