Created
May 2, 2012 00:08
-
-
Save shazron/2572545 to your computer and use it in GitHub Desktop.
Cordova - testing events (manual tests)
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 dm = {}; | |
| function msg_delay(e, m) | |
| { | |
| if (!m) { m = e; } | |
| dm[e] = m; | |
| } | |
| function msg(m, d) | |
| { | |
| if (d) { | |
| var d_ = dm[d]; | |
| if (d_) { | |
| console.log("Delayed log: " + d_); | |
| delete dm[d]; | |
| } | |
| } | |
| console.log(m); | |
| } | |
| function onDeviceReady() | |
| { | |
| // do your thing! | |
| document.addEventListener('orientationchange', function() { msg(window.orientation); }, false); | |
| document.addEventListener('pause', function() { msg_delay('pause'); }, false); | |
| document.addEventListener('resume', function() { msg('resume', 'pause'); }, false); | |
| document.addEventListener('online', function() { msg('online'); }, false); | |
| document.addEventListener('offline', function() { msg('offline'); }, false); | |
| document.addEventListener('active', function() { msg('active', 'resign'); }, false); | |
| document.addEventListener('resign', function() { msg_delay('resign'); }, false); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment