Add history (last five codes) and better help text to tracking page

master
Skylar Ittner 4 years ago
parent 008ab56ce8
commit 976f44a4f8

@ -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();
}
});

@ -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();
}
});

@ -40,9 +40,32 @@
</ul>
</div>
<div class="block">
<div class="block text-align-center">
<i class="material-icons">info</i>
<br />
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.
</div>
{{#if trackingcodehistory}}
<div class="list no-hairlines tablet-inset">
<ul>
<li class="item-divider">
History
</li>
{{#each trackingcodehistory}}
<li>
<div class="item-link item-content" onclick="openTrackingHistory('{{this}}')">
<div class="item-inner">
<div class="item-title">{{this}}</div>
</div>
</div>
</li>
{{/each}}
</ul>
</div>
{{/if}}
</div>
<script src="assets/js/toolbox_track.js"></script>

@ -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',

Loading…
Cancel
Save