-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
88 lines (73 loc) · 2.8 KB
/
scripts.js
File metadata and controls
88 lines (73 loc) · 2.8 KB
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
// script.js
document.addEventListener('DOMContentLoaded', function() {
const sosButton = document.getElementById('sosButton');
let clickCount = 0;
let clickTimer = null;
sosButton.addEventListener('click', () => {
clickCount++;
if (clickTimer === null) {
clickTimer = setTimeout(() => {
clickCount = 0;
clickTimer = null;
}, 300);
}
if (clickCount === 2) {
clearTimeout(clickTimer);
clickCount = 0;
clickTimer = null;
// Trigger emergency call
if (confirm('Are you sure you want to make an emergency call?')) {
window.location.href = 'tel:911';
}
}
});
document.getElementById('mobile-menu-button').addEventListener('click', function() {
const mobileMenu = document.getElementById('mobile-menu');
const isExpanded = this.getAttribute('aria-expanded') === 'true';
this.setAttribute('aria-expanded', !isExpanded);
mobileMenu.classList.toggle('hidden');
});
});
// Open the modal when the "Fill Details Manually" button is clicked
document.getElementById('fillDetailsButton').addEventListener('click', function() {
document.getElementById('manualDetailsModal').classList.remove('hidden');
});
// Close the modal when the "Close" button is clicked
document.getElementById('closeModal').addEventListener('click', function() {
document.getElementById('manualDetailsModal').classList.add('hidden');
});
// Handle form submission
document.getElementById('incidentForm').addEventListener('submit', function(event) {
event.preventDefault();
const numPatients = document.getElementById('numPatients').value;
const severity = document.getElementById('severity').value;
const description = document.getElementById('description').value;
// Prepare data to send
const data = {
numPatients: numPatients,
severity: severity,
description: description,
timestamp: new Date().toISOString()
};
// Send data to the server
fetch('/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then(response => {
if (response.ok) {
alert('Incident reported successfully!');
document.getElementById('manualDetailsModal').classList.add('hidden');
document.getElementById('incidentForm').reset();
} else {
alert('Error reporting incident.');
}
})
.catch(error => {
console.error('Error:', error);
alert('Error reporting incident.');
});
});