-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.js
More file actions
89 lines (73 loc) · 2.25 KB
/
render.js
File metadata and controls
89 lines (73 loc) · 2.25 KB
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
var clc = require('cli-color');
var Table = require('cli-table');
var jsonQuery = require('json-query');
class Render {
constructor() {
this.clc = clc
}
Fixtures(fixtures, input) {
console.log("\n");
console.log("UEFA EURO 2016 CLI v1.0");
console.log("\n");
console.log( input + " Match Results");
console.log("-----------------------------");
var clc = this.clc
Object.keys(fixtures).forEach(function(key) {
var val = fixtures[key];
var homeTeamName = val.homeTeamName;
var awayTeamName = val.awayTeamName;
var homeGoals = val.result.goalsHomeTeam;
var awayGoals = val.result.goalsAwayTeam;
if(val.status == 'FINISHED') {
var goals = homeGoals + "-" + awayGoals;
console.log(clc.green("(" + goals + ") " + homeTeamName + " vs " + awayTeamName))
} else {
var goals = '---';
console.log("(" + goals + ") " + homeTeamName + " vs " + awayTeamName + clc.red(" ( Will be played on " + val.date + ")"));
}
})
}
LeagueTable(GroupDetails, countryID, input) {
var clc = this.clc
var standingTable = jsonQuery('standings[][teamId=' + countryID + '].group', {
data: GroupDetails
});
console.log("\n");
var groupData = jsonQuery('standings['+standingTable.value+']', {
data: GroupDetails
});
console.log("[GROUP "+ standingTable.value +"] Classement");
// console.log(groupData.value);
var tableClassement = groupData.value;
var table = new Table({
head: [ 'Country',
'P',
'F',
'A',
'D',
'Point'
]
, colWidths: [20, 5, 5, 5, 5, 10]
});
tableClassement.forEach(function(val) {
if(val.team == input) {
table.push(
[
clc.green(val.team),
clc.green(val.playedGames),
clc.green(val.goals),
clc.green(val.goalsAgainst),
clc.green(val.goalDifference),
clc.green(val.points)
]
);
} else {
table.push(
[ val.team, val.playedGames, val.goals, val.goalsAgainst, val.goalDifference, val.points]
);
}
});
console.log(table.toString());
}
}
module.exports = Render;