-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
80 lines (75 loc) · 2.26 KB
/
Copy pathindex.html
File metadata and controls
80 lines (75 loc) · 2.26 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
<!--<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Emergency App</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
button { font-size: 2em; padding: 20px 40px; background: red; color: white; border: none; border-radius: 10px; }
#status { margin-top: 20px; color: green; }
</style>
</head>
<body>
<h1>Emergency Panic Button</h1>
<button id="panicBtn">PANIC!</button>
<div id="status"></div>
<script>
document.getElementById('panicBtn').onclick = async function() {
document.getElementById('status').textContent = "Sending emergency alert...";
// Get geolocation
if (!navigator.geolocation) {
alert('Geolocation is not supported by your browser');
return;
}
navigator.geolocation.getCurrentPosition(async (pos) => {
const { latitude, longitude } = pos.coords;
try {
const res = await fetch('/api/emergency', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ latitude, longitude })
});
if (res.ok) {
document.getElementById('status').textContent = "Alert sent to contacts & authorities!";
} else {
document.getElementById('status').textContent = "Failed to send alert.";
}
} catch (e) {
document.getElementById('status').textContent = "Error sending alert.";
}
}, (err) => {
alert("Unable to get location: " + err.message);
});
}
</script>
</body
</html>-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Emergency App</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Emergency Panic Button</h1>
<form id="userForm">
<label>
Name:
<input type="text" id="userName" required>
</label><br>
<label>
Phone:
<input type="tel" id="userPhone" required>
</label><br>
<label>
Medical Info (optional):
<input type="text" id="userMedical">
</label><br>
<button type="submit" id="saveBtn">Save Details</button>
</form>
<button id="panicBtn" disabled>PANIC!</button>
<div id="status"></div>
<script src="app.js"></script>
</body>
</html>