-
Notifications
You must be signed in to change notification settings - Fork 0
/
food_point.html
300 lines (269 loc) · 9.55 KB
/
food_point.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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html>
<head>
<link href="shop_style.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Playfair+Display" rel="stylesheet">
<title>DeliciousMenu.com</title>
</head>
<body>
<div id="body">
<div id = "navbar" class="navbar">
<nav class="font">
<a href="index_change.html"><strong>Home </strong></a>
<a href="login_change.html"><strong>Login </strong></a>
<a href="#about_us"><strong>About us!</strong></a>
</nav>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br>
<div id="heading">
<h2><strong>B-Block</strong></h2><br>
Click on the shop you want to order from!
</div>
<br>
<div class="shop_image_f">
<div >
<h2>Food Point</h2>
<a href="food_point.html"><img class="shop_image" src="Food_point_img.jpg" alt="shop1" height="300" width="300"></a>
<p class="shop_text">
text about shop
</p>
</div>
</div>
<br>
<p id="menu">Food Point</p>
<section class="shop_items">
<img class="shop_items_img" src="maggi.jpeg" width="200px" height="200px">
<p class="item_description"><strong>Maggi</strong><br>Description</p>
<span class="price">price : 30</span>
<p id="list_of_food_selected_food_point1" onclick="change(this.id)">
<button id="fp1" onclick="addToCart(this.id)" class="price_button">+</button><button id='but1' class='price_button'>Add</button><button id="fp1" onclick="removeFromCart(this.id)" class="price_button">-</button>
<p>0</p>
</p>
</section>
<section class="shop_items">
<img class="shop_items_img" src="bread_pakora.jpeg" width="200px" height="200px">
<p class="item_description"><strong>Bread Pakoda</strong><br>Description</p>
<span class="price">price : 40</span>
<p id="fp2" onclick="change(this.id)">
<button id="fp2" onclick="addToCart(this.id)" class="price_button">+</button><button id='but2' class='price_button'>Add</button><button id="fp2" onclick="removeFromCart(this.id)" class="price_button">-</button>
<p></p>
</p>
</section>
<section class="shop_items">
<img class="shop_items_img" src="sandwich.jpeg" width="200px" height="200px">
<p class="item_description"><strong>Sandwich</strong><br>Description</p>
<span class="price">price : 50</span>
<p id="fp3" onclick="change(this.id)">
<button id="fp3" onclick="addToCart(this.id)" class="price_button">+</button><button id='but3' class='price_button'>Add</button><button id="fp3" onclick="removeFromCart(this.id)" class="price_button">-</button>
<p></p>
</p>
</section>
<section class="shop_items">
<img class="shop_items_img" src="veg_hakka.jpeg" width="200px" height="200px">
<p class="item_description"><strong>Veg Hakka Noodles</strong><br>Description</p>
<span class="price">price : 30</span>
<p id="fp4" onclick="change(this.id)">
<button id="fp4" onclick="addToCart(this.id);" class="price_button">+</button><button id='but4' class='price_button'>Add</button><button id="fp4" onclick="removeFromCart(this.id);" class="price_button">-</button>
<p></p>
</p>
</section>
<a id="payment" href="payment.html"><strong>PROCEED TO PAY.</strong></a>
<br><br>
<div id="about_us">
<h2><strong>About Us</strong></h2>
<div id="some_data">
<div class="some_thing">
<strong>Address</strong>:Outer Ring Rd, Banashankari 3rd Stage, Banashankari, Bengaluru, Karnataka 560085
</div>
<div class="some_thing">
<strong>Campus</strong>:Urban
</div>
<div class="some_thing">
<strong>Terms Of Use.</strong>
</div>
<div class="some_thing">
<strong>License</strong>:All rights reserved.
</div>
</div>
</div>
</div>
<div id="social_media">
<ul>
<li><a href="#index_change.html"><img src="facebook.jpg" height="30" width="30"></a></li>
<li><a href="#index_change.html"><img src="pintrest.jpg" height="30" width="30"></a></li>
<li><a href="#index_change.html"><img src="instagram.jpg" height="30" width="30"></a></li>
<li><a href="#index_change.html"><img src="google+.jpg" height="30" width="30"></a></li>
<li><a href="#index_change.html"><img src="twitter.jpg" height="30" width="30"></a></li>
<li><a href="#index_change.html"><img src="whatsapp.jpg" height="30" width="30"></a></li>
</ul>
</div>
<script type="text/javascript">
//All changes to javascript
var button1=document.getElementById('but1');
var button2=document.getElementById('but2');
var button3=document.getElementById('but3');
var button4=document.getElementById('but4');
var num1=0,num2=0,num3=0,num4=0;
const price1=30,price2=40,price3=50,price4=60;
//add to cart stores the variable in session storage if it is not selected any time
//then it add the number of times it is clicked to store the item
function addToCart(id)
{
if(id=='fp1')
{
if(sessionStorage.getItem('list_of_food_selected_food_point1')!=null)
{
num1=num1+1;
sessionStorage.setItem('list_of_food_selected_food_point1',id+','+num1+','+price1+','+'food1.jpg');
}
else
{
num1=1;
sessionStorage.setItem('list_of_food_selected_food_point1',id+','+num1+','+price1+','+'food1.jpg');
}
button1.innerHTML=num1;
}
else if(id=='fp2')
{
if(sessionStorage.getItem('list_of_food_selected_food_point2')!=null)
{
num2+=1;
sessionStorage.setItem('list_of_food_selected_food_point2',id+','+num2+','+price2+','+'food1.jpg');
}
else
{
num2=1;
sessionStorage.setItem('list_of_food_selected_food_point2',id+','+num2+','+price2+','+'food1.jpg');
}
button2.innerHTML=num2;
}
else if(id=='fp3')
{
if(sessionStorage.getItem('list_of_food_selected_food_point3')!=null)
{
num3+=1;
sessionStorage.setItem('list_of_food_selected_food_point3',id+','+num3+','+price2+','+'food1.jpg');
}
else
{
num3=1;
sessionStorage.setItem('list_of_food_selected_food_point3',id+','+num3+','+price3+','+'food1.jpg');
}
button3.innerHTML=num3;
}
else
{
if(sessionStorage.getItem('list_of_food_selected_food_point4')!=null)
{
num4+=1;
sessionStorage.setItem('list_of_food_selected_food_point4',id+','+num4+','+price4+','+'food1.jpg');
}
else
{
num4=1;
sessionStorage.setItem('list_of_food_selected_food_point4',id+','+num4+','+price4+','+'food1.jpg');
}
button4.innerHTML=num4;
}
}
//when clicked on removeFromCart the number of food items ordered is decreased by 1.
function removeFromCart(id)
{
if(id=='fp1'&& num1>0)
{
if(num1==0)
{ //console.log('working');
alert("No item added to the cart");
return;
}
if(sessionStorage.getItem('list_of_food_selected_food_point_1')!=null)
{
num1=num1-1;
if(num1==0)
{ //console.log('working');
sessionStorage.removeItem('list_of_food_selected_food_point_1');
button1.innerHTML='Add';
return;
}
sessionStorage.setItem('list_of_food_selected_food_point_1',id+','+num1+','+price1+','+'food1.jpg');
button1.innerHTML=num1;
}
}
else if(id=='fp2'&& num1>0)
{
if(num2==0)
{ //console.log('working');
alert("No item added to the cart");
return;
}
if(sessionStorage.getItem('list_of_food_selected_food_point_2')!=null)
{
num2=num2-1;
if(num2==0)
{ //console.log('working');
sessionStorage.removeItem('list_of_food_selected_food_point_2');
button2.innerHTML='Add';
return;
}
sessionStorage.setItem('list_of_food_selected_food_point_2',id+','+num2+','+price2+','+'food1.jpg');
button2.innerHTML=num2;
}
}
else if(id=='fp3'&& num1>0)
{
if(num3==0)
{ //console.log('working');
alert("No item added to the cart");
return;
}
if(sessionStorage.getItem('list_of_food_selected_food_point_3')!=null && num3>0)
{
num3-=1;
if(num3==0)
{
button3.innerHTML='Add';
sessionStorage.removeItem('list_of_food_selected_food_point_3');
return;
}
sessionStorage.setItem('list_of_food_selected_food_point_3',id+','+num3+','+price2+','+'food1.jpg');
button3.innerHTML=num3;
}
}
else
{
if(num4==0)
{ //console.log('working');
alert("No item added to the cart");
return;
}
if(sessionStorage.getItem('list_of_food_selected_food_point_4')!=null && num4>0)
{
num4-=1;
if(num4==0)
{ //console.log('working');
sessionStorage.removeItem('list_of_food_selected_food_point_4');
button4.innerHTML='Add';
return;
}
sessionStorage.setItem('list_of_food_selected_food_point_4',id+','+num4+','+price4+','+'food1.jpg');
button4.innerHTML=num4;
}
}
}
function change(id)
{
var i;
//search the id of element which was clicked in session array
for (i = 0; i < sessionStorage.length; i++)
{
if(sessionStorage.getItem(sessionStorage.key(i)).split(',')[0]==id);
break;
}
//add the updated value of number of items an item was selected to the shop page
var t=sessionStorage.getItem(sessionStorage.key(i)).split(',')[1];
console.log(document.getElementById(id).parentNode.nodeName);
document.getElementById(id).parentNode.childNodes[2][document.getElementById(id).childNodes[0].nodeType === 3 ? 'data' : 'innerHTML']=t;//change the last paragraph element.
}
</script>
</body>
</html>