Created
January 6, 2021 15:06
-
-
Save Maxim-Kolmogorov/fca059291ce86f900d21ecf67d8cb260 to your computer and use it in GitHub Desktop.
Tutorial: Cordova plugin in Swift. Part 5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = { | |
initialize: function() { | |
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); | |
}, | |
onDeviceReady: function() { | |
this.receivedEvent('deviceready'); | |
echotest.echo('YO BRO!', function(msg) { | |
document.getElementById('deviceready').querySelector('.received').innerHTML = msg; | |
}, | |
function(err) { | |
document.getElementById('deviceready').innerHTML = '<p class="event received">' + err + '</p>'; | |
} | |
); | |
}, | |
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