forked from Jack-Drake/362-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (76 loc) · 3.34 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg shadow">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="./logo.png" width="90"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="./">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/allRecipes.html">All Recipes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact.html">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container text-center mt-5">
<h1>Recipe of The Day</h1>
<div id="randomRecipeContainer" class="container"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous">
</script>
<script>
window.onload = function () {
fetch("/requestRandomRecipe", {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: null
})
.then((response) => response.json())
.then((data) => handleRandomRecipeResponse(data));
}
function handleRandomRecipeResponse(data){
document.getElementById("randomRecipeContainer").innerHTML = `
<div class="row m-3" style="min-height: 400px;">
<div class="col" style="
background: url(`+ data.imageURL +`);
background-repeat: no-repeat;
background-size: cover;"></div>
<div class="col" style="position:relative;">
<div class="text-start">
<h2>`+ data.name +`</h2>
<hr>
<h5>Total Ingredients: `+ data.ingredients.length +`</h5>
<h5>Total Steps: `+ data.steps.length +`</h5>
</div>
<div style="position: absolute;bottom:0;right:0;">
<a class="btn btn-success">Learn More</a>
</div>
</div>
</div>
`;
}
</script>
</body>
</html>