-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackup.txt
184 lines (180 loc) · 5.52 KB
/
backup.txt
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GWA Calculator</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" />
<style>
@import url("https://fonts.googleapis.com/css?family=Montserrat:400,800");
* {
box-sizing: border-box;
}
body {
background: #f6f5f7;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-family: "Montserrat", sans-serif;
}
.container {
background-color: #fff;
border-radius: 10px;
position: relative;
overflow: hidden;
width: 768px;
max-width: 100%;
min-height: 550px;
margin-top: 45px;
margin-bottom: 45px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
h1 {
font-weight: bold;
margin-top: 50px;
}
p {
margin: 35px 0 35px 0;
font-size: 20px;
font-weight: bold;
}
.inputField {
width: 500px;
padding: 10px;
margin: 10px 0;
box-sizing: border-box;
border-radius: 8px;
}
input {
width: 500px;
padding: 10px;
margin: 10px 0;
box-sizing: border-box;
border-radius: 8px;
}
button {
border-radius: 8px;
border: 1px solid #4DB557;
background-color: #4DB557;
color: #ffffff;
font-size: 12px;
font-weight: bold;
padding: 12px 45px;
letter-spacing: 1px;
text-transform: uppercase;
transition: transform 80ms ease-in;
}
button#resetButton {
background-color: #FF5555;
border: 1px solid #FF5555;
}
@media screen and (max-width: 768px) {
.container {
height: 80%;
width: 90%;
}
input {
width: 280px;
padding: 10px;
margin: 10px auto;
box-sizing: border-box;
border-radius: 8px;
}
.inputField {
width: 300px;
padding: 10px;
margin: 10px auto;
box-sizing: border-box;
border-radius: 8px;
}
}
.button-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container" id="container">
<h1>GWA Calculator</h1>
<div id="inputFields">
<div class="inputField">
<input type="text" class="subjectInput" placeholder="Subject">
<input type="number" class="unitsInput" pattern="\d*" placeholder="Units">
<input type="number" class="gradeInput" pattern="\d*\.?\d*" placeholder="Grade">
</div>
</div>
<div class="button-container">
<button onclick="addInputField()">Add</button>
<button id="resetButton" onclick="resetFields()">Reset</button>
</div>
<button onclick="calculateGWA()">Calculate GWA</button>
<p>GWA: <span id="resultLabel">0.00</span></p>
</div>
</body>
<script>
function addInputField() {
var inputFieldsDiv = document.getElementById("inputFields");
var newInputField = document.createElement("div");
newInputField.className = "inputField";
var subjectInput = document.createElement("input");
subjectInput.type = "text";
subjectInput.className = "subjectInput";
subjectInput.placeholder = "Subject";
var unitsInput = document.createElement("input");
unitsInput.type = "number";
unitsInput.className = "unitsInput";
unitsInput.pattern = "\\d*";
unitsInput.placeholder = "Units";
var gradeInput = document.createElement("input");
gradeInput.type = "number";
gradeInput.className = "gradeInput";
gradeInput.pattern = "\\d*\\.?\\d*";
gradeInput.placeholder = "Grade";
newInputField.appendChild(subjectInput);
newInputField.appendChild(unitsInput);
newInputField.appendChild(gradeInput);
inputFieldsDiv.appendChild(newInputField);
}
function calculateGWA() {
var totalGrade = 0;
var totalUnits = 0;
var inputFields = document.getElementsByClassName("inputField");
for (var i = 0; i < inputFields.length; i++) {
var units = parseFloat(inputFields[i].getElementsByClassName("unitsInput")[0].value);
var grade = parseFloat(inputFields[i].getElementsByClassName("gradeInput")[0].value);
if (isNaN(units) || isNaN(grade)) {
alert("Please enter valid numeric values for Units and Grade in field " + (i + 1) + ".");
return;
}
var gwa = units * grade;
totalGrade += gwa;
totalUnits += units;
}
if (totalUnits === 0) {
alert("Please add at least one subject with valid units and grade.");
return;
}
var totalGWA = totalGrade / totalUnits;
var resultLabel = document.getElementById("resultLabel");
resultLabel.textContent = totalGWA.toFixed(2);
}
function resetFields() {
var inputFields = document.getElementsByClassName("inputField");
for (var i = 0; i < inputFields.length; i++) {
inputFields[i].getElementsByClassName("subjectInput")[0].value = "";
inputFields[i].getElementsByClassName("unitsInput")[0].value = "";
inputFields[i].getElementsByClassName("gradeInput")[0].value = "";
}
var resultLabel = document.getElementById("resultLabel");
resultLabel.textContent = "0.00";
}
</script>
</html>