Skip to content

Commit

Permalink
Merge 4cad1f2 into 7d2c0e8
Browse files Browse the repository at this point in the history
  • Loading branch information
misocho committed Jun 19, 2019
2 parents 7d2c0e8 + 4cad1f2 commit ea574bd
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
40 changes: 40 additions & 0 deletions wger/core/static/js/wger-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,46 @@ function wgerInitEditSet() {
updateAllExerciseFormset();
$('#id_sets_value').html($('#id_sets').val());
});
$('#checkbox-id').click(function () {
var dropsetForm = $('.dropset-items');
// eslint-disable-next-line no-unused-expressions
$('#dropset-checkbox')[0].checked ? dropsetForm.css({ display: 'block' }) :
dropsetForm.css({ display: 'none' });
});

$('#calculate-dropset').click(function () {
var i;
var repId;
var weightId;
var weightUnitId;
var repUnitId;
var id = $('input.form-control')[6].id;
var exerciseNo = id.replace(/^\D+|\D.*$/g, '');
var sets = $('#id_sets').val();
var weight = $('#dropset-weight').val();
var weightUnit = $('#dropset-weight-unit').val();
var percentageDrop = $('#percentage-drop').val();
var repPercentage = $('#rep-percentage-drop').val();
var repUnit = $('#rep-dropset-unit').val();
var startRep = $('#rep-dropset-weight').val();

if (sets) {
for (i = 0; i <= sets; i+=1) {
startRep = parseFloat(startRep);
weight = parseFloat(weight);
repId = 'id_exercise' + exerciseNo + '-' + i + '-reps';
repUnitId = 'id_exercise' + exerciseNo + '-' + i + '-repetition_unit';
weightId = 'id_exercise' + exerciseNo + '-' + i + '-weight';
weightUnitId = 'id_exercise' + exerciseNo + '-' + i + '-weight_unit';
$('#' + repId)[0].value = startRep.toFixed(0);
$('#' + weightId)[0].value = weight.toFixed(0);
$('#' + repUnitId).val(repUnit);
$('#' + weightUnitId).val(weightUnit);
startRep += startRep * (parseFloat(repPercentage) / 100);
weight -= weight * (parseFloat(percentageDrop) / 100);
}
}
});

/*
* Mobile version only
Expand Down
106 changes: 106 additions & 0 deletions wger/manager/templates/set/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,113 @@
you can just enter one value: e.g. for 4 sets just enter one "10" for the repetitions, this
automatically becomes "4 x 10".{% endblocktrans %}</span>
</div>

</div>

<div class="form-group" id="dropset_form">
<div class="col-md-3 control-label">
<label >
{% trans "Drop Set:" %}
</label>
<div id="checkbox-id">
<input name="dropset-checkbox"
id="dropset-checkbox"
type="checkbox"
>
</div>
</div>
<span class="help-block col-md-9">{% blocktrans %}Drop sets are essentially a technique where you perform an exercise and then drop (reduce) the weight and continue for more reps until you reach failure.{% endblocktrans %}</span>
<div class="col-md-9 dropset-items" style="display: none; float: right">
<div>
<div class="col-md-12" class="row" style="padding: 10px">
<div class="col-md-4">
<label for="percentage-drop">
Weight drop %
</label>
<input name="percentagedrop"
id="percentage-drop"
type="number"
class="form-control"
>
</div>
<div class="col-md-4">
<label for="dropset-weight">
Weight - <span style="color: #737373"> to start with</span>
</label>

<input name="dropset-weight"
id="dropset-weight"
type="number"
class="form-control"
>
</div>
<div class="col-md-4">
<label for="dropset-weight">
Unit - <span style="color: #737373"> the weight unit</span>
</label>
<select name="dropsetwight-unit" class="form-control" id="dropset-weight-unit">

<option value="4">Plates</option>

<option value="1" selected="">kg</option>

<option value="2">lb</option>

</select>
</div>
</div>
<div class="col-md-12" class="row" style="padding: 10px">
<div class="col-md-4">
<label for="rep-percentage-drop">
Repetition rise %
</label>
<input name="rep-percentagedrop"
id="rep-percentage-drop"
type="number"
class="form-control"
>
</div>
<div class="col-md-4">
<label for="rep-dropset-weight">
Reps - <span style="color: #737373"> no. of reps</span>
</label>

<input name="dropset-weight"
id="rep-dropset-weight"
type="number"
class="form-control"
>
</div>
<div class="col-md-4">
<label for="rep-dropset-unit">
Unit - <span style="color: #737373">of repetitions</span>
</label>
<select name="rep_unit" class="form-control" id="rep-dropset-unit">
<option value="6">Kilometers</option>

<option value="5">Miles</option>

<option value="4">Minutes</option>

<option value="1" selected>Repetitions</option>

<option value="3">Seconds</option>

</select>
</div>
</div>
<div class="col-md-12" style="padding: 10px">
<input name="calculate_dropset"
id="calculate-dropset"
value="Calculate Dropsets"
type="button"
class="btn btn-default"
>
</div>
</div>
</div>
</div>

<div class="form-group">
<div class="col-md-12">
<div id="formsets">
Expand Down

0 comments on commit ea574bd

Please sign in to comment.