-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
144 lines (134 loc) · 5.38 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dental Checkup Information</title>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 10px;
text-align: left;
}
</style>
</head>
<body>
<h1>Dental Checkup Information</h1>
<table>
<thead>
<tr>
<th>Grade</th>
<th>Age</th>
<th>Gender</th>
<th>School name and place</th>
<th>Guardian/Parents name</th>
<th>Chief complaint</th>
<th>Medical history</th>
<th>Medication history</th>
<th>Previous dental visit</th>
<th>Habits</th>
<th>Brushing habit</th>
<th>Bleeding gums</th>
<th>Early Childhood caries</th>
<th>Decayed</th>
<th>Fractured teeth</th>
<th>Preshedding mobility</th>
<th>Malocclusion</th>
<th>Does the child have pain, swelling or abscess? (Urgent care need)</th>
<th>Any other finding</th>
<th>Treatment plan</th>
</tr>
</thead>
<tbody id="table-body">
<tr id="data-row">
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
</tr>
</tbody>
</table>
<button id="submit-button">Submit</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
const url = 'http://localhost:5000/answer';
const audioFilePath = 'audio01.wav';
fetch(audioFilePath)
.then(response => response.blob())
.then(blob => {
const formData = new FormData();
formData.append('file', blob, audioFilePath);
return fetch(url, {
method: 'POST',
body: formData
});
})
.then(response => response.json())
.then(data => {
if (Array.isArray(data)) {
const answers = data[0]; // Assuming only one row of data is returned
const dataRow = document.getElementById('data-row');
const cells = dataRow.getElementsByTagName('td');
for (let i = 0; i < answers.length; i++) {
cells[i].textContent = answers[i]; // Fill the table cells with data
}
} else {
console.error('No data found in server response.');
}
})
.catch(error => {
console.error('Error:', error);
alert(`Request failed: ${error.message}`);
});
const submitButton = document.getElementById('submit-button');
submitButton.addEventListener('click', () => {
const dataRow = document.getElementById('data-row');
const cells = dataRow.getElementsByTagName('td');
// Convert table cell data to an array
const updatedData = [];
for (let cell of cells) {
updatedData.push(cell.textContent.trim());
}
// Prepare the data to be sent back to the server
const formData = new FormData();
formData.append('answers', JSON.stringify(updatedData));
fetch(url, {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(data => {
alert(data); // Display response message
// Disable contenteditable after saving
for (let cell of cells) {
cell.contentEditable = false;
}
})
.catch(error => {
console.error('Error:', error);
alert(`Request failed: ${error.message}`);
});
});
});
</script>
</body>
</html>