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 () { | $("#addpackagebtn").click(function () { | ||||||
|     if ($("input[name=number]").val().trim() == "") { |     if ($("input[name=number]").val().trim() == "") { | ||||||
|         playSound("error"); |         playSound("error"); | ||||||
| @ -41,27 +65,23 @@ $("#addpackagebtn").click(function () { | |||||||
|         address: address + " " + $("input[name=citystate]").val().toUpperCase() |         address: address + " " + $("input[name=citystate]").val().toUpperCase() | ||||||
|     }, function (resp) { |     }, function (resp) { | ||||||
|         if (resp.status == "OK") { |         if (resp.status == "OK") { | ||||||
|             packages.push({ |             if (resp.accuracy.ok) { | ||||||
|                 "address": address, |                 addPackage(resp.address.street, resp.coords[0], resp.coords[1]); | ||||||
|                 "coords": [ |             } else { | ||||||
|                     resp.coords[0], |                 playSound("error"); | ||||||
|                     resp.coords[1] |                 app.dialog.confirm( | ||||||
|                 ] |                         "The address \"" + address + "\" couldn't be reliably located. Add it anyways?", | ||||||
|             }); |                         "Accuracy Warning", | ||||||
|             localStorage.setItem("packages", JSON.stringify(packages)); |                         function (ok) { | ||||||
| 
 |                             if (resp.address.street == "") { | ||||||
|             playSound("ok"); |                                 addPackage(address, resp.coords[0], resp.coords[1]); | ||||||
| 
 |                             } else { | ||||||
|             app.toast.show({ |                                 addPackage(resp.address.street, resp.coords[0], resp.coords[1]); | ||||||
|                 text: 'Package Added!<br><span style="font-size: 80%;">' + address + "</span>", |                             } | ||||||
|                 position: "bottom", |                         } | ||||||
|                 destroyOnClose: true, |                 ); | ||||||
|                 closeTimeout: 1000 * 2 |  | ||||||
|             }); |  | ||||||
| 
 |  | ||||||
|             if (map != null) { |  | ||||||
|                 map.updatePackageLayer(packages); |  | ||||||
|             } |             } | ||||||
|  | 
 | ||||||
|         } else { |         } else { | ||||||
|             playSound("error"); |             playSound("error"); | ||||||
|             app.dialog.alert(resp.message, "Error"); |             app.dialog.alert(resp.message, "Error"); | ||||||
|  | |||||||
| @ -20,9 +20,7 @@ | |||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
|     var geocodeapi = "https://apis.netsyms.net/packagenotice/geocode.php"; |     var geocodeapi = "https://apis.netsyms.net/packagehelper/geocode.php"; | ||||||
| 
 |  | ||||||
|     var packages = []; |  | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <script src="node_modules/framework7/js/framework7.bundle.min.js"></script> | <script src="node_modules/framework7/js/framework7.bundle.min.js"></script> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user