|
|
|
@ -4,9 +4,16 @@
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
var trackingcoderegex = /^[0-9a-zA-Z]{5,40}$/;
|
|
|
|
|
|
|
|
|
|
function openTrackingInfoPage(code) {
|
|
|
|
|
if (typeof code == "undefined" || code == null || code == "") {
|
|
|
|
|
if (typeof code == "undefined" || code == null || code.trim() == "") {
|
|
|
|
|
app.input.validate("#trackingcode");
|
|
|
|
|
app.toast.show({
|
|
|
|
|
text: "Please enter a tracking code.",
|
|
|
|
|
position: "bottom",
|
|
|
|
|
closeTimeout: 2000
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -121,17 +128,16 @@ function updateTrackingMultiListStatus() {
|
|
|
|
|
function openTrackingBarcodeScanner() {
|
|
|
|
|
scanBarcode(function (result) {
|
|
|
|
|
var code = "";
|
|
|
|
|
var coderegex = /^[0-9a-zA-Z]{5,40}$/;
|
|
|
|
|
if (result.startsWith("https://helena.express/track#")) {
|
|
|
|
|
code = result.split("#")[1];
|
|
|
|
|
} else if (result.startsWith("http") && result.includes("#")) {
|
|
|
|
|
if (coderegex.test(result.split("#")[1])) {
|
|
|
|
|
if (trackingcoderegex.test(result.split("#")[1])) {
|
|
|
|
|
code = result.split("#")[1];
|
|
|
|
|
} else {
|
|
|
|
|
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else if (coderegex.test(result)) {
|
|
|
|
|
} else if (trackingcoderegex.test(result)) {
|
|
|
|
|
code = result;
|
|
|
|
|
} else {
|
|
|
|
|
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
|
|
|
@ -323,6 +329,54 @@ $("#app").on("contextmenu taphold", ".tracking-code-multi-link", function (evt)
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#app").on("contextmenu taphold", "#brokenscannercodeadd", function (evt) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
|
|
|
|
var code = $('input[name=\'trackingcode\']').val().trim().replace(/\s/, "");
|
|
|
|
|
|
|
|
|
|
var action = app.actions.create({
|
|
|
|
|
buttons: [
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
text: 'Track',
|
|
|
|
|
bold: true,
|
|
|
|
|
onClick: function () {
|
|
|
|
|
if (code == "") {
|
|
|
|
|
app.dialog.alert("You need to type a tracking code first.", "Error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
openTrackingInfoPage(code);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: 'Add to Multi list',
|
|
|
|
|
onClick: function () {
|
|
|
|
|
if (code == "") {
|
|
|
|
|
app.dialog.alert("You need to type a tracking code first.", "Error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!code.match(trackingcoderegex)) {
|
|
|
|
|
app.dialog.alert("That doesn't seem like a valid tracking code.", "Error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
addToTrackingMultiList(code);
|
|
|
|
|
addTrackingSuggestions();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
text: 'Cancel',
|
|
|
|
|
color: 'red'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
action.open();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#app").on("tab:show", "#tracking-multi-list", function (evt) {
|
|
|
|
|
updateTrackingMultiListStatus();
|
|
|
|
|
});
|
|
|
|
|