diff --git a/www/assets/js/account.js b/www/assets/js/account.js index c780697..eb39006 100644 --- a/www/assets/js/account.js +++ b/www/assets/js/account.js @@ -223,12 +223,8 @@ $("body").on("click", "#updateAccountBtn", function () { }); $("body").on("click", "#connectExistingAccountBtn", function () { - app.dialog.prompt("Enter your phone number or account number:", "Connect Your Account", function (val) { - var phone = val.replace(/\D/g, ''); - if (phone.length < 10) { - app.dialog.alert("Please enter a full 10-digit phone number.", "Oops!"); - return; - } + app.dialog.prompt("Enter your account number:", "Connect Your Account", function (val) { + var accountnumber = val.replace(/\D/g, ''); setStorage("accountnumber", accountnumber); router.refreshPage(); }, function (cancel) { diff --git a/www/assets/js/pickup.js b/www/assets/js/pickup.js new file mode 100644 index 0000000..72c4750 --- /dev/null +++ b/www/assets/js/pickup.js @@ -0,0 +1,47 @@ +/* + * 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/. + */ + + +function requestPickup() { + if (isNaN($("#pickupRequestForm #packagecount").val())) { + app.dialog.alert("Tell us how many packages you're sending so we'll know if we miss any.", "Whoops!"); + return; + } + if ($("#pickupRequestForm #streetaddress").val() == "") { + app.dialog.alert("We need an address to get the packages from. Don't have one? Find your location on fixphrase.com and use that.", "Whoops!"); + return; + } + if ($("#pickupRequestForm #packagelocation").val() == "" && $("#pickupRequestForm #instructions").val() == "") { + app.dialog.alert("Give us some instructions so we know how to find your packages.", "Whoops!"); + return; + } + + var instructions = ""; + instructions = $("#pickupRequestForm #packagelocation").val(); + instructions += " " + $("#pickupRequestForm #instructions").val(); + + setStorage("lastpickupaddress", $("#pickupRequestForm #streetaddress").val()); + setStorage("lastpickupzipcode", $("#pickupRequestForm #zipcode").val()); + + app.dialog.preloader("Requesting Pickup..."); + apirequest(SETTINGS.apis.requestpickup, { + accountnumber: getStorage("accountnumber"), + accountkey: getStorage("accountkey"), + count: $("#pickupRequestForm #packagecount").val(), + address: $("#pickupRequestForm #streetaddress").val() + " " + $("#pickupRequestForm #zipcode").val(), + instructions: instructions + }, function (success) { + app.dialog.close(); + if (success.status == "OK") { + app.dialog.alert(success.msg, "Pickup Requested!"); + } else { + app.dialog.alert(success.msg, "Error"); + } + }, function (error) { + app.dialog.close(); + app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error"); + }, "POST"); +} \ No newline at end of file diff --git a/www/index.html b/www/index.html index 4fe479a..d1d5de4 100644 --- a/www/index.html +++ b/www/index.html @@ -55,6 +55,7 @@ + diff --git a/www/pages/account.html b/www/pages/account.html index 05e6f57..2237def 100644 --- a/www/pages/account.html +++ b/www/pages/account.html @@ -32,7 +32,7 @@