|
|
|
@ -148,7 +148,7 @@ function addPackage(address, latitude, longitude, type, callback) {
|
|
|
|
|
packageID: packageID
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addAutofillEntry(address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -234,30 +234,59 @@ function countPackages() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addPackageByAddress(address, citystate, type, callback) {
|
|
|
|
|
$.getJSON(SETTINGS.geocodeapi, {
|
|
|
|
|
address: address + " " + citystate
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
|
if (resp.accuracy.ok) {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
var requestfinished = false;
|
|
|
|
|
var searchingdialogopen = false;
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: SETTINGS.geocodeapi,
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
data: {
|
|
|
|
|
address: address + " " + citystate
|
|
|
|
|
},
|
|
|
|
|
timeout: 15 * 1000,
|
|
|
|
|
success: function (resp) {
|
|
|
|
|
if (searchingdialogopen) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
searchingdialogopen = false;
|
|
|
|
|
}
|
|
|
|
|
requestfinished = true;
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
|
if (resp.accuracy.ok) {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
} else {
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.confirm(
|
|
|
|
|
"The address \"" + address + "\" couldn't be reliably located. Add it anyways?",
|
|
|
|
|
"Accuracy Warning",
|
|
|
|
|
function (ok) {
|
|
|
|
|
if (resp.address.street == "") {
|
|
|
|
|
addPackage(address, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
} else {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.confirm(
|
|
|
|
|
"The address \"" + address + "\" couldn't be reliably located. Add it anyways?",
|
|
|
|
|
"Accuracy Warning",
|
|
|
|
|
function (ok) {
|
|
|
|
|
if (resp.address.street == "") {
|
|
|
|
|
addPackage(address, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
} else {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1], type, callback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
app.dialog.alert(resp.message, "Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
},
|
|
|
|
|
error: function (jqXHR, status, errorThrown) {
|
|
|
|
|
if (searchingdialogopen) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
searchingdialogopen = false;
|
|
|
|
|
}
|
|
|
|
|
requestfinished = true;
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.alert(resp.message, "Error");
|
|
|
|
|
app.dialog.alert("There was a network issue while finding the address. Please try adding the item again.", "Error");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Open a loading message if there's a delay finding the address
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
if (!requestfinished) {
|
|
|
|
|
app.dialog.preloader("Searching for address...");
|
|
|
|
|
searchingdialogopen = true;
|
|
|
|
|
}
|
|
|
|
|
}, 750);
|
|
|
|
|
}
|