forked from nmunson/warmup-reps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
528 lines (439 loc) · 17.2 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sugapablo/Barbell Warm-Ups/Sets</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<link rel="apple-touch-icon" href="images/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png" />
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="scripts/jquery.cookie.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<style type="text/css">
/* issue 1259, pull request https://github.com/jquery/jquery-mobile/pull/2533 */
.ui-footer, .ui-page-fullscreen .ui-header, .ui-page-fullscreen .ui-footer {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
</style>
<script type="text/javascript">
var warmupApp = {
"metric" : false,
barWeight : function() {
if ($.cookie('bar_type') == 'bar-type-standard')
return warmupApp.metric ? 10 : 20;
else if ($.cookie('bar_type') == 'bar-type-technique')
return warmupApp.metric ? 7.5 : 15;
else if ($.cookie('bar_type') == 'bar-type-womens')
return warmupApp.metric ? 15 : 35;
else
return warmupApp.metric ? 20 : 45;
},
stepSize : function() {
return warmupApp.metric ? 2.5 : 5;
},
weights : function() {
if (warmupApp.metric)
return [20, 15, 10, 5, 2.5, 1.25];
else
return [45, 25, 10, 5, 2.5];
},
"programs" : []
}
$(document).ready(function() {
location.hash = '';
$.ajax({
url: 'programs/5x5.json',
dataType: 'json',
success: function(data) {
warmupApp.programs.push(data);
},
async: false
});
$.ajax({
url: 'programs/max_single.json',
dataType: 'json',
success: function(data) {
warmupApp.programs.push(data);
},
async: false
});
$.ajax({
url: 'programs/prilepin.json',
dataType: 'json',
success: function(data) {
warmupApp.programs.push(data);
},
async: false
});
$.ajax({
url: 'programs/starting_strength.json',
dataType: 'json',
success: function(data) {
warmupApp.programs.push(data);
},
async: false
});
$.ajax({
url: 'programs/westside_de.json',
dataType: 'json',
success: function(data) {
warmupApp.programs.push(data);
},
async: false
});
if ($.cookie("units") == "units-kilograms")
warmupApp.metric = true;
$("input[name='units']").change(function() {
$.cookie('units', $(this).attr('id'), { expires: 365 });
warmupApp.metric = !warmupApp.metric;
$('input').attr('min', warmupApp.barWeight().toString());
$(":input[min]").each(function() {
var currentMax = $(this).attr('max');
if (warmupApp.metric)
$(this).attr('max', roundDown(Math.floor(currentMax * 0.45359)));
else
$(this).attr('max', roundDown(Math.floor(currentMax * 2.20462)));
});
//trigger update for all lists, currently shows lbs until slider is changed
$('div').filter(function() {
return this.id.match(/-weight-container/);
}).trigger('change');
});
$("input[name='bar-type']").change(function() {
$.cookie('bar_type', $(this).attr('id'), { expires: 365 });
$('input').attr('min', warmupApp.barWeight().toString());
$('div').filter(function() {
return this.id.match(/-weight-container/);
}).trigger('change');
});
for (i = 0; i < warmupApp.programs.length; i++) {
var shortTitle = warmupApp.programs[i].title.toLowerCase().replace(/ /g, '-');
// generate homepage links
$('#programs').append('<p><a href="#' + shortTitle +
'" data-role="button" id="' + shortTitle +
'-link">' + warmupApp.programs[i].title + '</a></p>');
//generate page for program
$('body').append('<div data-role="page" id="' + shortTitle + '"> \
<div data-role="header"><h1>Barbell Warm-Ups/Sets</h1> \
<a href="#main" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a></div> \
<div data-role="content"> \
<h2>' + warmupApp.programs[i].title + '</h2> \
<p>Choose an exercise from the program.</p> \
<h3>Choose an exercise:</h3><div id="' + shortTitle + '-exercises"></div> \
<hr /><p><a href="#main" data-direction="reverse" data-role="button">Choose another program</a></p></div> \
<div data-role="footer" class="ui-bar" data-theme="d"><h4 style="display: inline-block; margin-left: 0px; margin-right: 10px">Related:</h4> \
<a href="#credits" data-rel="dialog" data-transition="slidedown">Credits</a> \
<a href="https://github.com/nmunson/warmup-reps" data-role="button" data-inline="true">Github</a> \
<a href="https://github.com/nmunson/warmup-reps/issues" data-role="button" data-inline="true">Issues</a></div></div>');
//add exercises
for (j = 0; j < warmupApp.programs[i].exercises.length; j++) {
shortExerciseName = warmupApp.programs[i].exercises[j].name.toLowerCase().replace(/ /g, '-');
$('#' + shortTitle + '-exercises').append(
'<p><a href="#' + shortTitle + "-" + shortExerciseName + '" data-role="button" id="' +
shortExerciseName + '-link">' + warmupApp.programs[i].exercises[j].name + '</a></p>');
if ($.cookie(shortExerciseName) != undefined)
var currentWeight = $.cookie(shortExerciseName);
else
var currentWeight = "100";
//generate page for each exercise
$('body').append('<div data-role="page" id="' + shortTitle + "-" + shortExerciseName + '"> \
<div data-role="header"><h1>Barbell Warm-Ups/Sets</h1> \
<a href="#main" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a></div> \
<div data-role="content"><h2>' + warmupApp.programs[i].exercises[j].name + '</h2> \
<p>Choose your working weight. Your warmup sets will then be calculated as well as the weights you need to put on each bar side.</p> \
<div id="' + shortTitle + "-" + shortExerciseName + '-weight-container"><label for="' + shortTitle + "-" + shortExerciseName + '-weight">Weight:</label> \
<input type="range" name="' + shortTitle + "-" + shortExerciseName + '-weight" id="' + shortTitle + "-" + shortExerciseName + '-weight" value="' + currentWeight + '" min="45" max="' + warmupApp.programs[i].exercises[j].max + '" step="5" /> \
</div><ul data-role="listview" data-inset="true" id="' + shortTitle + "-" + shortExerciseName + '-warmup"></ul> \
<p><a href="#' + shortTitle + '" data-direction="reverse" data-role="button">Choose another exercise</a></p> \
</div><div data-role="footer" class="ui-bar" data-theme="d"><h4 style="display: inline-block; margin-left: 0px; margin-right: 10px">Related:</h4> \
<a href="#credits" data-rel="dialog" data-transition="slidedown">Credits</a> \
<a href="https://github.com/nmunson/warmup-reps" data-role="button" data-inline="true">Github</a> \
<a href="https://github.com/nmunson/warmup-reps/issues" data-role="button" data-inline="true">Issues</a> \
</div></div>');
$('#' + shortTitle + "-" + shortExerciseName + '-warmup')
.data('workouts', warmupApp.programs[i].exercises[j]);
$('.ui-slider').live('mouseup', function() {
updateWorkout($(this).parent().siblings('ul'), $(this).siblings('input').val());
});
$('.ui-slider').live('touchend', function() {
updateWorkout($(this).parent().siblings('ul'), $(this).siblings('input').val());
});
$('#' + shortTitle + "-" + shortExerciseName + '-weight').live('blur', function() {
updateWorkout($(this).parent().siblings('ul'), $(this).val());
})
var volume = 0;
var chain_volume = 0;
var output = '';
//add each set
for (k = 0; k < warmupApp.programs[i].exercises[j].workouts.length; k++) {
var workout = warmupApp.programs[i].exercises[j].workouts[k];
if(workout.multiplier == -1) {
output = '<li style="color: #fff;background-image: linear-gradient(#666,#333);">' + workout.name + '</li>';
}
else if(workout.chains == 1) {
var setWeight = findWeight(workout, $('#' + shortTitle + '-' + shortExerciseName + '-weight').val());
chain_volume += setWeight;
}
else {
var setWeight = findWeight(workout, $('#' + shortTitle + '-' + shortExerciseName + '-weight').val());
volume = volume + getVolume(workout.sets,workout.reps,setWeight);
output = '<li>' + printSet(workout.sets, workout.reps, setWeight) + ' (' + calculateBarbellWeights(setWeight) + ')';
if(chain_volume) {
output += ' + up to ' + chain_volume + ' in chains.';
}
if((workout.multiplier == 1 && (workout.sets > 1 || workout.reps > 1)) || workout.workset == 1 ) {
output += ' · Volume: ' + getVolume(workout.sets, workout.reps, setWeight + chain_volume, 1);
}
output += '</li>'
}
$('#' + shortTitle + "-" + shortExerciseName + '-warmup').append(output);
}
//$('#' + shortTitle + "-" + shortExerciseName + '-warmup').append('<li>Total Volume: ' + getSystem(volume) + ' kg</li>');
}
}
initializePreferences();
$('#main').page("destroy").page();
});
function getSystem(str) {
if(warmupApp.metric)
str += " kg";
else
str += " lbs";
return str;
}
function getVolume(sets,reps,weight,display = 0) {
var volume = sets * reps * weight;
if(display)
volume = getSystem(volume);
return volume;
}
function initializePreferences() {
if ($.cookie('bar_type') != undefined) {
$('input[name="bar-type"]').prop("checked", false);
try {
$('input[id="' + $.cookie('bar_type') + '"]').prop("checked", true).checkboxradio("refresh");
}
catch (err) {
console.log(err);
}
$('input').attr('min', warmupApp.barWeight().toString());
}
else {
try {
$('input[id="bar-type-olympic"]').prop("checked", true).checkboxradio("refresh");
}
catch (err) {
console.log(err);
}
}
if ($.cookie('units') != undefined) {
$('input[name="units"]').prop("checked", false);
try {
$('input[id="' + $.cookie('units') + '"]').prop("checked", true).checkboxradio("refresh");
}
catch (err) {
console.log(err);
}
$('input').attr('step', warmupApp.stepSize().toString());
}
else {
try {
$('input[id="units-pounds"]').prop("checked", true).checkboxradio("refresh");
}
catch (err) {
console.log(err);
}
}
}
function updateWorkout(list, weight) {
var workouts = [];
$.cookie(list.data('workouts').name.toLowerCase().replace(/ /g, '-'), weight, { expires: 30 });
for (i = 0; i < list.data('workouts').workouts.length; i++) {
workouts.push(list.data('workouts').workouts[i]);
}
list.empty();
var volume = 0;
var chain_volume = 0
var output = '';
for (i = 0; i < workouts.length; i++) {
var workout = workouts[i];
if(workout.multiplier == -1) {
output = '<li style="color: #fff;background-image: linear-gradient(#666,#333);">' + workout.name + '</li>';
}
else if(workout.chains == 1) {
var setWeight = findWeight(workout, weight);
chain_volume += setWeight;
}
else {
var setWeight = findWeight(workout, weight);
volume = volume + getVolume(workout.sets,workout.reps,setWeight);
output = '<li>' + printSet(workout.sets, workout.reps, setWeight) + ' (' + calculateBarbellWeights(setWeight) + ')';
if(chain_volume) {
output += ' + up to ' + chain_volume + ' in chains.';
}
if((workout.multiplier == 1 && (workout.sets > 1 || workout.reps > 1)) || workout.workset == 1 ) {
output += ' · Volume: ' + getVolume(workout.sets, workout.reps, setWeight + chain_volume, 1);
}
output += '</li>'
}
list.append(output);
}
//list.append('<li>Total Volume: ' + getSystem(volume) + '</li>');
try
{
list.listview('refresh');
}
catch(err)
{
// can't refresh view if not initialized already, that is fine.
console.log(err);
}
}
function calculateBarbellWeights(weight) {
weight -= warmupApp.barWeight();
if (weight === 0)
return "Bar";
weight /= 2;
var weight_45 = 0;
var weight_35 = 0;
var weight_25 = 0;
var weight_10 = 0;
var weight_5 = 0;
var weight_2half = 0;
while (weight > 0) {
if (weight >= warmupApp.weights()[0]) {
weight_45 += 1;
weight -= warmupApp.weights()[0];
continue;
}
else if (weight >= warmupApp.weights()[1]) {
weight_35 += 1;
weight -= warmupApp.weights()[1];
continue;
}
else if (weight >= warmupApp.weights()[2]) {
weight_25 += 1;
weight -= warmupApp.weights()[2];
continue;
}
else if (weight >= warmupApp.weights()[3]) {
weight_10 += 1;
weight -= warmupApp.weights()[3];
continue;
}
else if (weight >= warmupApp.weights()[4]) {
weight_5 += 1;
weight -= warmupApp.weights()[4];
continue;
}
else {
weight_2half += 1;
weight -= warmupApp.weights()[5];
continue;
}
}
var result = "";
if (weight_45 != 0)
result += printWeightCountSubstring(weight_45, warmupApp.weights()[0].toString());
if (weight_35 != 0)
result += printWeightCountSubstring(weight_35, warmupApp.weights()[1].toString());
if (weight_25 != 0)
result += printWeightCountSubstring(weight_25, warmupApp.weights()[2].toString());
if (weight_10 != 0)
result += printWeightCountSubstring(weight_10, warmupApp.weights()[3].toString());
if (weight_5 != 0)
result += printWeightCountSubstring(weight_5, warmupApp.weights()[4].toString());
if (weight_2half != 0)
result += printWeightCountSubstring(weight_2half, warmupApp.weights()[5].toString());
return $.trim(result);
}
function printWeightCountSubstring(weight, text) {
if (weight > 1)
return weight + "x" + text + " ";
else
return text + " ";
}
function findWeight(exercise, weight) {
if (exercise.multiplier != undefined && exercise.minimum > 1 && roundDown(exercise.multiplier * weight) < exercise.minimum)
return exercise.minimum;
else if (exercise.multiplier != undefined )
return roundDown(exercise.multiplier * weight);
else
return exercise.weight;
}
function printSet(sets, reps, weight) {
var output = sets + "x" + reps + " " + weight;
if (warmupApp.metric)
return output + " kgs"
else
return output + " lbs"
}
function roundDown(num) {
if (num - (num % warmupApp.stepSize()) < warmupApp.barWeight())
return warmupApp.barWeight();
else
return num - (num % warmupApp.stepSize());
}
</script>
</head>
<body>
<div data-role="page" id="main">
<div data-role="header">
<h1>Barbell Warm-Ups/Sets</h1>
</div>
<div data-role="content" >
<h2>Getting Started</h2>
<p>Choose a program, exercise, and then set your target weight. Your warmup sets will then be automatically
calculated.</p>
<h3>Choose a program:</h3>
<div id="programs">
</div>
<hr />
<h3>Settings</h3>
<div data-role="collapsible" data-content-theme="c">
<h3>Configure units and bar type</h3>
<fieldset data-role="controlgroup" data-type="horizontal" >
<legend>Unit system:</legend>
<input type="radio" name="units" id="units-pounds" value="lbs" />
<label for="units-pounds">Pounds</label>
<input type="radio" name="units" id="units-kilograms" value="kgs" />
<label for="units-kilograms">Kilograms</label>
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal" >
<legend>Bar type (in lbs):</legend>
<input type="radio" name="bar-type" id="bar-type-olympic" value="45" />
<label for="bar-type-olympic">Olympic (45)</label>
<input type="radio" name="bar-type" id="bar-type-womens" value="35" />
<label for="bar-type-womens">Womens (35)</label>
<input type="radio" name="bar-type" id="bar-type-standard" value="20" />
<label for="bar-type-standard">Standard (20)</label>
<input type="radio" name="bar-type" id="bar-type-technique" value="15" />
<label for="bar-type-technique">Technique (15)</label>
</fieldset>
</div>
</div>
<div data-role="footer" class="ui-bar" data-theme="d">
<h4 style="display: inline-block; margin-left: 0px; margin-right: 10px">Related:</h4>
<a href="#credits" data-rel="dialog" data-transition="slidedown">Credits</a>
<a href="https://github.com/nmunson/warmup-reps" data-role="button" data-inline="true">Github</a>
<a href="https://github.com/nmunson/warmup-reps/issues" data-role="button" data-inline="true">Issues</a>
</div>
</div>
<div data-role="page" id="credits">
<div data-role="header">
<h1 data>Credits</h1>
</div>
<div data-role="content">
<p>Written and maintained by Nicholas Munson © 2012.</p>
<p>Additions/customizations added by Russ Schneider © 2022</p>
<p>"Weight Lifting" symbol by Scott Lewis, from thenounproject.com collection.</p>
<a data-rel="back" data-role="button">Close</a>
</div>
</div>
</body>
</html>