51 lines
1.7 KiB
JavaScript
Raw Normal View History

/*
2019-09-11 20:55:07 -06:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$("#addpackagebtn").click(function () {
if ($("input[name=number]").val().trim() == "") {
playSound("error");
app.toast.show({
text: "Please fill in a street number.",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 10
});
return;
}
if ($("input[name=street]").val().trim() == "") {
playSound("error");
app.toast.show({
text: "Please fill in a street name.",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 10
});
return;
}
if ($("input[name=citystate]").val().trim() == "") {
playSound("error");
app.toast.show({
text: "Please fill in a city and state.",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 10
});
return;
}
2019-08-23 20:32:14 -06:00
// Save city/state if changed
if (localStorage.getItem("citystate") != $("input[name=citystate]").val().trim()) {
localStorage.setItem("citystate", $("input[name=citystate]").val().trim());
}
var address = ($("input[name=number]").val() + " " + $("input[name=street]").val()).toUpperCase();
addPackageByAddress(address, $("input[name=citystate]").val().toUpperCase());
});
2019-08-23 20:32:14 -06:00
// Restore user's last entered city/state combo
if (localStorage.getItem("citystate") != null) {
$("input[name=citystate]").val(localStorage.getItem("citystate"));
}