diff options
Diffstat (limited to 'www/js/app.js')
-rw-r--r-- | www/js/app.js | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/www/js/app.js b/www/js/app.js index 282e921..71a4f97 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -100,6 +100,11 @@ var tpl = { printDebug: function(msg) { if ( CONFIG.DEBUG ) { console.log(msg); + + // Some messages get logged before we've had a chance to + // attach the debugger, so keep them all for later reference. + FMS.debug_messages = FMS.debug_messages || []; + FMS.debug_messages.push(msg); } }, @@ -113,21 +118,28 @@ var tpl = { }, checkLoggedInStatus: function() { + var p = $.Deferred(); + if ( FMS.isOffline ) { + p.resolve(); } else { $.ajax( { url: CONFIG.FMS_URL + '/auth/ajax/check_auth', type: 'GET', dataType: 'json', timeout: 30000, - success: function( data, status ) { - FMS.isLoggedIn = 1; - }, - error: function() { - FMS.isLoggedIn = 0; - } - } ); + }) + .done(function() { + FMS.isLoggedIn = 1; + p.resolve(); + }) + .fail(function() { + FMS.isLoggedIn = 0; + p.resolve(); + }) } + + return p; }, saveCurrentDraft: function(force) { @@ -334,16 +346,21 @@ var tpl = { FMS.allDrafts.fetch(); FMS.checkOnlineStatus(); FMS.loadCurrentDraft(); - FMS.checkLoggedInStatus(); - FMS.setupHelp(); - - Backbone.history.start(); - if ( navigator && navigator.splashscreen ) { - navigator.splashscreen.hide(); - } else { - $('#load-screen').hide(); - } - $('#display-help').show(); + FMS.checkLoggedInStatus().done(function() { + if (!CONFIG.HELP_DISABLED) { + FMS.setupHelp(); + } + + Backbone.history.start(); + if ( navigator && navigator.splashscreen ) { + navigator.splashscreen.hide(); + } else { + $('#load-screen').hide(); + } + if (!CONFIG.HELP_DISABLED) { + $('#display-help').show(); + } + }); }); } }); |