From 976f44a4f8ea6dffe013235d316080779e4fa1ee Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 30 Nov 2019 19:29:58 -0700 Subject: [PATCH] Add history (last five codes) and better help text to tracking page --- www/assets/js/toolbox_scanner.js | 2 +- www/assets/js/toolbox_track.js | 18 ++++++++++++++++-- www/pages/toolbox/track.html | 25 ++++++++++++++++++++++++- www/routes.js | 16 +++++++++++++++- 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/www/assets/js/toolbox_scanner.js b/www/assets/js/toolbox_scanner.js index 8beb771..47a5b6a 100644 --- a/www/assets/js/toolbox_scanner.js +++ b/www/assets/js/toolbox_scanner.js @@ -209,7 +209,7 @@ $("#app").on("click", "ul li.eventtypebutton", function () { }); $("#brokenscannerinput").on('keypress', function (e) { - if (e.which == 13) { + if (event.key === "Enter") { brokenScannerAddTextEntry(); } }); \ No newline at end of file diff --git a/www/assets/js/toolbox_track.js b/www/assets/js/toolbox_track.js index fab59d3..1551736 100644 --- a/www/assets/js/toolbox_track.js +++ b/www/assets/js/toolbox_track.js @@ -86,7 +86,21 @@ function openTrackingHistory(code) { infocontext.history[i].date = timestampToDateTimeString(infocontext.history[i].date); infocontext.history[i].status = trackingStatusToNiceString(infocontext.history[i].status, true); } - // TODO: format timestamps as local time + + // Keep last five tracking codes in history + var history = localStorage.getItem("trackingcodehistory"); + if (history == null) { + history = []; + } else { + history = JSON.parse(history); + } + if (infocontext.code != "") { + history.push(infocontext.code); + } + while (history.length > 5) { + history.shift(); + } + localStorage.setItem("trackingcodehistory", JSON.stringify(history)); if (refresh) { router.navigate("/toolbox/track/info", { @@ -150,7 +164,7 @@ $("#trackbtn").click(function () { }); $("input[name=trackingcode]").on('keypress', function (e) { - if (e.which == 13) { + if (event.key === "Enter") { $("#trackbtn").click(); } }); \ No newline at end of file diff --git a/www/pages/toolbox/track.html b/www/pages/toolbox/track.html index de92ba9..c5bacb1 100644 --- a/www/pages/toolbox/track.html +++ b/www/pages/toolbox/track.html @@ -40,9 +40,32 @@ -
+
+ info +
Compatible with USPS, UPS, FedEx, and DHL tracking codes. + Can extract full delivery point address (and sometimes customer phone number) + from 2D FedEx and UPS Mail Innovations barcodes.
+ + {{#if trackingcodehistory}} +
+
    +
  • + History +
  • + {{#each trackingcodehistory}} +
  • + +
  • + {{/each}} +
+
+ {{/if}}
diff --git a/www/routes.js b/www/routes.js index 6b23b91..82cd045 100644 --- a/www/routes.js +++ b/www/routes.js @@ -142,8 +142,22 @@ var routes = [ }, { path: '/track', - url: './pages/toolbox/track.html', name: 'track', + async: function (routeTo, routeFrom, resolve, reject) { + var history = localStorage.getItem("trackingcodehistory"); + if (history == null) { + history = false; + } else { + history = JSON.parse(history); + } + resolve({ + templateUrl: './pages/toolbox/track.html' + }, { + context: { + trackingcodehistory: history + } + }); + }, routes: [ { path: '/info',