-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndex.js
113 lines (104 loc) · 2.77 KB
/
Index.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
let AddHTML=()=>
{
let HTMLData=
`
<tr class="DataBody">
<div>
<td><input CH="Sn" type="text"></td>
<td><input class="CH" type="text"></td>
<td class="Grade">
<select name="" id="Grade">
<option value="">-</option>
<option value="">A+</option>
<option value="">A</option>
<option value="">A-</option>
<option value="">B+</option>
<option value="">B</option>
<option value="">B-</option>
<option value="">C+</option>
<option value="">C</option>
<option value="">C-</option>
<option value="">D+</option>
<option value="">D</option>
<option value="">D-</option>
<option value="">F</option>
</select>
</td>
</div>
</tr>
`
document.querySelector('.TableData').insertAdjacentHTML('afterbegin' , HTMLData);
}
document.querySelector('.fa-circle-plus').addEventListener("click" , ()=>
{
AddHTML();
})
function Points(Arg)
{
switch (Arg) {
case 'A+':
return 4
break;
case 'A':
return 4
break;
case 'A-':
return 3.7
break;
case 'B+':
return 3.3
break;
case 'B':
return 3
break;
case 'B-':
return 2.7
break;
case 'C+':
return 2.3
break;
case 'C':
return 2
break;
case 'C-':
return 1.7
break;
case 'D+':
return 1.3
break;
case 'D':
return 1
break;
case 'D-':
return 0.7
break;
case 'F':
return 0
break;
default:
break;
}
}
document.querySelector(".B1").addEventListener("click" , (e)=>
{
e.preventDefault();
let X=document.querySelectorAll('.DataBody .CH');
let Y=document.querySelectorAll('.DataBody #Grade');
let Sum1=0;
let Sum2=0;
for(let i=0; i<X.length ; i++)
{
let Ind=Y[i].selectedIndex;
let Po=Points(Y[0][Ind].text);
Sum1+=+X[i].value;
Sum2+=Po*X[i].value
}
let GPA=(Sum2/Sum1).toFixed(3);
document.querySelector('.Detail').style.display="flex";
document.querySelector('.Detail').classList.add('Detail2');
document.querySelector('.GPA').innerHTML=`${GPA}`;
});
document.querySelector('.B2').addEventListener("click" , ()=>
{
document.querySelector('.Detail').classList.remove('Detail2');
});