51 lines
1.8 KiB
JavaScript
Raw Normal View History

/*
* Copyright 2020 Netsyms Technologies.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$("#machinesearchbar").submit(function (evt) {
evt.preventDefault();
router.navigate("/machine/" + $("#machinesearchbar input[type=search]").val());
2020-06-09 14:03:30 -06:00
});
2020-09-06 20:16:53 -06:00
$("#clientsearchbar").submit(function (evt) {
evt.preventDefault();
router.navigate("/clients/" + $("#clientsearchbar input[type=search]").val());
});
2020-06-09 14:03:30 -06:00
function scanBarcodeOpenMachine() {
scanBarcode(function (code) {
if (code.startsWith("http")) {
matches = code.match(/[0-9]{8,}/g);
if (matches.length == 0) {
app.dialog.alert("No IDs detected in barcode.", "Error");
} else if (matches.length == 1) {
router.navigate("/machine/" + matches[0]);
} else if (matches.length > 1) {
var buttons = [];
for (var i = 0; i < matches.length; i++) {
buttons.push({
text: matches[i]
});
}
app.dialog.create({
title: 'Multiple IDs',
text: 'Multiple potential IDs exist in that barcode. Select the correct one.',
buttons: buttons,
verticalButtons: true,
onClick: function (dialog, index) {
var id = matches[index];
router.navigate("/machine/" + id);
}
}).open();
}
} else {
router.navigate("/machine/" + code);
}
2020-06-09 14:03:30 -06:00
}, function (error) {
app.dialog.alert(error, "Error");
});
}