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.

62 lines
2.9 KiB

  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. if ( ( window.location.protocol == "http:" && window.location.port == 80 ) || ( window.location.protocol == "https:" && window.location.port == 443 ) || ( window.location.port == "" ) ) {
  12. var link_domain = window.location.protocol + "//" + window.location.hostname;
  13. } else {
  14. var link_domain = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
  15. }
  16. switch ( this.status ) {
  17. case 200:
  18. console.log(this.responseURL);
  19. if ( this.responseURL == link_domain + "/api/createitem" ) {
  20. document.getElementById("shared").innerHTML = "New Location Item Created";
  21. var details = JSON.parse(this.response);
  22. while (document.getElementById("fetch").firstChild) {
  23. document.getElementById("fetch").removeChild(document.getElementById("fetch").firstChild);
  24. }
  25. document.getElementById("fetch").appendChild(document.createTextNode("Get location from "));
  26. a = document.createElement('a');
  27. a.setAttribute("href", link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
  28. a.setAttribute("title", "Get Location");
  29. a.appendChild(document.createTextNode(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key));
  30. document.getElementById("fetch").appendChild(a);
  31. while (document.getElementById("send").firstChild) {
  32. document.getElementById("send").removeChild(document.getElementById("send").firstChild);
  33. }
  34. document.getElementById("send").appendChild(document.createTextNode("Send this link "));
  35. a = document.createElement('a');
  36. a.setAttribute("href", link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key);
  37. a.setAttribute("title", "Share link to set location");
  38. a.appendChild(document.createTextNode(link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key));
  39. document.getElementById("send").appendChild(a);
  40. document.getElementById("send").appendChild(document.createTextNode(" to the person whose location you want"));
  41. window.open(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
  42. } else {
  43. document.getElementById("shared").innerHTML = "There was a problem";
  44. setTimeout(window.location.reload(true), 5000);
  45. }
  46. break;
  47. default:
  48. document.getElementById("shared").innerHTML = "There was a problem";
  49. setTimeout(createItem, 5000);
  50. }
  51. };
  52. }
  53. </script>
  54. </head>
  55. <body>
  56. <button onclick="createItem()">Create new location item</button>
  57. <p id="shared"></p>
  58. <p id="fetch"></p>
  59. <p id="send"></p>
  60. </body>
  61. </html>