From b56c8dbe3f295b2f673a6a347eb13963e0c093d8 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 29 Oct 2022 14:17:21 -0600 Subject: [PATCH] Fetch dynamically-updating text from server, add FAQ to money order page --- www/assets/css/app.css | 14 +++++++++++ www/assets/images/mail-trailer.svg | 2 ++ www/assets/js/main.js | 32 +++++++++++++++++++++++++ www/pages/moneyorder.html | 26 ++++++++++++++++++-- www/pages/notary.html | 2 +- www/pages/telegram.html | 2 +- www/pages/trailer.html | 4 ++-- www/routes.js | 38 +++++++++++++++++++++++++++--- www/settings.js | 2 ++ 9 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 www/assets/images/mail-trailer.svg diff --git a/www/assets/css/app.css b/www/assets/css/app.css index 10e14c9..f7e7103 100644 --- a/www/assets/css/app.css +++ b/www/assets/css/app.css @@ -199,4 +199,18 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. max-height: 40vh; max-width: 90%; height: 50rem; +} + +dl { + margin-left: 1rem; + margin-right: 1rem; +} + +dt { + font-weight: 700; +} + +dd { + margin-left: 1rem; + margin-bottom: .5rem; } \ No newline at end of file diff --git a/www/assets/images/mail-trailer.svg b/www/assets/images/mail-trailer.svg new file mode 100644 index 0000000..c701715 --- /dev/null +++ b/www/assets/images/mail-trailer.svg @@ -0,0 +1,2 @@ + + diff --git a/www/assets/js/main.js b/www/assets/js/main.js index 2864fb6..46f48c6 100644 --- a/www/assets/js/main.js +++ b/www/assets/js/main.js @@ -226,6 +226,38 @@ function openStartpageURLArg() { return false; } +/** + * Get the cached dynamic page content if available, else return null (and try to fetch it for next time) + * @param {string} page the page ID + * @returns {string|null} + */ +function getDynamicPageContent(page) { + if (inStorage("dynamiccontent_" + page)) { + return getStorage("dynamiccontent_" + page); + } + apirequest(SETTINGS.apis.dynamicappcontent, {page: page}, function (resp) { + if (resp.status == "OK") { + setStorage("dynamiccontent_" + resp.page, resp.content); + } + }); + return null; +} + +// update dynamic page text cache +setTimeout(function () { + dynamicPages.forEach(function (pageid) { + // Only update if it's been over an hour since last update + if (!inStorage("dynamiccontent-lastupdated_" + pageid) || getStorage("dynamiccontent-lastupdated_" + pageid) < time() - 60 * 60) { + apirequest(SETTINGS.apis.dynamicappcontent, {page: pageid}, function (resp) { + if (resp.status == "OK") { + setStorage("dynamiccontent_" + resp.page, resp.content); + setStorage("dynamiccontent-lastupdated_" + resp.page, time()); + } + }); + } + }); +}, 500); + if (setup) { router.navigate("/home"); } else { diff --git a/www/pages/moneyorder.html b/www/pages/moneyorder.html index 4db76c6..91d70b6 100644 --- a/www/pages/moneyorder.html +++ b/www/pages/moneyorder.html @@ -13,16 +13,38 @@ Back -
Verify Money Order
+
Money Orders
-
+
+
+
+
How do I purchase a money order?
+
You can buy a money order during any notary or shipping appointment. You can also call us to schedule a visit. We’re available where you are and on your schedule.
+ +
How can I pay for my money order?
+
We only accept cash payment for money orders at this time.
+ +
How much does a money order cost?
+
You can send money orders up to $500 with Helena Express for a $3 fee ($6 if by appointment).
+ +
How can a recipient cash a Helena Express money order?
+
Our money orders can be cashed like a check. Just bring it to your bank or any business offering check cashing services.
+
+
+
+
+
+
Verify Money Order
+
+ Enter the serial number from the top-right corner of the money order. +
  • diff --git a/www/pages/notary.html b/www/pages/notary.html index 477d15c..11201a2 100644 --- a/www/pages/notary.html +++ b/www/pages/notary.html @@ -19,7 +19,7 @@
    -
    +
    diff --git a/www/pages/telegram.html b/www/pages/telegram.html index 8d518e6..35ae665 100644 --- a/www/pages/telegram.html +++ b/www/pages/telegram.html @@ -28,7 +28,7 @@
  • -

    +

    Send a telegram with Helena Express for $15. We'll hand-deliver your message to anywhere in Helena, East Helena, Montana City, the Helena Valley, and the hills around Helena.

    diff --git a/www/pages/trailer.html b/www/pages/trailer.html index 1dd7193..5abc500 100644 --- a/www/pages/trailer.html +++ b/www/pages/trailer.html @@ -23,9 +23,9 @@
    - +
    -
    +
    Our Mobile Shipping Center is a specialized trailer equipped to offer mailing, shipping, notarizing, copying, and faxing services. With no pickup or travel fees, it's a good way to save money and skip the line at the post office. diff --git a/www/routes.js b/www/routes.js index 8262ae4..42642bd 100644 --- a/www/routes.js +++ b/www/routes.js @@ -4,6 +4,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +var dynamicPages = [ + "notary", + "telegram", + "trailer", + "moneyorder" +]; var compiledPages = {}; var pagesToCompile = [ "home", @@ -178,7 +184,7 @@ var routes = [ title: "Money Services", href: "/money", icon: "fa-duotone fa-money-bill-wave", - text: "Manage cryptocurrency and verify money orders." + text: "Manage money orders and cryptocurrency." }, { title: "My Account", @@ -235,7 +241,7 @@ var routes = [ content: compiledPages.money({ pages: [ { - title: "Verify Money Order", + title: "Money Orders", href: "/moneyorder", icon: "fa-duotone fa-money-check-dollar", text: "Check and verify a Helena Express money order." @@ -254,13 +260,27 @@ var routes = [ { path: '/moneyorder', content: compiledPages.moneyorder(), - name: 'moneyorder' + name: 'moneyorder', + on: { + pageBeforeIn: function () { + dyncontent = getDynamicPageContent("moneyorder"); + if (dyncontent != null) { + $("#moneyorder-dyncontent").html(dyncontent); + } + } + } }, { path: '/notary', content: compiledPages.notary(), name: 'notary', on: { + pageBeforeIn: function () { + dyncontent = getDynamicPageContent("notary"); + if (dyncontent != null) { + $("#notary-dyncontent").html(dyncontent); + } + }, pageAfterIn: function () { app.swiper.destroy("#notary-info-swiper"); app.swiper.create("#notary-info-swiper", { @@ -433,6 +453,14 @@ var routes = [ }) }, {}); }, "GET"); + }, + on: { + pageBeforeIn: function () { + dyncontent = getDynamicPageContent("trailer"); + if (dyncontent != null) { + $("#trailer-dyncontent").html(dyncontent); + } + } } }, { @@ -448,6 +476,10 @@ var routes = [ }, function (error) { $("#addPaymentMethodNag").css("display", ""); }); + dyncontent = getDynamicPageContent("telegram"); + if (dyncontent != null) { + $("#telegram-dyncontent").html(dyncontent); + } } } }, diff --git a/www/settings.js b/www/settings.js index 9d0bd74..59d72fa 100644 --- a/www/settings.js +++ b/www/settings.js @@ -6,6 +6,8 @@ var SETTINGS = { apis: { + // Dynamic text content updater + dynamicappcontent: "http://localhost/helena.express/apis/dynamicappcontent/", // Tracking track: "http://localhost/helena.express/apis/track/", trackmultiple: "http://localhost/helena.express/apis/trackmultiple/",