Skip to content

Instantly share code, notes, and snippets.

@rishabhAjay
Last active March 31, 2021 07:43
Show Gist options
  • Save rishabhAjay/9e4ac42bb28f4026567aaacfefba735f to your computer and use it in GitHub Desktop.
Save rishabhAjay/9e4ac42bb28f4026567aaacfefba735f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<form action="/check" method="POST">
<div class="mainBody">
<h2>LOCATION TRACKER</h2>
<h6><%= checkState %></h6>
<div class="mb-3">
<input type="text" class="form-control" name="phone" placeholder="Phone(starts with +17)" <%=fromState%>>
</div>
<div class="mb-3">
<input type="text" class="form-control" name="phone2" placeholder="Phone(starts with +91)"<%=toState%>>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="toggle" value="on" <%=onState%>>
<label class="form-check-label" for="flexRadioDefault1">
Switch Tracker ON
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="toggle" value="off" <%=offState%>>
<label class="form-check-label" for="flexRadioDefault2">
Switch Tracker OFF
</label>
</div>
<input type="hidden" id = "lat" name = "lat" value="">
<input type="hidden" id = "long" name = "long" value="">
<button class="btn btn-primary btn-sm" type="submit">GO</button>
</div>
</form>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script>
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
document.getElementById('lat').value = crd.latitude;
document.getElementById('long').value = crd.longitude;
console.log(crd.latitude, crd.longitude);
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
navigator.geolocation.getCurrentPosition(success, error, options);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment