This page allows you to scan barcodes from GSW Browse via the device camera.
This demo is set up to open the device camera as a barcode when the "User ID" field is entered by the user. All other fields are set to be normal manual input.
This demo is using the cordova-plugin-zxing plugin. For more information click here:
var GSW = GSW || {};
GSW.Tests = GSW.Tests || {};
GSW.Tests.onDeviceReady = function() {
// Cordova is now initialized. Have fun!
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
GSW.Tests.scan = function(el) {
var params = {
'prompt_message': 'Scan a barcode', // Change the info message. A blank message ('') will show a default message
'orientation_locked': false, // Lock the orientation screen
'camera_id': 0, // Choose the camera source
'beep_enabled': true, // Enables a beep after the scan
'scan_type': 'normal', // Types of scan mode: normal = default black with white background / inverted = white bars on dark background / mixed = normal and inverted modes
'barcode_formats': [
'QR_CODE',
'CODE_39',
'CODE_128',
'UPC_A'
], // Put a list of formats that the scanner will find. A blank list ([]) will enable scan of all barcode types
'extras': {} // Additional extra parameters. See [ZXing Journey Apps][1] IntentIntegrator and Intents for more details
};
function onSuccess(result) {
console.log(result);
el.value = result;
}
function onFailure(result) {
console.log(result);
}
window.plugins.zxingPlugin.scan(params, onSuccess, onFailure);
}
document.getElementById('userid').addEventListener("click", function() {
document.getElementById('userid').addEventListener("focus", GSW.Tests.scan(document.getElementById('userid')), false);
});
}
document.addEventListener('deviceready', GSW.Tests.onDeviceReady, false);