-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
118 lines (106 loc) · 3.44 KB
/
script.js
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
const burgerr = document.querySelector('.navimage');
const nav = document.querySelector('.nav-links');
burgerr.addEventListener('click', () => {
nav.classList.toggle('nav-active');
burgerr.classList.toggle('toggle');
});
var total_price, product;
function update_product() {
if(--window.LoopTrap <= 0) throw "Infinite loop.";
let element_name = document.getElementById('name');
let new_div = document.createElement('div');
new_div.innerText = product.shift();
element_name.appendChild(new_div);
let element_quantity = document.getElementById('quantity');
let new_div2 = document.createElement('div');
new_div2.innerText = product.shift();
element_quantity.appendChild(new_div2);
let element_price = document.getElementById('price');
let new_div3 = document.createElement('div');
new_div3.innerText = product.shift();
element_price.appendChild(new_div3);
product = [];
}
function totalcast() {
if(--window.LoopTrap <= 0) throw "Infinite loop.";
let element_totalcart = document.getElementById('totalcart');
element_totalcart.innerText = total_price.reduce((a,b) => a+b, 0);
}
total_price = [];
product = [];
document.getElementById('biryani').addEventListener('click', (event) => {
product.push('delicious Biryani');
product.push(1);
product.push('8,00€');
total_price.push(8);
update_product();
totalcast();
});
document.getElementById('mutton').addEventListener('click', (event) => {
product.push('Mutton Karahi');
product.push(1);
product.push('12,00€');
total_price.push(12);
update_product();
totalcast();
});
document.getElementById('fish').addEventListener('click', (event) => {
product.push('Fried Fish');
product.push(1);
product.push('8,50€');
total_price.push(8.50);
update_product();
totalcast();
});
document.getElementById('nugets').addEventListener('click', (event) => {
product.push('Chicken Nuguets');
product.push(1);
product.push('7,00€');
total_price.push(7);
update_product();
totalcast();
});
document.getElementById('wings').addEventListener('click', (event) => {
product.push('Chicken Wings');
product.push(1);
product.push('5,00€');
total_price.push(5);
update_product();
totalcast();
});
document.getElementById('sekhkabab').addEventListener('click', (event) => {
product.push('Sekh Kabab');
product.push(1);
product.push('7,70€');
total_price.push(7.70);
update_product();
totalcast();
});
document.getElementById('samosa').addEventListener('click', (event) => {
product.push('Yummy Samosa');
product.push(1);
product.push('3,50€');
total_price.push(3.50);
update_product();
totalcast();
});
document.getElementById('paya').addEventListener('click', (event) => {
product.push('Mutton Paya');
product.push(1);
product.push('9,50€');
total_price.push(9.50);
update_product();
totalcast();
});
document.getElementById('clearbtn').addEventListener('click', (event) => {
let element_name2 = document.getElementById('name');
element_name2.replaceChildren();
let element_quantity2 = document.getElementById('quantity');
element_quantity2.replaceChildren();
let element_price2 = document.getElementById('price');
element_price2.replaceChildren();
let element_totalcart2 = document.getElementById('totalcart');
element_totalcart2.innerText = 0;
total_price = [];
product = [];
});