You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mw...@apache.org on 2012/08/30 20:13:04 UTC
[1/3] git commit: [app] Add comments to JavaScript.
Updated Branches:
refs/heads/master 2e929c09b -> 1d98ded89
[app] Add comments to JavaScript.
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/commit/1d98ded8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/tree/1d98ded8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/diff/1d98ded8
Branch: refs/heads/master
Commit: 1d98ded89c6b0d944a2b0bab7be03b745659cece
Parents: 46d4790
Author: Michael Brooks <mi...@michaelbrooks.ca>
Authored: Thu Aug 30 11:04:01 2012 -0700
Committer: Michael Brooks <mi...@michaelbrooks.ca>
Committed: Thu Aug 30 11:04:01 2012 -0700
----------------------------------------------------------------------
www/js/index.js | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-app-hello-world/blob/1d98ded8/www/js/index.js
----------------------------------------------------------------------
diff --git a/www/js/index.js b/www/js/index.js
index 0a0e8c6..3b75d3f 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -17,17 +17,25 @@
* under the License.
*/
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() {
- // This is an event handler function, which means the scope is the event.
- // So, we must explicitly called `app.report()` instead of `this.report()`.
app.receivedEvent('deviceready');
},
+ // Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');