-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
27 lines (22 loc) · 880 Bytes
/
script.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
document.getElementById('sendButton').addEventListener('click', function () {
const textInput = document.getElementById('textInput').value;
console.log(textInput);
fetch("http://192.168.1.34:3000/detect", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text: textInput }),
})
.then(response => response.json())
.then(data => {
document.getElementById('textInput').blur();
const responseDiv = document.getElementById('response');
responseDiv.textContent = data.percentage.toString() + '%';
// Show the response and blur the text input box
responseDiv.classList.remove('response-hidden');
})
.catch((error => {
console.error("Error: ", error);
}))
})