Skip to content

Commit

Permalink
[#166185730] add support for drop-sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Manorlds-Eaglespark committed Jun 20, 2019
1 parent 7760822 commit b6b7b1f
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"dependencies": {
"bower": "^1.8.8"
}
}
}
2 changes: 1 addition & 1 deletion wger/manager/migrations/0009_merge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2019-06-20 09:31
# Generated by Django 1.9 on 2019-06-18 12:58
from __future__ import unicode_literals

from django.db import migrations
Expand Down
89 changes: 87 additions & 2 deletions wger/manager/templates/set/formset.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
{% load wger_extras %}
{% load i18n %}

<div class="form-group">
<label class="col-md-3 control-label">
Drop sets
</label>
<div class=" col-md-9">
<span class="help-block">
This technique is performed when using dead weights. Once you reach failure with a certain dumbbell weight,
pick up a lighter weight off the rack and continue down the rack until
failure.
<br><br>
<b>Rule</b> : 1st set should be heaviest. No rest in between drops sets. "Walk down the rack" selecting weights.
<br><br>
<b>Instructions</b> : Input only the initial weight and number of reps per set.
</span>
</div>
</div>


<div class="form-group">
<label class="col-md-3 control-label">
</label>
<div class=" col-md-9">
<span class="help-block">
<div class="col-xs-3 " id="col-xs-3">
<input type="number" id="button-type1" onchange="saveReps()" class="form-control"
placeholder="Reps">
</div>
<div class="col-xs-4 " id="col-xs-4">
<input type="number" id="button-type2" onchange="saveWeight()" class="form-control"
placeholder="Weight">
</div>
<a class="btn btn-primary" onclick="getDropsets()">Calculate Drop sets</a>
</span>
</div>
</div>


</div>
</div>



<div id="formset-exercise-{{exercise.id}}" style="margin-top: 1em;">
<div class="row">
<div class="col-md-offset-2 col-md-10">
Expand All @@ -9,7 +52,6 @@
</div>
</div>
{{ formset.management_form }}

{% for field in formset %}
<div style="padding-top: 0.5em;">

Expand All @@ -34,7 +76,7 @@
{% endif %}
{% endfor %}
</div>

{# Form field rows #}
<div class="row">
{% for i in field %}
Expand Down Expand Up @@ -71,3 +113,46 @@
</div>
{% endfor %}
</div>


<script>
var noSets = document.getElementById('id_sets').value;
var value = '';
var noReps = '';
var id = document.querySelectorAll('input.form-control')[4].id;
var exerciseNo = id.replace(/^\D+|\D.*$/g, '');
var repsId = '';
var weightId = '';
var repClass = '';
var weightClass = '';
var i = null;
function getDropsets() {
if (noReps && value) {
for (i = 0; i <= noSets; i++) {
repsId = 'id_exercise' + exerciseNo + '-' + i + '-reps';
weightId = 'id_exercise' + exerciseNo + '-' + i + '-weight';
document.getElementById(weightId).value = parseFloat(value).toFixed(0);
document.getElementById(repsId).value = noReps;
value -= value * 0.3;
}
}
}
function saveReps() {
noReps = document.getElementById('button-type1').value;
if (noReps < 1) {
repClass = 'col-xs-3 has-error';
} else {
repClass = 'col-xs-3';
}
document.getElementById('col-xs-3').className = repClass;
}
function saveWeight() {
value = document.getElementById('button-type2').value;
if (value < 30) {
weightClass = 'col-xs-4 has-error';
} else {
weightClass = 'col-xs-4';
}
document.getElementById('col-xs-4').className = weightClass;
}
</script>
21 changes: 21 additions & 0 deletions wger/nutrition/migrations/0003_auto_20190618_1549.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2019-06-18 12:49
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('nutrition', '0002_auto_20190612_1819'),
]

operations = [
migrations.AlterField(
model_name='ingredient',
name='language',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Language', verbose_name='Language'),
),
]

0 comments on commit b6b7b1f

Please sign in to comment.