Skip to content

Commit 8ce2a1d

Browse files
test deploy
1 parent ac6af5d commit 8ce2a1d

File tree

3 files changed

+73
-72
lines changed

3 files changed

+73
-72
lines changed

public/home.js

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
1-
// $(document).ready(onPageLoadHome);
1+
$(document).ready(onPageLoadHome);
22

3-
// function onPageLoadHome() {
4-
// updateAuthenticatedUI();
3+
function onPageLoadHome() {
4+
updateAuthenticatedUI();
55

6-
// // if (STATE.authUser) {
7-
// // HTTP.getUserworkouts({
8-
// // jwtToken: STATE.authUser.jwtToken,
9-
// // onSuccess: console.log("User Authenticated")
10-
// // // RENDER.renderWorkoutsList
11-
// // });
12-
// // }
13-
// { /* <nav class="nav-login"><a id="logout-btn" href="">Log Out</a> </nav> */ }
6+
// if (STATE.authUser) {
7+
// HTTP.getUserworkouts({
8+
// jwtToken: STATE.authUser.jwtToken,
9+
// onSuccess: console.log("User Authenticated")
10+
// // RENDER.renderWorkoutsList
11+
// });
12+
// }
13+
{ /* <nav class="nav-login"><a id="logout-btn" href="">Log Out</a> </nav> */ }
1414

15-
// // $('#workout-list').on('click', '#delete-workout-btn', onDeleteWorkoutBtnClick);
16-
// // $('#workout-list').on('click', '#workout-card', onWorkoutCardClick);
17-
// }
15+
// $('#workout-list').on('click', '#delete-workout-btn', onDeleteWorkoutBtnClick);
16+
// $('#workout-list').on('click', '#workout-card', onWorkoutCardClick);
17+
}
1818

1919

20-
// function onLogoutBtnClick(event) {
21-
// event.preventDefault();
20+
function onLogoutBtnClick(event) {
21+
event.preventDefault();
2222

23-
// try {
24-
// CACHE.deleteAuthenticatedUserFromCache();
25-
// window.open('/index.html', '_self')
26-
// } catch {
27-
// console.error(error);
28-
// }
29-
// }
23+
try {
24+
CACHE.deleteAuthenticatedUserFromCache();
25+
window.open('/index.html', '_self')
26+
} catch {
27+
console.error(error);
28+
}
29+
}
3030

31-
// // Handle opening Workout details
32-
// function onWorkoutCardClick(event) {
33-
// const workoutId = $(event.currentTarget).attr('data-workout-id');
34-
// window.open(`Workout/details.html?id=${workoutId}`, '_self');
35-
// }
31+
// Handle opening Workout details
32+
function onWorkoutCardClick(event) {
33+
const workoutId = $(event.currentTarget).attr('data-workout-id');
34+
window.open(`Workout/details.html?id=${workoutId}`, '_self');
35+
}
3636

37-
// // Handle deleting Workouts
38-
// function onDeleteWorkoutBtnClick(event) {
39-
// /**
40-
// * Because "onWorkoutDeleteClick" and "onWorkoutClick" both are listening for clicks inside of
41-
// * #Workout-card element, we need to call event.stopImmediatePropagation to avoid both
42-
// * event listeners firing when we click on the delete button inside #Workout-card.
43-
// */
44-
// event.stopImmediatePropagation();
45-
// // Step 1: Get the Workout id to delete from it's parent.
46-
// const workoutId = $(event.currentTarget)
47-
// .closest('#workout-card')
48-
// .attr('data-workout-id');
49-
// // Step 2: Verify use is sure of deletion
50-
// const userSaidYes = confirm('Are you sure you want to delete this workout?');
51-
// if (userSaidYes) {
52-
// // Step 3: Make ajax call to delete workout
53-
// HTTP.deleteWorkout({
54-
// workoutId: workoutId,
55-
// jwtToken: STATE.authUser.jwtToken,
56-
// onSuccess: () => {
57-
// // Step 4: If succesful, reload the workouts list
58-
// alert('Workout deleted succesfully, reloading results ...');
59-
// HTTP.getUserWorkouts({
60-
// jwtToken: STATE.authUser.jwtToken,
61-
// onSuccess: RENDER.renderWorkoutsList
62-
// });
63-
// }
64-
// });
65-
// }
66-
// }
37+
// Handle deleting Workouts
38+
function onDeleteWorkoutBtnClick(event) {
39+
/**
40+
* Because "onWorkoutDeleteClick" and "onWorkoutClick" both are listening for clicks inside of
41+
* #Workout-card element, we need to call event.stopImmediatePropagation to avoid both
42+
* event listeners firing when we click on the delete button inside #Workout-card.
43+
*/
44+
event.stopImmediatePropagation();
45+
// Step 1: Get the Workout id to delete from it's parent.
46+
const workoutId = $(event.currentTarget)
47+
.closest('#workout-card')
48+
.attr('data-workout-id');
49+
// Step 2: Verify use is sure of deletion
50+
const userSaidYes = confirm('Are you sure you want to delete this workout?');
51+
if (userSaidYes) {
52+
// Step 3: Make ajax call to delete workout
53+
HTTP.deleteWorkout({
54+
workoutId: workoutId,
55+
jwtToken: STATE.authUser.jwtToken,
56+
onSuccess: () => {
57+
// Step 4: If succesful, reload the workouts list
58+
alert('Workout deleted succesfully, reloading results ...');
59+
HTTP.getUserWorkouts({
60+
jwtToken: STATE.authUser.jwtToken,
61+
onSuccess: RENDER.renderWorkoutsList
62+
});
63+
}
64+
});
65+
}
66+
}
6767

68-
// function updateAuthenticatedUI() {
69-
// const authUser = CACHE.getAuthenticatedUserFromCache();
70-
// if (authUser) {
71-
// STATE.authUser = authUser;
72-
// $('#nav-greeting').html(`Welcome, ${authUser.name}`);
73-
// $('#auth-menu').removeAttr('hidden');
74-
// } else {
75-
// $('#default-menu').removeAttr('hidden');
76-
// }
77-
// }
68+
function updateAuthenticatedUI() {
69+
const authUser = CACHE.getAuthenticatedUserFromCache();
70+
if (authUser) {
71+
STATE.authUser = authUser;
72+
$('#nav-greeting').html(`Welcome, ${authUser.name}`);
73+
$('#auth-menu').removeAttr('hidden');
74+
} else {
75+
$('#default-menu').removeAttr('hidden');
76+
}
77+
}

public/search.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h3 id="exerciseName"></h3>
4747
</fieldset>
4848
</form>
4949
</div>
50-
50+
5151
</section>
5252

5353
</main>
@@ -80,12 +80,13 @@ <h3 id="exerciseName"></h3>
8080
<script src="/moment.js"></script>
8181
<script src="/utilities/cache.module.js"></script>
8282
<script src="/typeahead.js"></script>
83-
83+
8484
<script src="/utilities/http.module.js"></script>
8585
<script src="/utilities/index.js"></script>
8686
<script src="/dashboard.page.js"></script>
8787
<script src="/search.js"></script>
88-
88+
<script src="/home.js"></script>
89+
8990

9091
</body>
9192

public/utilities/http.module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function getUserWorkouts(options) {
102102
}
103103

104104
function createWorkout(options) {
105-
105+
console.log("Creating Workout")
106106
const {
107107
jwtToken,
108108
newWorkout,

0 commit comments

Comments
 (0)