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.

50 lines
2.2KB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Location</title>
  5. <script>
  6. function createItem() {
  7. var post = new XMLHttpRequest();
  8. post.open("GET", "/api/createitem", true);
  9. post.send();
  10. post.onload = function () {
  11. switch ( this.status ) {
  12. case 200:
  13. document.getElementById("shared").innerHTML = "New Location Item Created";
  14. var details = JSON.parse(this.response);
  15. if ( ( window.location.protocol == "http:" && window.location.port == 80 ) || ( window.location.protocol == "https:" && window.location.port == 443 ) ) {
  16. var link_domain = window.location.protocol + "//" + window.location.hostname;
  17. } else {
  18. var link_domain = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
  19. }
  20. document.getElementById("fetch").appendChild(document.createTextNode("Get location from "));
  21. a = document.createElement('a');
  22. a.setAttribute("href", link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
  23. a.setAttribute("title", "Get Location");
  24. a.appendChild(document.createTextNode(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key));
  25. document.getElementById("fetch").appendChild(a);
  26. document.getElementById("send").appendChild(document.createTextNode("Send this link "));
  27. a = document.createElement('a');
  28. a.setAttribute("href", link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key);
  29. a.setAttribute("title", "Share link to set location");
  30. a.appendChild(document.createTextNode(link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key));
  31. document.getElementById("send").appendChild(a);
  32. document.getElementById("send").appendChild(document.createTextNode(" to the person whose location you want"));
  33. window.open(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
  34. break;
  35. default:
  36. document.getElementById("shared").innerHTML = "There was a problem";
  37. setTimeout(createItem, 5000);
  38. }
  39. };
  40. }
  41. </script>
  42. </head>
  43. <body>
  44. <button onclick="createItem()">Create new location item</button>
  45. <p id="shared"></p>
  46. <p id="fetch"></p>
  47. <p id="send"></p>
  48. </body>
  49. </html>