diff --git a/www/assets/js/rates.js b/www/assets/js/rates.js new file mode 100644 index 0000000..c779580 --- /dev/null +++ b/www/assets/js/rates.js @@ -0,0 +1,87 @@ +/* + * 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 updateRateForm() { + $("#itemweight").css("display", "none"); + $("#itemsize").css("display", "none"); + $("#itemweightlbs").css("display", ""); + switch ($(this).val()) { + case "Card": + $("#itemweight").css("display", "none"); + $("#weightLbs").val("0"); + $("#weightOz").val("0"); + break; + case "Letter": + $("#itemweight").css("display", ""); + $("#itemweightlbs").css("display", "none"); + $("#weightLbs").val("0"); + break; + case "Flat": + $("#itemweight").css("display", ""); + break; + case "Parcel": + $("#itemweight").css("display", ""); + $("#itemsize").css("display", ""); + break; + case "RegionalRateBoxA": + case "RegionalRateBoxB": + $("#itemweight").css("display", ""); + break; + default: + break; + } +} + +$("#app").on("click change", "#itemType", updateRateForm); + +function initRateForm() { + $("#itemType").val(""); + updateRateForm(); +} + +function getRates() { + app.dialog.preloader("Loading..."); + + apirequest( + SETTINGS.apis.rates, + { + from_street1: $("#from_street1").val(), + from_zip: $("#from_zip").val(), + to_street1: $("#to_street1").val(), + to_zip: $("#to_zip").val(), + itemType: $("#itemType").val(), + length: $("input[name=length]").val(), + width: $("input[name=width]").val(), + height: $("input[name=height]").val(), + weightLbs: $("#weightLbs").val(), + weightOz: $("#weightOz").val() + }, + function (resp) { + app.dialog.close(); + if (resp.status == "OK") { + if (resp.rates.length == 0) { + resp.rates = false; + } + if (resp.hints.length == 0) { + resp.hints = false; + } + router.navigate("/rateresult", { + context: resp + }); + } else { + app.dialog.alert(resp.message, "Error"); + } + }, + function (xhr) { + app.dialog.close(); + var error = $.parseJSON(xhr.responseText); + if (error && typeof error.msg != 'undefined') { + app.dialog.alert(error.msg, "Error"); + } else { + app.dialog.alert("A server or network error occurred.", "Error"); + } + }, "GET"); +} \ No newline at end of file diff --git a/www/index.html b/www/index.html index a39de38..293fe26 100644 --- a/www/index.html +++ b/www/index.html @@ -46,6 +46,7 @@ + \ No newline at end of file diff --git a/www/pages/rateresult.html b/www/pages/rateresult.html new file mode 100644 index 0000000..08ee8f1 --- /dev/null +++ b/www/pages/rateresult.html @@ -0,0 +1,162 @@ + + +
+ + + + +
+
+
+
+
    +
  • From:
  • + {{#with from}} +
  • +
    +
    +
    + {{street}} +
    +
    +
    +
  • +
  • +
    +
    +
    + {{citystatezip}} +
    +
    +
    +
  • + {{/with}} +
  • To:
  • + {{#with to}} +
  • +
    +
    +
    + {{street}} +
    +
    +
    +
  • +
  • +
    +
    +
    + {{citystatezip}} +
    +
    +
    +
  • + {{/with}} +
  • Item:
  • +
  • +
    +
    +
    + {{weight}} +
    +
    +
    +
  • +
  • +
    +
    +
    + {{size}} +
    +
    +
    +
  • +
  • Rates:
  • + {{#if rates}} +
  • +
    +
    +
    +
    + Service +
    +
    + Delivery Estimate +
    +
    + Price +
    +
    +
    +
    +
  • + {{#each rates}} +
  • +
    +
    +
    +
    + {{carrier}} {{service}} +
    +
    + {{date}} +
    +
    + ${{rate}} +
    +
    +
    +
    +
  • + {{/each}} + {{else}} +
  • +
    +
    +
    +
    + We could find no available shipping options based on the information you provided. +
    +
    +
    +
    +
  • + {{/if}} + {{#if hints}} +
  • Tip{{#js_if "this.hints.length > 1"}}s{{/js_if}}:
  • + {{#each hints}} +
  • +
    +
    +
    +
    + {{this}} +
    +
    +
    +
    +
  • + {{/each}} + {{/if}} +
+
+
+
+
+ Rates provided do not include pickup fees. This tool provides shipping cost estimates; actual prices, available service options, and delivery dates shown are not guaranteed to be actually available when you ship your item. Your item's contents may not be eligible for certain services. +
+
+ +
\ No newline at end of file diff --git a/www/pages/rates.html b/www/pages/rates.html new file mode 100644 index 0000000..d30ae15 --- /dev/null +++ b/www/pages/rates.html @@ -0,0 +1,149 @@ + + +
+ + + + +
+
+
+
+
+
+
    +
  • From:
  • +
  • +
    +
    Street Address
    +
    + + +
    +
    +
  • +
  • +
    +
    ZIP Code
    +
    + + +
    +
    +
  • +
  • To:
  • +
  • +
    +
    Street Address
    +
    + + +
    +
    +
  • +
  • +
    +
    ZIP Code
    +
    + + +
    +
    +
  • +
  • Item Type:
  • +
  • +
    +
    + +
    +
    +
  • +
+ + +
+
+
Get Rates
+
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/www/routes.js b/www/routes.js index 6075bf1..c352bc9 100644 --- a/www/routes.js +++ b/www/routes.js @@ -25,7 +25,7 @@ var routes = [ icon: "fad fa-search" }, { - title: "Check Rates", + title: "Get Rates", href: "/rates", icon: "fad fa-calculator" } @@ -60,6 +60,21 @@ var routes = [ } } }, + { + path: '/rates', + url: './pages/rates.html', + name: 'rates', + on: { + pageAfterIn: function () { + initRateForm(); + } + } + }, + { + path: '/rateresult', + name: 'rateresult', + templateUrl: './pages/rateresult.html' + }, { path: '/addresscode', name: 'addresscode', diff --git a/www/settings.js b/www/settings.js index b5eb127..d91e932 100644 --- a/www/settings.js +++ b/www/settings.js @@ -6,7 +6,8 @@ var SETTINGS = { apis: { - track: "https://helena.express/tracker/api.php" + track: "https://helena.express/tracker/api.php", + rates: "https://helena.express/rateapi.php" }, appointmenturl: "https://appointments.netsyms.com/index.php?service=19&hlnexp=1&embed=1&only=1", branding: {