-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlivescore.js
111 lines (88 loc) · 2.79 KB
/
livescore.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
jQuery.fn.livescore = function (config) {
var $this = this,
$header,
$headerTitle,
$content,
rows = [];
config = jQuery.extend({
title: 'Live Score',
data: []
}, config);
function renderLayout() {
$this.addClass('ls-container');
$header = jQuery('<div />');
$header.addClass('ls-header');
$header.appendTo($this);
$headerTitle = jQuery('<h3 />');
$headerTitle.html(config.title);
$headerTitle.appendTo($header);
$content = jQuery('<div />');
$content.addClass('ls-content');
$content.appendTo($this);
}
function renderContent() {
var i, $row,
$labelDate,
$labelTime,
$labelQueue,
$timeline,
$score,
$twitter;
for (i = 0; i < config.data.length; i += 1) {
$row = jQuery('<div />');
$row.addClass('ls-row');
$row.appendTo($content);
$labelDate = jQuery('<label />');
$labelDate.addClass('ls-row-date');
$labelDate.appendTo($row);
$labelDate.html(config.data[i].time[0]);
$labelTime = jQuery('<label />');
$labelTime.addClass('ls-row-time');
$labelTime.appendTo($row);
$labelTime.html(config.data[i].time[1]);
$labelQueue = jQuery('<div />');
$labelQueue.addClass('ls-row-queue');
$labelQueue.appendTo($row);
$labelQueue.html('F' + (i + 1));
$match = jQuery('<div />');
$match.addClass('ls-row-match')
$match.appendTo($row);
$player1team = jQuery('<label />');
$player1team.addClass('ls-row-player');
$player1team.html(config.data[i].players[0]);
$player1team.appendTo($match);
$player1score = jQuery('<label />');
$player1score.addClass('ls-row-score');
$player1score.html(config.data[i].currentScore[0]);
$player1score.appendTo($match);
jQuery('<div />').addClass('clear').addClass('ls-row-separator').appendTo($match);
$player2team = jQuery('<label />');
$player2team.addClass('ls-row-player');
$player2team.html(config.data[i].players[1]);
$player2team.appendTo($match);
$player2score = jQuery('<label />');
$player2score.addClass('ls-row-score');
$player2score.html(config.data[i].currentScore[1]);
$player2score.appendTo($match);
$twitter = jQuery('<button />');
$twitter.addClass('ls-row-twitter');
$twitter.appendTo($row);
$('<i />').addClass('fa fa-twitter').appendTo($twitter);
if (i + 1 == config.data.length) {
$row.addClass('ls-row-last');
}
rows.push($row);
}
if (config.data.length == 0) {
$row = jQuery('<div />');
$row.addClass('ls-row');
$row.addClass('ls-row-last');
$row.addClass('ls-row-empty');
$row.html('no match');
$row.appendTo($content);
}
}
renderLayout();
renderContent();
return this;
}