-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
241 lines (189 loc) · 7.85 KB
/
index.html
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>10P ATX Warmups</title>
<script language="JavaScript">
var oneDay = 24 * 60 * 60 * 1000;
var warmupWeekDayMap = [
['A','B','C','D'],
['E','F','G','H'],
['B','A','D','C'],
['F','E','H','G'],
['D','C','B','A'],
['H','G','F','E'],
['C','D','A','B'],
['G','H','E','F']
];
// Youtube video source https://www.youtube.com/playlist?list=PLBbtD5r9yUN5LrQ9_G4cOP61lfJfCm-1n
var warmupMap = [
['Granbys', 'K87AUrlmSBE'],
['Hail Marys', '_INFTLutYfg'],
['Pressure Passes', '9y7kmaTfHDg'],
['Standing Psases', 'Q2b6SMRYPP4'],
['Quarter Guard', 'LGE2L12N-FA'],
['Butterflies', 'PDhMLvfzK9w'],
['Top Half Passes', 'oUibzLZz0I0'],
['Open Guards', 'OYnWxY-PBBc']
];
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function today() {
return new Date(formatDate(new Date()));
}
function formatDate(date) {
var dd = date.getDate();
var mm = date.getMonth()+1; //January is 0!
var yyyy = date.getFullYear();
if (dd < 10) {
dd ='0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
return mm + '/' + dd + '/' + yyyy;
}
function getWarmupLetterFromDate(warmupDate) {
var seedDate = new Date('2016-04-11'); // Week 1, Day A (which is a monday)
var diffDays = Math.round(Math.abs(warmupDate.getTime() - seedDate.getTime()) / oneDay);
var dayIndex = (diffDays % 7);
var weekIndex = Math.floor((diffDays / 7) % 8);
var warmupLetter = "Z";
if (weekIndex < 8 && dayIndex < 4) {
warmupLetter = warmupWeekDayMap[weekIndex][dayIndex];
}
return warmupLetter;
}
function getNextWarmUpInfoFromDate(seedDate, inc) {
var letter = "Z";
var letterDate = new Date(seedDate.getTime());
if (inc == 0) inc = 1; // stack overflow prevention
while (letter == "Z") {
letter = getWarmupLetterFromDate(letterDate);
if (letter == "Z") letterDate.setDate(letterDate.getDate() + 1 * inc);
}
var dayDiff = Math.round((letterDate.getTime() - today().getTime()) / oneDay);
var dayLabel = "Today";
if (dayDiff == 1) {
dayLabel = "Tomorrow";
} else if (dayDiff == -1) {
dayLabel = "Yesterday";
} else if (dayDiff > 1) {
dayLabel = dayDiff + " Days";
} else if (dayDiff < -1) {
dayLabel = Math.abs(dayDiff) + " Days ago";
}
var warmupMapIndex = letter.charCodeAt(0) - 65; // assuming caps, 0 based index on UTF-16
return {
letter: letter,
warmupDate: letterDate,
headingLabel: "Warmup " + letter + ": " + warmupMap[warmupMapIndex][0] + " - " + dayLabel + " (" + letterDate.toString().substring(0, 10) + ")",
youtubeUrl: "https://www.youtube.com/embed/" + warmupMap[warmupMapIndex][1]
};
}
function updatePrevNextLinks(linkId, seedDate, inc) {
var url = document.location.href;
var linkDate = new Date(seedDate.getTime());
linkDate.setDate(linkDate.getDate() + 1 * inc);
if (url.indexOf('d=') >= 0) {
url = url.replace(/(d=)[^\&]+/, '$1' + formatDate(linkDate));
} else if (url.indexOf('?') > 0) {
url += '&d=' + formatDate(linkDate);
} else {
url += "?d=" + formatDate(linkDate);
}
document.getElementById(linkId).href = url;
}
function init() {
var seedDate = getSeedDate();
document.getElementById('seedDateContent').innerHTML = seedDate.toString().substring(0, 10);
updatePrevNextLinks('prevLink', seedDate, -1);
updatePrevNextLinks('nextLink', seedDate, 1);
var nextWarmupInfo = getNextWarmUpInfoFromDate(seedDate, 1);
var upcommingDate = new Date(nextWarmupInfo.warmupDate.getTime());
upcommingDate.setDate(upcommingDate.getDate() + 1);
var upcommingWarmupInfo = getNextWarmUpInfoFromDate(upcommingDate, 1);
var previousDate = new Date(seedDate.getTime());
previousDate.setDate(previousDate.getDate() - 1);
var previousWarmUpInfo = getNextWarmUpInfoFromDate(previousDate, -1);
document.getElementById('nextContent').innerHTML = "Current: " + nextWarmupInfo.headingLabel;
document.getElementById('nextVideo').src = nextWarmupInfo.youtubeUrl;
document.getElementById('upcommingContent').innerHTML = "Up Next: " + upcommingWarmupInfo.headingLabel;
document.getElementById('upcommingVideo').src = upcommingWarmupInfo.youtubeUrl;
document.getElementById('previousContent').innerHTML = "Previous: " + previousWarmUpInfo.headingLabel;
document.getElementById('previousVideo').src = previousWarmUpInfo.youtubeUrl;
}
function getSeedDate() {
var q = getParameterByName('d');
if (q != null) {
return new Date(q);
} else {
return today();
}
}
function runTest() {
for (i = 0; i < 50; i++) {
var theDate = today();
theDate.setDate(theDate.getDate() + i * -1);
document.write("<br>Date: " + theDate + "<br>");
document.write(" " + getNextWarmUpInfoFromDate(theDate, -1).letter);
}
}
</script>
<style>
.content {
display: block;
width: 100%;
font-size: x-large;
}
.header {
text-align: center;
margin-bottom: 25px;
}
.videowrapper {
float: none;
clear: both;
width: 90%;
position: relative;
padding-bottom: 56.25%;
padding-top: 25px;
margin-bottom: 25px;
margin-top: 5px;
height: 0;
}
.videowrapper iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body onload="init()">
<div id="content" class="content">
<div class="header">
<a id="prevLink"><<</a> Warmups for <span id="seedDateContent"></span> <a id="nextLink">>></a>
</div>
<span id="nextContent"></span>
<div class="videowrapper">
<iframe id="nextVideo" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
<span id="upcommingContent"></span>
<div class="videowrapper">
<iframe id="upcommingVideo" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
<span id="previousContent"></span>
<div class="videowrapper">
<iframe id="previousVideo" width="560" height="315" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</body>
</html>