-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
221 lines (192 loc) Β· 6.07 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Housemate Grocery List</title>
<style>
body {
font-family: "Comic Sans MS", "Times New Roman", sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #c2dbbf;
color: #333;
}
header {
background-color: #8db580;
color: #fff;
text-align: center;
padding: 10px;
}
.container {
display: grid;
grid-template-columns: 1fr repeat(6, 1fr);
gap: 20px;
padding: 20px;
}
.column {
border: 1px solid rgba(125, 184, 134, 0.5);
padding: 20px;
text-align: center;
background-color: #c2dbbf;
color: #333;
flex-grow: 1;
}
.checklist {
text-align: left;
}
input,
button {
background-color: #8db580;
color: #fff;
border: none;
padding: 8px;
margin-top: 8px;
cursor: pointer;
width: 100%;
}
input::placeholder {
color: #b5c7a7;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 8px;
}
footer {
background-color: #8db580;
color: #fff;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
display: flex;
justify-content: space-between;
}
#go-to-bill-button,
#clear-button {
margin-left: 20px;
font-weight: bold;
font-size: 1.2em;
padding: 8px 16px;
border: 2px solid #5b9957; /* Different shade of green */
border-radius: 12px;
cursor: pointer;
background-color: #7fc27e;
}
@media only screen and (max-width: 600px) {
.container {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<header>
<h1>πΏ Housemate Grocery List π</h1>
</header>
<div class="container">
<div class="column" id="your-items">
<h2>π Your Items π</h2>
<div class="checklist" id="your-items-checklist">
<ul id="your-items-list"></ul>
</div>
</div>
<div class="column" id="veggies">
<h2>π₯¦ Veggies π½</h2>
<div class="checklist" id="veggies-checklist">
<input type="text" id="veggies-input" placeholder="Add item" />
<button onclick="addItem('veggies');">Add</button>
<ul id="veggies-list"></ul>
</div>
</div>
<div class="column" id="fruits">
<h2>π Fruits π</h2>
<div class="checklist" id="fruits-checklist">
<input type="text" id="fruits-input" placeholder="Add item" />
<button onclick="addItem('fruits');">Add</button>
<ul id="fruits-list"></ul>
</div>
</div>
<div class="column" id="breakfast">
<h2>π³ Breakfast π₯</h2>
<div class="checklist" id="breakfast-checklist">
<input type="text" id="breakfast-input" placeholder="Add item" />
<button onclick="addItem('breakfast');">Add</button>
<ul id="breakfast-list"></ul>
</div>
</div>
<div class="column" id="lunch">
<h2>π Lunch π</h2>
<div class="checklist" id="lunch-checklist">
<input type="text" id="lunch-input" placeholder="Add item" />
<button onclick="addItem('lunch');">Add</button>
<ul id="lunch-list"></ul>
</div>
</div>
<div class="column" id="spices">
<h2>πΆοΈ Spices π§</h2>
<div class="checklist" id="spices-checklist">
<input type="text" id="spices-input" placeholder="Add item" />
<button onclick="addItem('spices');">Add</button>
<ul id="spices-list"></ul>
</div>
</div>
<div class="column" id="sauces">
<h2>π
Sauces π</h2>
<div class="checklist" id="sauces-checklist">
<input type="text" id="sauces-input" placeholder="Add item" />
<button onclick="addItem('sauces');">Add</button>
<ul id="sauces-list"></ul>
</div>
</div>
</div>
<button id="clear-button" onclick="clearItems()">Clear Items</button>
<footer>
<p>© 2023 Housemate Grocery List</p>
<button id="go-to-bill-button" onclick="goToBill()">Go to Bill</button>
</footer>
<script>
var totalPrice = 0;
var recap = [];
window.onload = function () {
var yourItemsList = document.getElementById("your-items-list");
var recap = JSON.parse(localStorage.getItem("items"));
for (var i = 0; i < recap.length; i++) {
var listItem = document.createElement("li");
listItem.textContent = recap[i];
yourItemsList.appendChild(listItem);
}
};
function addItem(category) {
let price = prompt("What is the price for each item?");
let number = prompt("How many do you want for this item?");
totalPrice += price * number;
var inputElement = document.getElementById(category + "-input");
var listElement = document.getElementById(category + "-list");
var yourItemsList = document.getElementById("your-items-list");
var listItem = document.createElement("li");
listItem.textContent = inputElement.value + " X " + number;
recap.push(listItem.textContent);
window.localStorage.setItem("items", JSON.stringify(recap));
listElement.appendChild(listItem);
yourItemsList.appendChild(listItem.cloneNode(true));
inputElement.value = "";
}
function goToBill() {
alert("Redirecting to the bill page...");
location.href = "Second.html";
totalPrice.toFixed(2);
window.localStorage.setItem("price", JSON.stringify(totalPrice));
}
function clearItems() {
localStorage.clear();
location.reload();
}
</script>
</body>
</html>