|
|
|
@ -33,7 +33,6 @@ var scanBarcode = function (success, error) {
|
|
|
|
|
|
|
|
|
|
var scanningBarcode = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setupHTML5BarcodeScanner() {
|
|
|
|
|
$("body").append('<script src="node_modules/@zxing/library/umd/index.min.js"></script>');
|
|
|
|
|
|
|
|
|
@ -82,6 +81,34 @@ function setupHTML5BarcodeScanner() {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setupCordovaBarcodeScanner() {
|
|
|
|
|
scanBarcode = function (success, error) {
|
|
|
|
|
scanningBarcode = true;
|
|
|
|
|
cordova.plugins.barcodeScanner.scan(
|
|
|
|
|
function (result) {
|
|
|
|
|
scanningBarcode = false;
|
|
|
|
|
if (!result.cancelled) {
|
|
|
|
|
success(result.text);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function (err) {
|
|
|
|
|
scanningBarcode = false;
|
|
|
|
|
if (typeof error == "function") {
|
|
|
|
|
error(err);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
showTorchButton: true,
|
|
|
|
|
showFlipCameraButton: true,
|
|
|
|
|
prompt: "Scan barcode",
|
|
|
|
|
resultDisplayDuration: 0,
|
|
|
|
|
disableSuccessBeep: true,
|
|
|
|
|
formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE"
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getLocation = function (success, error) {
|
|
|
|
|
if ("geolocation" in navigator) {
|
|
|
|
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
|
|
@ -156,35 +183,13 @@ function initCordova() {
|
|
|
|
|
window.open(url, '_system', '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof device != "undefined" && device.platform != "browser") {
|
|
|
|
|
scanBarcode = function (success, error) {
|
|
|
|
|
scanningBarcode = true;
|
|
|
|
|
cordova.plugins.barcodeScanner.scan(
|
|
|
|
|
function (result) {
|
|
|
|
|
scanningBarcode = false;
|
|
|
|
|
if (!result.cancelled) {
|
|
|
|
|
success(result.text);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function (err) {
|
|
|
|
|
scanningBarcode = false;
|
|
|
|
|
if (typeof error == "function") {
|
|
|
|
|
error(err);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
showTorchButton: true,
|
|
|
|
|
showFlipCameraButton: true,
|
|
|
|
|
prompt: "Scan barcode",
|
|
|
|
|
resultDisplayDuration: 0,
|
|
|
|
|
disableSuccessBeep: true,
|
|
|
|
|
formats: "QR_CODE,DATA_MATRIX,CODE_39,CODE_93,CODE_128,CODABAR,PDF_417,AZTEC,MAXICODE"
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
setupHTML5BarcodeScanner();
|
|
|
|
|
}
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
if (typeof device != "undefined" && device.platform != "browser") {
|
|
|
|
|
setupCordovaBarcodeScanner();
|
|
|
|
|
} else {
|
|
|
|
|
setupHTML5BarcodeScanner();
|
|
|
|
|
}
|
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
|
|
// Handle geo: urls
|
|
|
|
|
$("#app").on("click", ".geolink", function (evt) {
|
|
|
|
|