-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
131 lines (66 loc) · 2.94 KB
/
Copy pathscript.js
File metadata and controls
131 lines (66 loc) · 2.94 KB
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
const form = document.querySelector('#bmi-form')
form.addEventListener('submit', function (e) {
e.preventDefault();
const height = parseFloat(document.querySelector('#height').value)
const weight = parseFloat(document.querySelector('#weight').value)
const results = document.querySelector('#results')
const aireAleart = document.getElementById('alert')
let timeoutDuration = 3500;
if(height === '' || height < 0 || isNaN(height)) {
results.innerHTML =`please give a valid height ${height}`;
setTimeout(() => results.innerHTML = "", 3000);
return;
}else if(weight === '' || weight < 0 || isNaN(weight)) {
results.innerHTML =`please give a valid weight ${weight}`;
setTimeout(() => results.innerHTML = "", 3000);
return;
}else {
const bmi = (weight / ((height * height) / 10000)).toFixed(2);
let massage = `<span>Your BMI is: ${bmi}</span>`;
if (bmi <= 18.6) {
massage += `<span style="color: green;"> <br>
You are underweight</span>`;
timeoutDuration = 3500;
} else if (bmi >= 18.6 && bmi <= 24.9) {
massage += `<span style="color: #8a6d3b;"> <br>
<i class="fas fa-exclamation-triangle" style="margin-right: 5px;"></i>
You are in healthy range</span>`;
timeoutDuration = 3500;
} else {
massage += `<span style="color: #721c24;"> <br>
<i class="fa-solid fa-triangle-exclamation" style="font-size: 1.2rem;"></i>
You are overweight — please <br/>take care of your health.</span>`;
aireAleart.play()
timeoutDuration = 9000;
}
results.innerHTML = massage;
setTimeout(() => {
results.innerHTML = "";
form.reset();
}, timeoutDuration);
}
})
document.addEventListener('DOMContentLoaded', function () {
const animatedBox = document.querySelector('.flip-box-init');
setTimeout(() => {
animatedBox.classList.add('flip-box-show');
}, 300); // start animation after 300ms
});
document.addEventListener('DOMContentLoaded', function () {
const animatedText = document.querySelector('.zoom-in-text-right');
setTimeout(() => {
animatedText.classList.add('zoom-in-text-show');
}, 300); // start animation after 300ms
});
document.addEventListener('DOMContentLoaded', function () {
const animatedText = document.querySelector('.zoom-in-left');
setTimeout(() => {
animatedText.classList.add('zoom-in-show');
}, 300); // start animation after 300ms
});
document.addEventListener('DOMContentLoaded', function () {
const animatedText = document.querySelector('.zoom-in-bottom-up');
setTimeout(() => {
animatedText.classList.add('zoom-in-bottom-show');
}, 300); // start animation after 300ms
});