Add context menu to track search button (close #8)
This commit is contained in:
parent
aa3a602a2b
commit
0468b19b6d
@ -4,9 +4,16 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var trackingcoderegex = /^[0-9a-zA-Z]{5,40}$/;
|
||||||
|
|
||||||
function openTrackingInfoPage(code) {
|
function openTrackingInfoPage(code) {
|
||||||
if (typeof code == "undefined" || code == null || code == "") {
|
if (typeof code == "undefined" || code == null || code.trim() == "") {
|
||||||
app.input.validate("#trackingcode");
|
app.input.validate("#trackingcode");
|
||||||
|
app.toast.show({
|
||||||
|
text: "Please enter a tracking code.",
|
||||||
|
position: "bottom",
|
||||||
|
closeTimeout: 2000
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,17 +128,16 @@ function updateTrackingMultiListStatus() {
|
|||||||
function openTrackingBarcodeScanner() {
|
function openTrackingBarcodeScanner() {
|
||||||
scanBarcode(function (result) {
|
scanBarcode(function (result) {
|
||||||
var code = "";
|
var code = "";
|
||||||
var coderegex = /^[0-9a-zA-Z]{5,40}$/;
|
|
||||||
if (result.startsWith("https://helena.express/track#")) {
|
if (result.startsWith("https://helena.express/track#")) {
|
||||||
code = result.split("#")[1];
|
code = result.split("#")[1];
|
||||||
} else if (result.startsWith("http") && result.includes("#")) {
|
} else if (result.startsWith("http") && result.includes("#")) {
|
||||||
if (coderegex.test(result.split("#")[1])) {
|
if (trackingcoderegex.test(result.split("#")[1])) {
|
||||||
code = result.split("#")[1];
|
code = result.split("#")[1];
|
||||||
} else {
|
} else {
|
||||||
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (coderegex.test(result)) {
|
} else if (trackingcoderegex.test(result)) {
|
||||||
code = result;
|
code = result;
|
||||||
} else {
|
} else {
|
||||||
app.dialog.alert("This app can't understand what's in that barcode.", "Error");
|
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;
|
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) {
|
$("#app").on("tab:show", "#tracking-multi-list", function (evt) {
|
||||||
updateTrackingMultiListStatus();
|
updateTrackingMultiListStatus();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user