-
Notifications
You must be signed in to change notification settings - Fork 0
/
pies.html
78 lines (76 loc) · 2.51 KB
/
pies.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="site.css" type="text/css" />
<title>Pies | Bethany's pie shop</title>
<style></style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="pies.html">Pies</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<main>
<aside><img src="images/logo.png" alt="" /></aside>
<article>
<section class="columns-desktop">
<div class="pie">
<img src="images/apple-pie.png" alt="Apple Pie" />
<div class="columns">
<div class="title">Apple Pie</div>
<div class="price">$12.95</div>
</div>
<p class="desc">Our famous apple pie</p>
<button data-order="apple-pie">Order</button>
</div>
<div class="pie">
<img src="images/cherry-pie.png" alt="Cherry Pie" />
<div class="columns">
<div class="title">Cherry Pie</div>
<div class="price">$15.95</div>
</div>
<p class="desc">A summer classic!</p>
<button data-order="cherry-pie">Order</button>
</div>
</section>
</article>
</main>
<footer>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="pies.html">Pies</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</footer>
</body>
<script>
window.addEventListener("DOMContentLoaded", function (e) {
const orderButtons = document.querySelectorAll("button[data-order]");
orderButtons.forEach(function (button) {
button.addEventListener("click", function (e) {
const button = e.currentTarget;
const container = button.parentNode;
const order = {
id: button.getAttribute("data-order"),
title: container.querySelector(".title").innerText,
price: container.querySelector(".price").innerText,
desc: container.querySelector(".desc").innerText,
};
localStorage.setItem("order", JSON.stringify(order));
const url = window.location.href.replace("pies.html", "order.html");
window.location.href = url;
});
});
});
</script>
</html>