Cheap hack for barcode scanner maybe
This commit is contained in:
parent
b1c9f78e40
commit
e37382eedf
@ -33,7 +33,6 @@ var scanBarcode = function (success, error) {
|
|||||||
|
|
||||||
var scanningBarcode = false;
|
var scanningBarcode = false;
|
||||||
|
|
||||||
|
|
||||||
function setupHTML5BarcodeScanner() {
|
function setupHTML5BarcodeScanner() {
|
||||||
$("body").append('<script src="node_modules/@zxing/library/umd/index.min.js"></script>');
|
$("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) {
|
var getLocation = function (success, error) {
|
||||||
if ("geolocation" in navigator) {
|
if ("geolocation" in navigator) {
|
||||||
navigator.geolocation.getCurrentPosition(function (position) {
|
navigator.geolocation.getCurrentPosition(function (position) {
|
||||||
@ -156,35 +183,13 @@ function initCordova() {
|
|||||||
window.open(url, '_system', '');
|
window.open(url, '_system', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof device != "undefined" && device.platform != "browser") {
|
setTimeout(function () {
|
||||||
scanBarcode = function (success, error) {
|
if (typeof device != "undefined" && device.platform != "browser") {
|
||||||
scanningBarcode = true;
|
setupCordovaBarcodeScanner();
|
||||||
cordova.plugins.barcodeScanner.scan(
|
} else {
|
||||||
function (result) {
|
setupHTML5BarcodeScanner();
|
||||||
scanningBarcode = false;
|
}
|
||||||
if (!result.cancelled) {
|
}, 3000);
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle geo: urls
|
// Handle geo: urls
|
||||||
$("#app").on("click", ".geolink", function (evt) {
|
$("#app").on("click", ".geolink", function (evt) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user