Created
September 24, 2012 20:44
-
-
Save Red-Folder/3778262 to your computer and use it in GitHub Desktop.
Phonegap Service Tutorial - Part2 - Index.html
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
<script type="text/javascript" src="backgroundService.js"></script> | |
<script type="text/javascript" src="twitterService.js"></script> | |
<script type="text/javascript" > | |
document.addEventListener('deviceready', function() { | |
getStatus(); | |
}, true); | |
function getStatus() { | |
window.plugins.twitterService.getStatus( function(r){ startService(r) }, | |
function(e){ alert('An error has occurred in getStatus') }); | |
}; | |
function startService(data) { | |
if (data.ServiceRunning) | |
enableTimer(data); | |
else | |
window.plugins.twitterService.startService( function(r){ enableTimer(r) }, | |
function(e){ alert('An error has occurred in startService') }); | |
} | |
function enableTimer(data) { | |
if (data.TimerEnabled) | |
alert('Service started and timer enabled'); | |
else | |
window.plugins.twitterService.enableTimer( 60000, | |
function(r){ /* All running, no action */ }, | |
function(e){ alert('An error has occurred in enableTimer') }); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment