modify dropdown menu
This commit is contained in:
parent
efa7761f20
commit
cbf7dfcef6
63
main.go
63
main.go
|
|
@ -145,7 +145,15 @@ func handleAddSet(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
exercise := r.FormValue("exercise")
|
// NEW: exercise from dropdown + optional custom
|
||||||
|
selected := r.FormValue("exercise_select")
|
||||||
|
exerciseCustom := r.FormValue("exercise_custom")
|
||||||
|
|
||||||
|
exercise := selected
|
||||||
|
if selected == "custom" {
|
||||||
|
exercise = exerciseCustom
|
||||||
|
}
|
||||||
|
|
||||||
repsStr := r.FormValue("reps")
|
repsStr := r.FormValue("reps")
|
||||||
weightStr := r.FormValue("weight")
|
weightStr := r.FormValue("weight")
|
||||||
|
|
||||||
|
|
@ -464,11 +472,23 @@ const indexHTML = `
|
||||||
grid-template-columns: 1.1fr 0.9fr;
|
grid-template-columns: 1.1fr 0.9fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.flex-row {
|
||||||
|
display:flex;
|
||||||
|
gap:0.5rem;
|
||||||
|
align-items:center;
|
||||||
|
}
|
||||||
|
.flex-row input[type="text"] {
|
||||||
|
flex:1;
|
||||||
|
}
|
||||||
|
.small {
|
||||||
|
font-size:0.8rem;
|
||||||
|
color:#9ca3af;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Minimal Fitness Tracker</h1>
|
<h1>Minimal Fitness Tracker</h1>
|
||||||
<p style="color:#9ca3af;">Simple self-hosted Go app – log sets, see rest times and training volume.</p>
|
<p style="color:#9ca3af;">Simple self-hosted Go app – 5×5 friendly: pick standard lifts, track volume and rest.</p>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -490,9 +510,28 @@ const indexHTML = `
|
||||||
{{if .HasWorkout}}
|
{{if .HasWorkout}}
|
||||||
<form method="POST" action="/add-set">
|
<form method="POST" action="/add-set">
|
||||||
<label>
|
<label>
|
||||||
Exercise
|
Exercise (5×5 core lifts & friends)
|
||||||
<input type="text" name="exercise" placeholder="Squat" required>
|
<select name="exercise_select" id="exercise_select" required onchange="toggleCustomExercise()">
|
||||||
|
<option value="Squat">Squat</option>
|
||||||
|
<option value="Bench Press">Bench Press</option>
|
||||||
|
<option value="Barbell Row">Barbell Row</option>
|
||||||
|
<option value="Overhead Press">Overhead Press</option>
|
||||||
|
<option value="Deadlift">Deadlift</option>
|
||||||
|
<option value="Pull-up">Pull-up</option>
|
||||||
|
<option value="Chin-up">Chin-up</option>
|
||||||
|
<option value="Dip">Dip</option>
|
||||||
|
<option value="Barbell Curl">Barbell Curl</option>
|
||||||
|
<option value="Tricep Extension">Tricep Extension</option>
|
||||||
|
<option value="Face Pull">Face Pull</option>
|
||||||
|
<option value="Lat Pulldown">Lat Pulldown</option>
|
||||||
|
<option value="custom">Custom…</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
<div class="flex-row small" id="customExerciseRow" style="margin-top:0.4rem; display:none;">
|
||||||
|
<span>Custom name:</span>
|
||||||
|
<input type="text" name="exercise_custom" id="exercise_custom" placeholder="Front Squat, Incline Bench…">
|
||||||
|
</div>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
Reps
|
Reps
|
||||||
<input type="number" name="reps" min="1" step="1" required>
|
<input type="number" name="reps" min="1" step="1" required>
|
||||||
|
|
@ -566,6 +605,21 @@ const indexHTML = `
|
||||||
let restChartInstance = null;
|
let restChartInstance = null;
|
||||||
let volumeChartInstance = null;
|
let volumeChartInstance = null;
|
||||||
|
|
||||||
|
function toggleCustomExercise() {
|
||||||
|
const select = document.getElementById('exercise_select');
|
||||||
|
const row = document.getElementById('customExerciseRow');
|
||||||
|
const input = document.getElementById('exercise_custom');
|
||||||
|
|
||||||
|
if (select.value === 'custom') {
|
||||||
|
row.style.display = 'flex';
|
||||||
|
input.required = true;
|
||||||
|
} else {
|
||||||
|
row.style.display = 'none';
|
||||||
|
input.required = false;
|
||||||
|
input.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadRestTimes() {
|
function loadRestTimes() {
|
||||||
fetch('/api/rest-times')
|
fetch('/api/rest-times')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|
@ -687,6 +741,7 @@ const indexHTML = `
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
toggleCustomExercise();
|
||||||
loadRestTimes();
|
loadRestTimes();
|
||||||
loadVolumeStats();
|
loadVolumeStats();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue