-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.js
More file actions
36 lines (36 loc) · 1.36 KB
/
text.js
File metadata and controls
36 lines (36 loc) · 1.36 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
function sendMessages() {
var recipients = ['+91 9836578565', '+91 7439114374', '+91 8777249216'];
for (var i = 0; i < recipients.length; i++) {
client.messages
.create({
body: 'Emergency! Please send help. Nearest police station: ' + nearestPolice,
from: '+15073534760',
to: recipients[i]
})
.then(message => console.log(message.sid));
}
}
document.getElementById('sos-button').addEventListener('click', function() {
// Call the API and send a message to 3 people
});
function callPolice() {
navigator.geolocation.getCurrentPosition(function(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var request = new XMLHttpRequest();
request.open('GET', 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=' + lat + ',' + lng + '&radius=500&type=police&key=YOUR_API_KEY');
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
var nearestPolice = data.results[0].name;
// Call the nearest police station
} else {
console.log('Error');
}
};
request.onerror = function() {
console.log('Error');
};
request.send();
});
}