An app written in GoLang to find people using location services on smartphones.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Location</title>
  5. <script>
  6. function getLocation() {
  7. if (navigator.geolocation) {
  8. coords = navigator.geolocation.getCurrentPosition(showLocation);
  9. } else {
  10. document.getElementById("location").innerHTML = "Geolocation is not supported by this browser.";
  11. }
  12. }
  13. function showLocation(location) {
  14. var post = new XMLHttpRequest();
  15. post.open("POST", "/api/location", true);
  16. post.send("{\"latitude\": " + location.coords.latitude + ", \"longitude\": " + location.coords.longitude + ", \"id\": \"{{.Id}}\", \"key\": \"{{.Key}}\"}");
  17. post.onload = function () {
  18. if ( this.status == 201 ) {
  19. document.getElementById("shared").innerHTML = "Your Location Has Been Shared";
  20. } else {
  21. document.getElementById("shared").innerHTML = "There was a probelem sharing your location, try refreshing the page"
  22. }
  23. };
  24. document.getElementById("location").innerHTML = "Latitude: " + location.coords.latitude + ", Longitude: " + location.coords.longitude;
  25. }
  26. window.onload = getLocation;
  27. </script>
  28. </head>
  29. <body>
  30. <p id="shared"></p>
  31. <p id="location"></p>
  32. </body>
  33. </html>