Browse Source

improve javascript in manage locations page to include actual links

master
Craig Stewart 3 months ago
parent
commit
8e0a7f3de7
1 changed files with 19 additions and 3 deletions
  1. +19
    -3
      managelocations.html

+ 19
- 3
managelocations.html View File

@@ -12,9 +12,25 @@ function createItem() {
case 200:
document.getElementById("shared").innerHTML = "New Location Item Created";
var details = JSON.parse(this.response);
document.getElementById("fetch").innerHTML = "Get location from " + window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/getlocation.html?id=" + details.id + "&key=" + details.key;
document.getElementById("send").innerHTML = "Send link " + window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/setlocation.html?id=" + details.id + "&key=" + details.key + " to person whose location you want";
window.open(window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + "/getlocation.html?id=" + details.id + "&key=" + details.key);
if ( ( window.location.protocol == "http:" && window.location.port == 80 ) || ( window.location.protocol == "https:" && window.location.port == 443 ) ) {
var link_domain = window.location.protocol + "//" + window.location.hostname;
} else {
var link_domain = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port;
}
document.getElementById("fetch").appendChild(document.createTextNode("Get location from "));
a = document.createElement('a');
a.setAttribute("href", link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
a.setAttribute("title", "Get Location");
a.appendChild(document.createTextNode(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key));
document.getElementById("fetch").appendChild(a);
document.getElementById("send").appendChild(document.createTextNode("Send this link "));
a = document.createElement('a');
a.setAttribute("href", link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key);
a.setAttribute("title", "Share link to set location");
a.appendChild(document.createTextNode(link_domain + "/setlocation.html?id=" + details.id + "&key=" + details.key));
document.getElementById("send").appendChild(a);
document.getElementById("send").appendChild(document.createTextNode(" to the person whose location you want"));
window.open(link_domain + "/getlocation.html?id=" + details.id + "&key=" + details.key);
break;
default:
document.getElementById("shared").innerHTML = "There was a problem";

Loading…
Cancel
Save