Skip to content

Instantly share code, notes, and snippets.

@johnvilsack
Created July 30, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnvilsack/44cb8f6fd9328e327ff9 to your computer and use it in GitHub Desktop.
Save johnvilsack/44cb8f6fd9328e327ff9 to your computer and use it in GitHub Desktop.
Standard index.js for /ttatarinov/lineapro-phonegap-plugin
function onDeviceConnected(data) {
alert("onDeviceConnected: " + data);
}
function onSuccessScanPaymentCard(data) {
alert("onSuccessScanPaymentCard: " + data);
}
function onBarcodeScanned(data) {
alert("onBarcodeScanned: " + data.rawCodesArr);
}
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
LineaProCDV.initDT(onDeviceConnected, onSuccessScanPaymentCard, onBarcodeScanned);
app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment