-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScoredSeparatelyMatrix.js
144 lines (129 loc) · 3.95 KB
/
ScoredSeparatelyMatrix.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//
// name=ScoredSeperatelyMatrix.js
// dependencies=
// description=Shows the result tables as a matrix if they have been scored separately.
// author=Colin Jenkins
// version=1.0
// date=2015-07-27
// url=
// twitter=@op12no2
//
// Please note that this effect only works when more then one or more
// group (e.g. fleet) has been scored separately. There may be some
// other limitations. Footers and notes are removed. Burgees are
// consolidated.
//
$.fn.exists = function () {
return this.length !== 0;
}
function showcodes () {
$('h3.codestitle').fadeIn('slow');
$('table.codestable').fadeIn('slow');
}
function showprizes () {
$('h3.prizestitle').show();
$('table.prizestable').show();
}
function showsummary (f) {
hideall();
$(d.sum[f].title).show();
$(d.sum[f].caption).show();
$(d.sum[f].table).fadeIn('slow');
showcodes()
}
function showrace (f,r) {
hideall();
showcodes()
$(d.sum[f].races[r].title).show();
$(d.sum[f].races[r].caption).show();
$(d.sum[f].races[r].table).fadeIn('slow');
}
function hideall () {
$('h3.prizestitle').hide();
$('table.prizestable').hide();
hideinit();
}
function hideinit () {
$('h3.codestitle').hide();
$('table.codestable').hide();
$('h3.summarytitle').hide();
$('div.summarycaption').hide();
$('table.summarytable').hide();
$('h3.racetitle').hide();
$('div.racecaption').hide();
$('table.racetable').hide();
}
$(function() {
$('img').removeClass('hardleft');
$('img').removeClass('hardright');
$('img.hardright').remove();
$('p.hardright').remove();
$('p.hardleft').remove();
$('div.contents').remove();
$('p.seriesnotes').remove();
$('p.racenotes').remove();
d = {};
d.sum = [];
$('h3.summarytitle').each(function(index) {
if (!d.sum[index])
d.sum[index] = {};
d.sum[index].title = this;
console.log($(d.sum[index].title).text());
if ($(this).attr('id'))
d.sum[index].id = $(this).attr('id').replace(/summary/gi,'');
else
d.sum[index].id = 'overall';
//console.log($(this).attr('id'));
//console.log(d.sum[index].id);
d.sum[index].caption = $(this).next();
d.sum[index].table = $(this).next().next();
maxraces = 100; //hack $('h3.racetitle').size();
minr = 10000;
maxr = 0;
//console.log(maxraces);
d.sum[index].races = [];
for (var i=0; i<maxraces; i++) {
var r = i + 1;
var id = '#r' + r + d.sum[index].id;
//console.log(id);
if ($(id).exists()) {
if (r > maxr)
maxr = r;
if (r < minr)
minr = r;
d.sum[index].races[r] = {};
d.sum[index].races[r].raceno = r;
d.sum[index].races[r].title = $(id);
d.sum[index].races[r].caption = $(id).next();
d.sum[index].races[r].table = $(id).next().next();
}
}
});
$('a.racelink').each(function(index) {
$(this).parent().html($(this).text());
});
hideinit();
h = '<div style="margin: 40px auto 20px; auto;" id="dynamic"><table>';
for (var f=0; f<d.sum.length; f++) {
var fleet = d.sum[f];
var races = d.sum[f].races;
h += '<tr><td>' + $(fleet.title).text() + '</td>';
var linktitle = 'Overall';
h += '<td><a href="#" onclick="showsummary(' + f + ');">' + linktitle + '</a></td>';
for (var r=minr; r<=maxr; r++) {
var linktitle = $.trim(($(races[r].title).text().split('-'))[0]);
h += '<td>';
if (races[r])
h += '<a href="#" onclick="showrace(' + f + ',' + r + ');">' + linktitle + '</a>';
else
h += ' ';
h += '</td>';
}
h += '</tr>';
}
//h += '<tr><td><a href="#" onclick="showcodes();">Scoring codes</a></td></tr>';
//h += '<tr><td><a href="#" onclick="showprizes();">Prizes</a></td></tr>';
h += '</table></div>';
$('h3.seriestitle').append(h);
});