-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_test.html
213 lines (186 loc) · 7.54 KB
/
index_test.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
<!DOCTYPE html>
<html>
<head>
<!-- This is the minified production version of Parse JS -->
<script type="text/javascript" src="https://npmcdn.com/parse/dist/parse.min.js"></script>
<title>Frações</title>
<style>
.container {
font-size: 40px;
font-family: Arial, sans-serif;
position: relative;
}
.number {
display: inline-block;
margin-right: 10px; /* Espaço entre o número e o sinal de "+" */
}
.plus {
display: inline-block;
margin-right: 10px; /* Espaço entre o sinal de "+" e o sinal de "=" */
}
.divide {
display: inline-block;
margin-right: 10px; /* Espaço entre o sinal de "+" e o sinal de "=" */
position: relative;
top: 2px; /* Ajuste vertical para alinhar a chave de divisão */
}
.equals {
display: inline-block;
font-size: 20px; /* Tamanho da fonte do sinal de "=" */
}
.input-box {
width: 40px;
height: 40px;
border: 2px solid red; /* Adiciona uma borda vermelha */
box-sizing: border-box; /* Inclui a borda na largura e altura total */
text-align: center; /* Centraliza o texto na caixa de texto */
font-size: 20px; /* Tamanho da fonte da caixa de texto */
position: relative;
top: -4px; /* Suba a caixa de texto em 4 pixels */
}
.finalizar {
display: block;
margin-top: 10px; /* Espaço acima do botão Finalizar */
}
.fraction {
display: inline-block;
text-align: center;
vertical-align: middle; /* Alinha verticalmente ao centro */
}
.fraction .numerator {
display: block;
}
.fraction .denominator {
display: block;
border-top: 2px solid;
}
</style>
</head>
<body>
<h1>Turma 5º A</h1>
<input id="nome" type="text" placeholder="Nome Completo"/>
<input id="data" type="text" placeholder="Data (DD/MM/AAAA)"/>
<input id="serie" type="text" placeholder="Série"/>
<div class="container">
<span class="number">5</span>
<span class="plus">+</span>
<input class="input-box" type="text" maxlength="1">
<span class="equals">=</span>
</div>
<div class="container">
<span class="number">8</span>
<span class="plus">-</span>
<input class="input-box" type="text" maxlength="1">
<span class="equals">=</span>
</div>
<div class="container">
<span class="number">5</span>
<span class="plus">-</span>
<span class="input-value">7</span>
<span class="equals">=</span>
<input class="input-box"type="text" maxlength="1">
</div>
<div class="container">
<div class="fraction">
<span class="numerator">1</span>
<span class="denominator">8</span>
</div>
<span class="plus">+</span>
<div class="fraction">
<span class="numerator">5</span>
<span class="denominator">7</span>
</div>
<span class="equals">=</span>
<input class="input-box" type="text" maxlength="1">
</div>
<div class="container">
<div class="fraction">
<span class="numerator">9</span>
</div>
<span class="divide">÷</span>
<input class="input-box" type="text" maxlength="1">
<span class="equals">=</span>
</div>
<button class="finalizar">Finalizar</button>
<script>
document.querySelector('.finalizar').addEventListener('click', function() {
var respostas = document.querySelectorAll('.input-box');
var valores = Array.from(respostas).map(function(element, index) {
return {
numero: index + 1,
resposta: element.value
};
});
var nome = document.getElementById('nome').value;
var data = document.getElementById('data').value;
var serie = document.getElementById('serie').value;
var nomeDaLicao = document.title; // Obtém o nome da lição da tag <title>
// Crie uma instância da classe Logs
var Logs = Parse.Object.extend("Logs");
var logs = new Logs();
// Defina as propriedades da instância
logs.set("respostas", valores);
logs.set("nomeCompleto", nome);
logs.set("data", data);
logs.set("serie", serie);
logs.set("nomeDaLicao", nomeDaLicao); // Salva o nome da lição
// Salve o objeto no banco de dados do Back4App
logs.save().then(function(logs) {
// Sucesso ao salvar o objeto
console.log("Respostas salvas com sucesso!");
// Exiba uma mensagem ao usuário
alert("Respostas salvas com sucesso!");
}).catch(function(error) {
// Erro ao salvar o objeto
console.log("Erro ao salvar as respostas: " + error.message);
// Exiba uma mensagem de erro ao usuário
alert("Erro ao salvar as respostas: " + error.message);
});
});
// Auto completar a barra no campo de data
document.getElementById('data').addEventListener('input', function() {
var inputValue = this.value;
var inputLength = inputValue.length;
if (inputLength === 2 || inputLength === 5) {
inputValue += '/';
this.value = inputValue;
}
if (inputLength >= 10) {
// Limita a quantidade de dígitos após a segunda e última barra
this.value = inputValue.substring(0, 10);
}
});
</script>
</body>
</html>
<script>
// Initialize Parse
Parse.initialize("1ouGZGBYP2FIyamYbQCKmvDy0Pw5zhTFfC0KUgnX", "a7ye1eR4aTFq4EjdbabvdtTuvkr5nYy9lSevygoQ"); //PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY
Parse.serverURL = "https://parseapi.back4app.com/"; // Create a new User
async function createParseUser() {
// Creates a new Parse "User" object, which is created by default in your Parse app
let user = new Parse.User();
// Set the input values to the new "User" object
user.set("username", document.getElementById("username").value);
user.set("email", document.getElementById("email").value);
user.set("password", document.getElementById("password").value);
try {
// Call the save method, which returns the saved object if successful
user = await user.save();
if (user !== null) {
// Notify the success by getting the attributes from the "User" object, by using the get method (the id attribute needs to be accessed directly, though)
alert(
`New object created with success! ObjectId: ${
user.id
}, ${user.get("username")}`
);
}
} catch (error) {
alert(`Error: ${error.message}`);
}
}
// Add on click listener to call the create parse user function
document.getElementById("createButton").addEventListener("click", async function () {
createParseUser();
});
</script>