-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptRegex.js
34 lines (27 loc) · 875 Bytes
/
scriptRegex.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
document.addEventListener('DOMContentLoaded', function(){
const entrada_regex = document.getElementById('regex');
const botao_entrada = document.getElementById('botao_entrada_regex');
botao_entrada.addEventListener('click', function(){
const regex = entrada_regex.value;
enviarER(regex);
});
async function enviarER(regex){
const expressao = {
"expressao":regex
}
try {
const response = await fetch(`${host}/api/automatos/regexToAfn`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(expressao)
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
}catch(error) {
console.error('Erro ao gerar autômato:', error);
}
}
});