-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptG.js
46 lines (30 loc) · 1.16 KB
/
scriptG.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
// for i_gift.html _ _ _ _ _ __ _ _ _ _ _ _ _ _ _ _ _ _ _
const buttonG = document.querySelector("#btnG");
buttonG.addEventListener("click", calculateAmountG);
let confett = document.querySelector("#my-canvas");
let btnClose = document.querySelector(".close");
function calculateAmountG(e) {
e.preventDefault();
const billG = document.querySelector("#billG").value;
const billAddG = document.querySelector("#billAddG").value;
const peopleG = document.querySelector("#peopleG").value;
if(billG==="" || peopleG==="" || peopleG < 1) {
Swal.fire({
icon: 'error',
title: 'Error!',
text: 'Please enter your information!'
});
}
let sumBillG = +billG + +billAddG;
let totalSumG = sumBillG/peopleG;
totalSumG = totalSumG.toFixed(2);
document.querySelector("#billAndTipG").textContent = totalSumG;
confett.classList.add('active');
btnClose.classList.add('active');
}
btnClose.addEventListener("click", ()=>{
document.location.reload();
});
const confettiSettings = { target: 'my-canvas' };
const confetti = new ConfettiGenerator(confettiSettings);
confetti.render();