-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatt.js
58 lines (55 loc) · 2.18 KB
/
att.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
let form=document.getElementsByName("form");
let output=document.querySelector("#output");
let output1=document.querySelector(".output");
let present=document.getElementById("p");
let total=document.getElementById("t");
let bunk=document.getElementById("b");
let extra=document.getElementById("e");
let noOfLecture=document.getElementById("n");
let myChart=document.getElementById("myChart")
let button=document.getElementById("button")
let z=document.createElement("p");
let dropbox=document.getElementById("dropbox");
function data(){
console.log("data is called")
let a,x,d,calc,n=0;
let b=parseInt(total.value)
d=1/parseInt(noOfLecture.value);
x=d*(parseInt(extra.value)*2);
d=d*parseInt(bunk.value);
a =parseInt(present.value) - d + x
calc=(a/parseInt(total.value))*100
if (parseInt(present.value) < 0 || parseInt(total.value) <= 0 || parseInt(present.value) > parseInt(total.value)) {
return (output.innerHTML= "Proper values please ¯\\_(ツ)_/¯");
}else{
calculation(calc,a,b,n)
}
}
function calculation(calc,a,b,n){
console.log("calculation is called")
output.innerHTML=`Attendance Percentage: ${(Math.round((calc* 100)) / 100)}% <br>`
if(calc<parseInt(dropbox.value)){
console.log("less than 75")
while (((a/b)*100)<=parseInt(dropbox.value)){
n++,b++,a++
}
calc=(a/b)*100
z.innerHTML=`You need to attend <b>${n}</b> more days to attain ${(Math.round((calc* 100)) / 100)} attendance.`;
output1.appendChild(z);
n=0
}else if (calc>parseInt(dropbox.value)){
console.log("greater than 75")
while (((a/b)*100)>=parseInt(dropbox.value)){
n++,b++
}
b--, n--
calc=(a/b)*100
z.innerHTML=`You can bunk for <b>${n}</b> more days. and you attendance will be ${(Math.round((calc* 100)) / 100)}%`;
output1.appendChild(z);
n=0
}
}
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})