summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS2
-rw-r--r--app/static/js/create.js26
-rw-r--r--app/templates/workout/create.html10
3 files changed, 15 insertions, 23 deletions
diff --git a/BUGS b/BUGS
index 0fe296a..e69de29 100644
--- a/BUGS
+++ b/BUGS
@@ -1,2 +0,0 @@
-/workout/edit:
- Adding a workout to the edit page does not work
diff --git a/app/static/js/create.js b/app/static/js/create.js
index 0f63956..a9bf7ae 100644
--- a/app/static/js/create.js
+++ b/app/static/js/create.js
@@ -32,22 +32,16 @@ function handleDel(elem) {
}
}
-document.getElementById("add").onclick = handleAdd;
-
function handleChange(elem) {
- if (elem.target.value == 'time') {
- elem.target.parentNode.parentNode.parentNode.children[1].placeholder = "Time (in seconds)";
- elem.target.parentNode.parentNode.parentNode.children[1].selected = true;
- elem.target.parentNode.parentNode.children[1].children[0].classList.remove('fa-calculator');
- elem.target.parentNode.parentNode.children[1].children[0].classList.add('fa-clock-o');
- } else if (elem.target.value == 'reps') {
- elem.target.parentNode.parentNode.children[1].children[0].classList.add('fa-calculator');
- elem.target.parentNode.parentNode.children[1].children[0].classList.remove('fa-clock-o');
- elem.target.parentNode.parentNode.parentNode.children[1].selected = true;
- elem.target.parentNode.parentNode.parentNode.children[1].placeholder = "Reps";
+ if (elem.value == 'time') {
+ elem.parentNode.parentNode.parentNode.children[1].placeholder = "Time (in seconds)";
+ elem.parentNode.parentNode.parentNode.children[1].selected = true;
+ elem.parentNode.parentNode.children[1].children[0].classList.remove('fa-calculator');
+ elem.parentNode.parentNode.children[1].children[0].classList.add('fa-clock-o');
+ } else if (elem.value == 'reps') {
+ elem.parentNode.parentNode.children[1].children[0].classList.add('fa-calculator');
+ elem.parentNode.parentNode.children[1].children[0].classList.remove('fa-clock-o');
+ elem.parentNode.parentNode.parentNode.children[1].selected = true;
+ elem.parentNode.parentNode.parentNode.children[1].placeholder = "Reps";
}
}
-
-for (row of rowsDiv.children) {
- row.children[0].children[2].children[0].children[0].children[0].addEventListener('input', handleChange);
-}
diff --git a/app/templates/workout/create.html b/app/templates/workout/create.html
index 628ef74..569717a 100644
--- a/app/templates/workout/create.html
+++ b/app/templates/workout/create.html
@@ -24,9 +24,6 @@
<div id="rows" class="field">
{% for entry in form.exercises.entries %}
- {% if workout %}
- {{ entry['id']() }}
- {% endif %}
<div class="field is-horizontal">
<div class="field-body">
<div class="field">
@@ -53,13 +50,13 @@
<div class="field has-addons">
<div class="control has-icons-left">
<div class="select">
- {{ entry['type'] }}
+ {{ entry['type'](oninput='handleChange(this)') }}
</div>
<div class="icon is-small is-left">
<i class="fa fa-calculator"></i>
</div>
</div>
- {{ entry['units'](class_='input', placeholder="Reps") }}
+ {{ entry['units'](class_='input', placeholder='Reps') }}
</div>
<p class="button is-danger" onclick="handleDel(this)">
<span class="icon is-small">
@@ -68,6 +65,9 @@
</p>
</div>
</div>
+ {% if workout %}
+ {{ entry['id']() }}
+ {% endif %}
{% endfor %}
</div>