Improve barcode handling

master
Skylar Ittner 4 years ago
parent 808ff0f4a8
commit b99e577d63

@ -16,11 +16,10 @@ $("#clientsearchbar").submit(function (evt) {
router.navigate("/clients/" + $("#clientsearchbar input[type=search]").val()); router.navigate("/clients/" + $("#clientsearchbar input[type=search]").val());
}); });
function scanBarcodeOpenMachine() { function openMachineInfoByBarcode(code) {
scanBarcode(function (code) { if (code.startsWith("http") || !code.match(/^([A-Z0-9])+$/)) {
if (code.startsWith("http")) { matches = code.match(/[0-9A-Z]{8,}/g);
matches = code.match(/[0-9]{8,}/g); if (matches == null || matches.length == 0) {
if (matches.length == 0) {
app.dialog.alert("No IDs detected in barcode.", "Error"); app.dialog.alert("No IDs detected in barcode.", "Error");
} else if (matches.length == 1) { } else if (matches.length == 1) {
router.navigate("/machine/" + matches[0]); router.navigate("/machine/" + matches[0]);
@ -45,6 +44,11 @@ function scanBarcodeOpenMachine() {
} else { } else {
router.navigate("/machine/" + code); router.navigate("/machine/" + code);
} }
}
function scanBarcodeOpenMachine() {
scanBarcode(function (code) {
openMachineInfoByBarcode(code);
}, function (error) { }, function (error) {
app.dialog.alert(error, "Error"); app.dialog.alert(error, "Error");
}); });

Loading…
Cancel
Save