iphlex commited on
Commit
607f62e
·
verified ·
1 Parent(s): c46f13e

🐳 17/03 - 13:46 - the 性別 does not work

Browse files
Files changed (1) hide show
  1. script.js +44 -0
script.js CHANGED
@@ -155,6 +155,50 @@ const exerciseDB = {
155
  // Personal Info State
156
  let personalInfo = { gender: null, height: null, weight: null };
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  // Helper function to get exercise details based on muscle and difficulty
159
  function getExerciseDetails(muscle, difficulty) {
160
  // Core and Full Body use time-based format
 
155
  // Personal Info State
156
  let personalInfo = { gender: null, height: null, weight: null };
157
 
158
+ // Gender Selection
159
+ function selectGender(gender) {
160
+ personalInfo.gender = gender;
161
+
162
+ // Update UI
163
+ const maleBtn = document.getElementById('genderMale');
164
+ const femaleBtn = document.getElementById('genderFemale');
165
+
166
+ if (gender === 'male') {
167
+ maleBtn.classList.add('border-blue-500', 'bg-blue-500/20');
168
+ maleBtn.classList.remove('border-transparent');
169
+ femaleBtn.classList.remove('border-pink-500', 'bg-pink-500/20');
170
+ femaleBtn.classList.add('border-transparent');
171
+ } else {
172
+ femaleBtn.classList.add('border-pink-500', 'bg-pink-500/20');
173
+ femaleBtn.classList.remove('border-transparent');
174
+ maleBtn.classList.remove('border-blue-500', 'bg-blue-500/20');
175
+ maleBtn.classList.add('border-transparent');
176
+ }
177
+
178
+ updatePersonalInfo();
179
+ }
180
+
181
+ // Update Personal Info and Calculate Protein
182
+ function updatePersonalInfo() {
183
+ const heightInput = document.getElementById('heightInput');
184
+ const weightInput = document.getElementById('weightInput');
185
+ const proteinPreview = document.getElementById('proteinPreview');
186
+ const proteinAmount = document.getElementById('proteinAmount');
187
+
188
+ personalInfo.height = heightInput.value ? parseFloat(heightInput.value) : null;
189
+ personalInfo.weight = weightInput.value ? parseFloat(weightInput.value) : null;
190
+
191
+ // Calculate protein if weight is available
192
+ if (personalInfo.weight) {
193
+ const minProtein = Math.round(personalInfo.weight * 0.3);
194
+ const maxProtein = Math.round(personalInfo.weight * 0.4);
195
+ proteinAmount.textContent = `${minProtein}-${maxProtein} 克`;
196
+ proteinPreview.classList.remove('hidden');
197
+ } else {
198
+ proteinPreview.classList.add('hidden');
199
+ }
200
+ }
201
+
202
  // Helper function to get exercise details based on muscle and difficulty
203
  function getExerciseDetails(muscle, difficulty) {
204
  // Core and Full Body use time-based format