|
|
|
@ -5,6 +5,30 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addPackage(address, latitude, longitude) {
|
|
|
|
|
packages.push({
|
|
|
|
|
"address": address,
|
|
|
|
|
"coords": [
|
|
|
|
|
latitude,
|
|
|
|
|
longitude
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
localStorage.setItem("packages", JSON.stringify(packages));
|
|
|
|
|
|
|
|
|
|
playSound("ok");
|
|
|
|
|
|
|
|
|
|
app.toast.show({
|
|
|
|
|
text: 'Package Added!<br><span style="font-size: 80%;">' + address + "</span>",
|
|
|
|
|
position: "bottom",
|
|
|
|
|
destroyOnClose: true,
|
|
|
|
|
closeTimeout: 1000 * 3
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (map != null) {
|
|
|
|
|
map.updatePackageLayer(packages);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("#addpackagebtn").click(function () {
|
|
|
|
|
if ($("input[name=number]").val().trim() == "") {
|
|
|
|
|
playSound("error");
|
|
|
|
@ -41,27 +65,23 @@ $("#addpackagebtn").click(function () {
|
|
|
|
|
address: address + " " + $("input[name=citystate]").val().toUpperCase()
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
|
packages.push({
|
|
|
|
|
"address": address,
|
|
|
|
|
"coords": [
|
|
|
|
|
resp.coords[0],
|
|
|
|
|
resp.coords[1]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
localStorage.setItem("packages", JSON.stringify(packages));
|
|
|
|
|
|
|
|
|
|
playSound("ok");
|
|
|
|
|
|
|
|
|
|
app.toast.show({
|
|
|
|
|
text: 'Package Added!<br><span style="font-size: 80%;">' + address + "</span>",
|
|
|
|
|
position: "bottom",
|
|
|
|
|
destroyOnClose: true,
|
|
|
|
|
closeTimeout: 1000 * 2
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (map != null) {
|
|
|
|
|
map.updatePackageLayer(packages);
|
|
|
|
|
if (resp.accuracy.ok) {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
|
|
|
|
|
} 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]);
|
|
|
|
|
} else {
|
|
|
|
|
addPackage(resp.address.street, resp.coords[0], resp.coords[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
playSound("error");
|
|
|
|
|
app.dialog.alert(resp.message, "Error");
|
|
|
|
|