diff options
| author | FivePixels <o5pxels@gmail.com> | 2022-04-23 17:48:40 -0500 |
|---|---|---|
| committer | FivePixels <o5pxels@gmail.com> | 2022-04-23 17:56:17 -0500 |
| commit | eff104b1e2840ad40131e7ab811448a34a896f9f (patch) | |
| tree | 44e9acd48fcf8995e6f6cde5a87ca476dff180a9 | |
| parent | ceb76e7b1d75623b09a9c85a3e48752404a9077d (diff) | |
| download | Strengthy-eff104b1e2840ad40131e7ab811448a34a896f9f.tar.xz Strengthy-eff104b1e2840ad40131e7ab811448a34a896f9f.zip | |
Begin logic on record.js for enter to tab handling, remove skip exercise
button from record page. Add info about workout in card on select page,
update edit to use units if they exist on an existing workout
| -rw-r--r-- | app/static/js/record.js | 31 | ||||
| -rw-r--r-- | app/templates/workout/record.html | 1 | ||||
| -rw-r--r-- | app/templates/workout/select.html | 21 |
3 files changed, 34 insertions, 19 deletions
diff --git a/app/static/js/record.js b/app/static/js/record.js index aba6785..67ad2a6 100644 --- a/app/static/js/record.js +++ b/app/static/js/record.js @@ -1,13 +1,26 @@ - // Register 'Enter' listeners on all inputs -Array.from(document.getElementsByClassName('input')) - .filter(e => e.type == 'number') - .forEach(e => e.addEventListener('keyup', function(event) { - if (event.key == 'Enter') { - // TODO implement - console.log("ENTER") - } - })) +allInputs = Array.from(document.getElementsByClassName('input')) + .filter(e => e.type == 'number'); +allInputs.forEach(e => e.addEventListener('keypress', handleEnterKey)); + +function handleEnterKey(event) { + + // add ids to each input programatically + + if (event.key = 'Enter') { + event.preventDefault(); + + //Isolate the node that we're after + const currentNode = event.target; + + //Find the current tab index. + currentIndex = [...allInputs].findIndex(el => currentNode.isEqualNode(el)) + + //focus the following element + const targetIndex = (currentIndex + 1) % allInputs.length; + allInputs[targetIndex].focus();} + +} function setReset(row, values=true) { let lbsInput = row.children[1].children[0]; diff --git a/app/templates/workout/record.html b/app/templates/workout/record.html index 94fe611..d1662e3 100644 --- a/app/templates/workout/record.html +++ b/app/templates/workout/record.html @@ -37,7 +37,6 @@ </span> <span>Add Set</span> </a> - <a class="button is-danger">Skip</a> </div> <hr> </div> diff --git a/app/templates/workout/select.html b/app/templates/workout/select.html index c01a4f8..7109c70 100644 --- a/app/templates/workout/select.html +++ b/app/templates/workout/select.html @@ -4,18 +4,21 @@ <div class="continer"> <div class="columns is-centered"> {% for workout in current_user.workouts %} - <div class="column"> - <div class="card"> - <header class="card-header"> - <p class="card-header-title"> {{ workout.name }}</p> - </header> - <div class="card-content"> - <div class="content"> - <a class="button" href="/workout/record?id={{ workout.id }}">Start</a> - </div> + <div class="column"> + <div class="card"> + <header class="card-header"> + <p class="card-header-title"> {{ workout.name }}</p> + </header> + <div class="card-content"> + <div class="content"> + {% for exercise in workout.exercises %} + <p>{{ exercise.sets }} x {{ exercise.units }} x {{ exercise.name }}</p> + {% endfor %} + <a class="button" href="/workout/record?id={{ workout.id }}">Start</a> </div> </div> </div> + </div> {% endfor %} </div> </div> |
