-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfirmation.html
157 lines (144 loc) · 6.68 KB
/
confirmation.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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!doctype html>
<html lang="en">
<head>
<title>Confirmation - Starshop</title>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- bootstrap -->
<link rel="stylesheet" href="css/bootstrap-dark.css">
<link href="css/custom.css" rel="stylesheet">
<!-- icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<link rel="icon" href="assets/icons/cart.png">
<!-- handlebars -->
<script src="js/handlebars.min-v4.7.8.js"></script>
<script src="js/vanilla.js"></script>
<script src="js/checkout.js"></script>
<script>
function init() {
const checkout = JSON.parse(sessionStorage.getItem("checkout"))
render(checkout, '[type="text/x-handlebars-checkout"]')
const cart = JSON.parse(sessionStorage.getItem("boughtStars"))
total = 0
cart.forEach(element => {
total += element["Price"]
});
render({ "total": total }, '[type="text/x-handlebars-template-2"]')
if (cart.length > 0) {
render(cart, '[type="text/x-handlebars-cart"]')
}
toOrders(checkout, cart, total)
render({}, '[type="text/x-handlebars-navbar"]')
render({}, '[type="text/x-handlebars-footer"]')
}
function toOrders(checkout, data, total) {
ordersString = localStorage.getItem("orders")
var orders = JSON.parse(ordersString)
if (ordersString === null) {
var neworders = [{ "checkout": checkout, "data": data, "total": total }]
localStorage.setItem("orders", JSON.stringify(neworders))
}
else if (validateOrder(orders, total) === true) {
orders.push({ "checkout": checkout, "data": data, "total": total })
localStorage.setItem("orders", JSON.stringify(orders))
}
}
function validateOrder(orders, total) {
var validated = true
orders.forEach(element => {
if (element.total === total) {
validated = false;
}
});
return validated
}
</script>
</head>
<body onload="init()">
<script id="template" type="text/x-handlebars-navbar">
{{> navbar }}
</script>
<div></div>
<!-- MARK: Support Card
-->
<section id="Support Card" class="bg-black py-5 star-background">
<div class="container-lg justify-content-center">
<div class="row align-content-center justify-content-center">
<div class="col-lg-8">
<div class="card bg ">
<div class="card-body">
<h4 class="card-title pb-4 text-center">Your order is arriving soon</h4>
<script id="template" type="text/x-handlebars-cart">
{{#each this}}
<li class="list-group-item d-flex justify-content-between lh-condensed">
<img src="assets/stars/{{Color}}.png" class="card-img-top cart-image-checkout border-bottom border-dark img-fluid">
<div>
<h6 class="my-0 text-start">{{ProperName}}</h6>
<small class="text-muted">
{{#if (lt Price 100000)}}
<strong>Sale</strong>
{{/if}}
Distance: {{Distance}}
</small>
</div>
<span class="text-muted">€ {{formatCurrency Price}}</span>
</li>
{{/each}}
</script>
<ul class="list-group mb-1">
</ul>
<script id="template" type="text/x-handlebars-template-2">
<div class="col-10 col-sm-8 col-md-6 col-xl-4 justify-center mt-2 text-center">
<ul>
<li class="list-group-item justify-content-between">
<span>
Total
</span>
<strong>
€ {{formatCurrency total}}
</strong>
</li>
</ul>
</div>
</script>
<div class="row justify-content-center mb-2"></div>
<div class="container">
<script id="template" type="text/x-handlebars-checkout">
{{#each this}}
<div class="col-12 col-sm-10 col-md-8 col-xl-6">
<ul class="list-group mt-1">
<li class="list-group-item d-flex border-0 justify-content-between lh-condensed">
<div>
<h6 class="my-0 text-start">{{name}}</h6>
</div>
<span class="text-muted">{{value}}{{#if (eq value "")}}nothing{{/if}}
</span>
</li>
</ul>
<hr style="height:2px">
</div>
{{/each}}
</script>
<div class="row justify-content-center">
</div>
</div>
<div class="card-footer text-center mt-3">
<a href="articles.html" class="btn btn-secondary btn-lg">Home</a>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- MARK: footer
-->
<script id="template" type="text/x-handlebars-footer">
{{> footer }}
</script>
<div></div>
<!-- Bootstrap JavaScript Libraries -->
<script src="js/bootstrap.js"></script>
</body>
</html>