Warn user if package address isn't real
This commit is contained in:
parent
246f3a4fad
commit
e70caae70c
@ -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");
|
||||
|
@ -20,9 +20,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var geocodeapi = "https://apis.netsyms.net/packagenotice/geocode.php";
|
||||
|
||||
var packages = [];
|
||||
var geocodeapi = "https://apis.netsyms.net/packagehelper/geocode.php";
|
||||
</script>
|
||||
|
||||
<script src="node_modules/framework7/js/framework7.bundle.min.js"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user