Repository navigation
Expand file tree
/
Copy pathprofile.html
More file actions
126 lines (102 loc) · 6.07 KB
/
Copy pathprofile.html
File metadata and controls
126 lines (102 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Food Findr</title>
<link rel="canonical" href="https://HotSanta.github.io/LosAltosHackathon/">
<link rel="manifest" href="/LosAltosHackathon/manifest.webmanifest">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="index.css">
<link rel="icon" href="Screen Shot 2023-04-08 at 5.59.07 PM.png">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
</head>
<body onload="check()">
<nav>
<div class="row justify-content-center">
<h1 class="py-2 text-light" style="font-size:4rem"><b>FoodFindr</b></h1>
</div>
</nav>
<div class="py-3 container-fluid column justify-content-between">
<div class="row justify-content-center">
<h1 id = "profileName" class="text-light" style="font-size:3rem;">Name</h1>
</div>
</div>
<div class="favoriteRecipes" style="text-align:center;">
<h1>Recipes you Have Favorited</h1>
<h3>Click on them to direct you to their recipe cards</h3>
<div style ="overflow: scroll;height:285px;margin-top:1.25rem;">
<h1 id ="favorite"></h1>
</div>
</div>
<nav class="navbar mt-5 py-5 fixed-bottom navbar-expand-sm d-flex" id="customnav">
<div class="container-fluid flex-fill justify-content-center">
<ul class="navbar-nav flex-fill justify-content-around">
<li class="nav-item justify-content-center">
<a class="nav-link" href="home.html"><i class="bi-house-fill px-2" style="font-size: 4rem; color: gray"></i></a>
</li>
<li class="nav-item justify-content-center">
<a class="nav-link" href="explore.html"><i class="bi-search px-2" style="font-size: 4rem; color: gray"></i></a>
</li>
<li class="nav-item justify-content-center">
<a class="nav-link" href="profile.html"><i class="bi-person-fill px-2" style="font-size: 4rem; color: white"></i></a>
</li>
</ul>
</div>
</nav>
<script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-auth.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-database.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyB4vrsbuA0_8xFlrY_ysnlKPM6bYhvV2l4",
authDomain: "los-altos-hackathon-project.firebaseapp.com",
projectId: "los-altos-hackathon-project",
storageBucket: "los-altos-hackathon-project.appspot.com",
messagingSenderId: "14005580470",
appId: "1:14005580470:web:3c7029a8021494c3296c17",
measurementId: "G-TGJC2F0DR4"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
function check(){
if(sessionStorage.getItem("loggedIn")==null){
window.location = "index.html";
}
else{
email = sessionStorage.getItem("email")
user = email.substring(0,email.indexOf("@"))
document.getElementById("profileName").innerHTML =`Welcome ${user}!`;
loadFavorites();
}
}
function loadFavorites(){
user = sessionStorage.getItem("email").replaceAll(".","").replaceAll("#","").replaceAll("$",'').replaceAll("[","").replaceAll("]","")
const userFavoritesRef = firebase.database().ref('userFavorites/'+user);
userFavoritesRef.on('value', (snapshot) => { // Listen for changes to the user's saved recipes
const recipes = snapshot.val(); // Get the user's saved recipes from the snapshot
const favoriteRecipes = document.getElementById('favorite'); // Get the h1 tag with id "favorite" from your HTML
favoriteRecipes.innerHTML = ''; // Clear any existing links in the h1 tag
for (const recipeId in recipes) { // Iterate through each recipe in the user's saved recipes
const recipe = recipes[recipeId];
const recipeName = recipe.name; // Get the name of the recipe
const recipeCardURL = recipe.imageUrl; // Get the URL of the recipe card image
const link = document.createElement('a'); // Create a new link element
link.href = recipeCardURL; // Set the href attribute of the link to the URL of the recipe card image
link.textContent = recipeName; // Set the text content of the link to the name of the recipe
favoriteRecipes.appendChild(link); // Add the link to the h1 tag with id "favorite"
favoriteRecipes.appendChild(document.createElement('br'));
}
});
}
</script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>