diff options
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/index.js')
| -rwxr-xr-x | StoneIsland/platforms/android/assets/www/js/index.js | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js index 73af443a..6bea75d0 100755 --- a/StoneIsland/platforms/android/assets/www/js/index.js +++ b/StoneIsland/platforms/android/assets/www/js/index.js @@ -1,9 +1,10 @@ var app = (function(){ var app = {} - app.init = function(){ + app.init = function(){ + console.log("init") - sdk.init({ env: "test" }) + sdk.init({ env: "production" }) app.bind() app.build() @@ -63,29 +64,56 @@ var app = (function(){ } app.ready = function(){ + console.log(">> READY") if (window.cordova) { document.addEventListener('pause', app.paused, false) document.addEventListener('resume', app.resumed, false) + document.addEventListener('online', app.online, false) + document.addEventListener('offline', app.offline, false) cordova.plugins.Keyboard.disableScroll(true) geo.fetch() + var image = new Image + image.src = "./img/compass-logo.png" } app.view = null app.router = new SiteRouter () -// if (sdk.env == "test") { -// app.router.launch() -// } -// else { - push.init() - app.account.connect( app.router.launch.bind(app.router) ) -// } + +// if (sdk.env == "test") { +// app.router.launch() +// } +// else { +// } + + if (navigator.onLine) { + app.account.connect() + app.blog.fetch(function(){ + app.router.initial_route = "/intro" + app.router.launch() + }) + } + else { + console.log(">> LAUNCHED WHILE OFFLINE") + app.router.go("intro") + app.finished_launching() + } + push.init() + } + + app.finished_launching = function(){ + console.log(">> FINISHED LAUNCHING") + if (window.cordova) { + navigator.splashscreen.hide() + } $("body").removeClass("loading") } var refresh_time = +Date.now() app.paused = function(){} app.resumed = function(){ + console.log( "app is ready?", app.is_ready ) + geo.fetch() var now = +Date.now() if (now - refresh_time > 60 * 60 * 1000) { @@ -94,6 +122,13 @@ var app = (function(){ } } + app.online = function(){ + console.log(">> ONLINE") + } + app.offline = function(){ + console.log(">> OFFLINE") + } + return app })() |
