1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
-
4
- < head >
5
- < meta charset ="UTF-8 ">
6
- < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
- < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
8
- < title > Pies | Bethany's Pie Shop</ title >
9
- < link rel ="stylesheet " href ="site.css " type ="text/css ">
10
- </ head >
11
-
12
- < body >
13
- < header >
14
- < nav >
15
- < ul >
16
- < li > < a href ="/ "> Home</ a > </ li >
17
- < li > < a href ="pies.html "> Pies</ a > </ li >
18
- < li > < a href ="contact.html "> Contact</ a > </ li >
19
- </ ul >
20
- </ nav >
21
- </ header >
22
- < main >
23
- < div class ="layout-container ">
24
- < div class ="branding "> < img src ="images/logo.png " alt ="Bethany's Pie Shop "> </ div >
25
- < div class ="content ">
26
- < h1 > Pies</ h1 >
27
- < div >
28
- < img src ="images/apple-pie.png " alt ="Apple Pie ">
3
+ < head >
4
+ < meta charset ="UTF-8 " />
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge " />
7
+ < title > Pies | Bethany's Pie Shop</ title >
8
+ < link rel ="stylesheet " href ="site.css " type ="text/css " />
9
+ </ head >
10
+ < body >
11
+ < header >
12
+ < nav >
13
+ < ul >
14
+ < li > < a href ="/ "> Home</ a > </ li >
15
+ < li > < a href ="pies.html "> Pies</ a > </ li >
16
+ < li > < a href ="contact.html "> Contact</ a > </ li >
17
+ </ ul >
18
+ </ nav >
19
+ </ header >
20
+ < main >
21
+ < div class ="layout-container ">
22
+ < div class ="branding ">
23
+ < img src ="images/logo.png " alt ="Bethany's Pie Shop " />
24
+ </ div >
25
+ < div class ="content ">
26
+ < h1 > Pies</ h1 >
29
27
< div >
30
- < div > Apple Pie</ div >
31
- < div > $12.95</ div >
28
+ < img src ="images/apple-pie.png " alt ="Apple Pie " />
29
+ < div >
30
+ < div class ="title "> Apple Pie</ div >
31
+ < div class ="price "> $12.95</ div >
32
+ </ div >
33
+ < p class ="desc "> Our famous apple pie</ p >
34
+ < button data-order ="apple-pie "> Order</ button >
32
35
</ div >
33
- < p > Our famous apple pie</ p >
34
- < button data-name ="apple-pie "> Order</ button >
35
- </ div >
36
- </ div >
37
- < div >
38
- < img src ="" alt ="">
39
36
< div >
40
- < div > Cherry Pie</ div >
41
- < div > $15.95</ div >
37
+ < img src ="images/cherry-pie.png " alt ="Chery Pie " />
38
+ < div >
39
+ < div class ="title "> Cherry Pie</ div >
40
+ < div class ="price "> $15.95</ div >
41
+ </ div >
42
+ < p class ="desc "> A summer classic!</ p >
43
+ < button data-order ="cherry-pie "> Order</ button >
42
44
</ div >
43
- < p > A summer classic</ p >
44
- < button data-name ="cherry-pie "> Order</ button >
45
45
</ div >
46
46
</ div >
47
- </ div >
48
- </ main >
49
- < footer >
50
- < nav >
51
- < ul >
52
- < li > < a href ="/ "> Home</ a > </ li >
53
- < li > < a href ="pies.html "> Pies</ a > </ li >
54
- < li > < a href ="contact.html "> Contact</ a > </ li >
55
- </ ul >
56
- </ nav >
57
- </ footer >
58
- </ body >
47
+ </ main >
48
+ < footer >
49
+ < nav >
50
+ < ul >
51
+ < li > < a href ="/ "> Home</ a > </ li >
52
+ < li > < a href ="pies.html "> Pies</ a > </ li >
53
+ < li > < a href ="contact.html "> Contact</ a > </ li >
54
+ </ ul >
55
+ </ nav >
56
+ </ footer >
57
+ </ body >
58
+ < script >
59
+ window . addEventListener (
60
+ "DOMContentLoaded" ,
61
+ function ( e ) {
62
+ const orderButtons = document . querySelectorAll ( "button[data-order]" ) ;
63
+
64
+ [ ] . forEach . call ( orderButtons , function ( button ) {
65
+ button . addEventListener ( "click" , function ( e ) {
66
+ const button = e . currentTarget ;
67
+ const id = button . getAttribute ( "data-order" ) ;
68
+ const container = button . parentNode ;
69
+ const title = container . querySelector ( ".title" ) . innerText ;
70
+ const price = container . querySelector ( ".price" ) . innerText ;
71
+ const desc = container . querySelector ( ".desc" ) . innerText ;
72
+
73
+ const order = {
74
+ title : title ,
75
+ id : id ,
76
+ price : price ,
77
+ desc : desc
78
+ } ;
79
+
80
+ localStorage . setItem ( "order" , JSON . stringify ( order ) ) ;
59
81
60
- </ html >
82
+ const url = window . location . href . replace ( "pies.html" , "order.html" ) ;
83
+ window . location . href = url ;
84
+ } ) ;
85
+ } ) ;
86
+ } ,
87
+ false
88
+ ) ;
89
+ </ script >
90
+ </ html >
0 commit comments