Hi ,
I've created a button which opens the Phonegap scanner in my app and the scanner is working fine, However when the scan is completed how do I set the scanned value to a field? The field is called Scan_Result.
Here is the code which I am currently using:
{dialog.object}.appVars={};
{dialog.object}.appVars.debug=true;
{dialog.object}.appVars.msg = '';
{dialog.object}.appVars.scannerResult = {};
{dialog.object}.appVars.template = [
'<center><img src = "{results[0].artworkUrl100}"></center><br><br>',
'<b>{results[0].trackName}</b><br><br>',
'<b>Author: </b>{results[0].artistName}<br><br>',
'<b>Type:</b> {results[0].kind} <b>Price:</b> {results[0].formattedPrice}<br><br>',
'<center><button class="blueBtn" ontouchend="launchInAppBrowser(\'{results[0].trackViewUrl}\');">{results[0].btnLabel}</button></center>',
'{results[0].description}'].join('');
{dialog.object}.appVars.templateWithRatings = [
'<center><img src = "{results[0].artworkUrl100}"></center><br><br>',
'<b>{results[0].trackName}</b><br><br>',
'<b>Author: </b>{results[0].artistName}<br><br>',
'<b>Type:</b> {results[0].kind} <b>Price:</b> {results[0].formattedPrice}<br>',
'<b>Rating:</b> {results[0].averageUserRating} based on <b>{results[0].userRatingCount}</b> reviews.<br><br>',
'<center><button class="blueBtn" ontouchend="launchInAppBrowser(\'{results[0].trackViewUrl}\');">{results[0].btnLabel}</button></center>',
'{results[0].description}'].join('');
/* Event Handlers */
// onDeviceReady: this fires after PhoneGap has been fully initialized.
document.addEventListener('deviceready',onDeviceReady,false);
/* Support Functions */
function onDeviceReady() {
// PhoneGap is initialized, let's show some device info
if ({dialog.object}.appVars.debug) {
console.log('PhoneGap deviceready fired.');
}
navigator.notification.alert('PhoneGap 3.1 Ready\n'+
'\nPlatform : '+ device.platform + '\n' +
'OS Version: '+ device.version + '\n' +
'Device Model: '+ device.model + '\n' +
'PhoneGap Version: '+ device.cordova);
}
function scanBarCode(){
if ({dialog.object}.appVars.debug) {
console.log('scanBarCode function called.');
}
// this is a minimal check to verify plugin installation
if (typeof (cordova) == 'undefined') {
alert('PhoneGap plugin is not installed.');
return;
}
cordova.plugins.barcodeScanner.scan(function(result) {
{dialog.object}.appVars.scannerResult = result;
if (result.cancelled) {
navigator.notification.alert('Try again.');
} else {
alert("We got a barcode: " ;
}
},
function(error) {
navigator.notification.alert('Try Again' +error);
});
}
I've created a button which opens the Phonegap scanner in my app and the scanner is working fine, However when the scan is completed how do I set the scanned value to a field? The field is called Scan_Result.
Here is the code which I am currently using:
{dialog.object}.appVars={};
{dialog.object}.appVars.debug=true;
{dialog.object}.appVars.msg = '';
{dialog.object}.appVars.scannerResult = {};
{dialog.object}.appVars.template = [
'<center><img src = "{results[0].artworkUrl100}"></center><br><br>',
'<b>{results[0].trackName}</b><br><br>',
'<b>Author: </b>{results[0].artistName}<br><br>',
'<b>Type:</b> {results[0].kind} <b>Price:</b> {results[0].formattedPrice}<br><br>',
'<center><button class="blueBtn" ontouchend="launchInAppBrowser(\'{results[0].trackViewUrl}\');">{results[0].btnLabel}</button></center>',
'{results[0].description}'].join('');
{dialog.object}.appVars.templateWithRatings = [
'<center><img src = "{results[0].artworkUrl100}"></center><br><br>',
'<b>{results[0].trackName}</b><br><br>',
'<b>Author: </b>{results[0].artistName}<br><br>',
'<b>Type:</b> {results[0].kind} <b>Price:</b> {results[0].formattedPrice}<br>',
'<b>Rating:</b> {results[0].averageUserRating} based on <b>{results[0].userRatingCount}</b> reviews.<br><br>',
'<center><button class="blueBtn" ontouchend="launchInAppBrowser(\'{results[0].trackViewUrl}\');">{results[0].btnLabel}</button></center>',
'{results[0].description}'].join('');
/* Event Handlers */
// onDeviceReady: this fires after PhoneGap has been fully initialized.
document.addEventListener('deviceready',onDeviceReady,false);
/* Support Functions */
function onDeviceReady() {
// PhoneGap is initialized, let's show some device info
if ({dialog.object}.appVars.debug) {
console.log('PhoneGap deviceready fired.');
}
navigator.notification.alert('PhoneGap 3.1 Ready\n'+
'\nPlatform : '+ device.platform + '\n' +
'OS Version: '+ device.version + '\n' +
'Device Model: '+ device.model + '\n' +
'PhoneGap Version: '+ device.cordova);
}
function scanBarCode(){
if ({dialog.object}.appVars.debug) {
console.log('scanBarCode function called.');
}
// this is a minimal check to verify plugin installation
if (typeof (cordova) == 'undefined') {
alert('PhoneGap plugin is not installed.');
return;
}
cordova.plugins.barcodeScanner.scan(function(result) {
{dialog.object}.appVars.scannerResult = result;
if (result.cancelled) {
navigator.notification.alert('Try again.');
} else {
alert("We got a barcode: " ;
}
},
function(error) {
navigator.notification.alert('Try Again' +error);
});
}
Comment