-
Notifications
You must be signed in to change notification settings - Fork 0
/
mediaCondicional.html
397 lines (335 loc) · 12.4 KB
/
mediaCondicional.html
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Média</title>
<style>
* {
box-sizing: border-box;
font-family: sans-serif;
}
body {
background-color: #ECECEC;
margin: 8px;
transition: background 0.2s linear;
}
#modal {
width: 300px;
height: 50px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
text-transform: uppercase;
font-size: 12px;
background-color: #272932;
color: #ffffff;
border-top: solid #92ff5c 5px;
position: fixed;
top: 10px;
z-index: 2;
transition: 400ms;
}
#bg-modal {
width: 100%;
height: 100vh;
background-color: #090e2ac4;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
header {
display: flex;
justify-content: end;
margin-bottom: 20px;
}
header>span {
cursor: pointer;
}
main {
display: flex;
flex-direction: column;
gap: 50px;
}
.container {
background-color: #fff;
padding: 2%;
box-shadow: 0px 4px 13px 0px rgba(0,0,0,0.75);
border-radius: 15px;
}
h2 {
font-size: 20px;
}
fieldset {
border: 0;
margin: 0;
padding: 0;
margin-top: 15px;
}
label {
display: block;
font-weight: 600;
margin: 1% 0;
}
input, select, #printMedia1 {
height: 32px;
width: 100%;
border: solid #d1d1d1;
padding: 2px;
background-color: #ffffff00;
}
#printMedia1 {
cursor: not-allowed;
display: flex;
align-items: center;
color: #b2b2b2;
}
input:focus, select:focus {
outline: black solid 1px;
}
button {
height: 32px;
background-color: green;
border: none;
color: #fff;
margin-top: 15px;
cursor: pointer;
border-radius: 0 0 0 10px;
}
button:hover {
background-color: rgb(0, 105, 0);
}
table {
width: 100%;
}
tbody {
display: grid;
grid-template-columns: 1fr 2fr;
}
tr {
display: grid;
}
th, td {
min-height: 40px;
padding: 5px;
}
th {
background-color: green;
color: #fff;
}
td {
grid-template-columns: 1fr 0;
}
@media screen and (min-width: 720px) {
fieldset {
display: flex;
align-items: end;
gap: 5px;
width: fit-content;
}
button {
margin: 0;
border-radius: unset;
}
tr {
grid-template-columns: 2fr repeat(8, 1fr);
}
td, th {
display: flex;
text-align: center;
justify-content: center;
align-items: center;
}
tbody {
display: unset;
}
}
.escuro {
background-color: #313638;
color: #fff;
}
.bg-dark-container {
background-color: #222424;
box-shadow: 0px 4px 13px 0px rgba(0, 0, 0, 0.75);
}
.inputs {
border: solid #314043;
color: gray;
}
</style>
</head>
<body>
<div id="modal" style="right: -300px;">
<p>Algum campo do formulário não esta preenchido corretamente</p>
</div>
<div id="bg-modal" style="display: none;"></div>
<header>
<span id="mudarCor">Mudar tema</span>
</header>
<main>
<div class="container">
<form action="#">
<h2>Cadastro de notas</h2>
<fieldset>
<div class="wrapper">
<label for="nome">Nome Completo:</label>
<input type="text" id="nome" required>
</div>
<div class="wrapper">
<label for="serie">Turma:</label>
<select name="serie" id="serie" required>
<option value="">Escolher Turma</option>
<option value="1EM">1EM</option>
<option value="2EM">2EM</option>
<option value="3EM">3EM</option>
<option value="4EM">4EM</option>
<option value="5EM">5EM</option>
</select>
</div>
<div class="wrapper">
<label for="materia">Matéria:</label>
<select name="materia" id="materia" required>
<option value="">Escolher Matéria</option>
<option value="Português">Português</option>
<option value="Matemática">Matemática</option>
<option value="Física">Física</option>
<option value="Geografia">Geografia</option>
</select>
</div>
</fieldset>
<fieldset>
<div class="wrapper">
<label for="bimestre1">Bimestre 1</label>
<input id="bimestre1" type="number" required>
</div>
<div class="wrapper">
<label for="bimestre2">Bimestre 2</label>
<input id="bimestre2" type="number" required>
</div>
<div class="wrapper">
<label for="bimestre3">Bimestre 3</label>
<input id="bimestre3" type="number" required>
</div>
<div class="wrapper">
<label for="bimestre4">Bimestre 4</label>
<input id="bimestre4" type="number" required>
</div>
<div class="wrapper">
<label>Média</label>
<div id="printMedia1">Calcule</div>
</div>
<button type="button" onclick="clicarBTN(1)">Calcular</button>
</fieldset>
</form>
</div>
<div class="container">
<h2>Relatório</h2>
<table>
<tbody>
<tr>
<th>Nome Completo</th>
<th>Turma</th>
<th>Matéria</th>
<th>B1</th>
<th>B2</th>
<th>B3</th>
<th>B4</th>
<th>Média</th>
<th>Situação</th>
</tr>
<tr>
<td id="printNome">-</td>
<td id="printSerie">-</td>
<td id="printMateria">-</td>
<td id="printB1">-</td>
<td id="printB2">-</td>
<td id="printB3">-</td>
<td id="printB4">-</td>
<td id="printMedia2">-</td>
<td id="printSituacao">-</td>
</tr>
</tbody>
</table>
</div>
</main>
<script>
// Tema dark
mudarCor.addEventListener('click', function() {
document.body.classList.toggle('escuro');
const containers = document.querySelectorAll('.container');
containers.forEach(function(container) {
container.classList.toggle('bg-dark-container');
});
const inputs = document.querySelectorAll('input')
inputs.forEach(function(input) {
input.classList.toggle('inputs')
})
const selects = document.querySelectorAll('select')
selects.forEach(function(select) {
select.classList.toggle('inputs')
})
const optins = document.querySelectorAll('option')
optins.forEach(function(option) {
option.classList.toggle('escuro')
})
});
function clicarBTN(calcular) {
const nomeValor = document.getElementById('nome').value
const serieValor = document.getElementById('serie').value
const materiaValor = document.getElementById('materia').value
// Váriaveis para pegar valores do bimestre
const b1 = parseFloat(document.getElementById('bimestre1').value)
const b2 = parseFloat(document.getElementById('bimestre2').value)
const b3 = parseFloat(document.getElementById('bimestre3').value)
const b4 = parseFloat(document.getElementById('bimestre4').value)
// Calculo da média
const media = (b1 + b2 + b3 + b4) / 4
if (nomeValor.length < 1 || serieValor === '' || materiaValor === '' || b1.toString().length === 3 || b2.toString().length === 3 || b3.toString().length === 3 || b4.toString().length === 3 ){
// Não manda os dados para a tabela
// Função para exibir o modal
var modal = document.getElementById("modal");
modal.style.right = "4%";
var bgModal = document.getElementById('bg-modal')
bgModal.style.display = ""
// Caso clicar no bgModal fechar
bgModal.addEventListener('click', function() {
modal.style.right = "-300px";
bgModal.style.display = "none";
})
setTimeout(function () {
modal.style.right = "-300px";
bgModal.style.display = "none";
}, 5500);
} else {
if (calcular == 1 && media > 7) { // Caso seja maior de 7
document.getElementById('printMedia1').innerHTML = media.toFixed(1)
document.getElementById('printMedia2').innerHTML = media.toFixed(1)
document.getElementById('printSituacao').innerHTML = "Aprovado"
document.getElementById('printNome').innerHTML = nomeValor
document.getElementById('printSerie').innerHTML = serieValor
document.getElementById('printMateria').innerHTML = materiaValor
document.getElementById('printB1').innerHTML = b1
document.getElementById('printB2').innerHTML = b2
document.getElementById('printB3').innerHTML = b3
document.getElementById('printB4').innerHTML = b4
// document.getElementById("printMedia1").style.color = "#000"
} else { // Caso não seja maior que 7
document.getElementById('printMedia1').innerHTML = media.toFixed(1)
document.getElementById('printMedia2').innerHTML = media.toFixed(1)
document.getElementById('printSituacao').innerHTML = "Reprovado"
document.getElementById('printNome').innerHTML = nomeValor
document.getElementById('printSerie').innerHTML = serieValor
document.getElementById('printMateria').innerHTML = materiaValor
document.getElementById('printB1').innerHTML = b1
document.getElementById('printB2').innerHTML = b2
document.getElementById('printB3').innerHTML = b3
document.getElementById('printB4').innerHTML = b4
// document.getElementById("printMedia1").style.color = "#000"
}
}
}
</script>
</body>
</html>