diff options
author | Struan Donald <struan@exo.org.uk> | 2013-04-26 14:57:52 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-04-26 14:57:52 +0100 |
commit | dcc6095c50594278d035a4c29467d1de56cd33f5 (patch) | |
tree | 5112f49bfda76634a88616751e1af1e67751221d /www/js | |
parent | 2cd0332b5406393c0ffd509f37241874fa3e4097 (diff) |
split out network status check to separate function
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/app.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/www/js/app.js b/www/js/app.js index 7c85d84..930b6f2 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -60,6 +60,13 @@ var tpl = { FMS.isOffline = 1; }, + checkOnlineStatus: function() { + if ( navigator && navigator.connection && ( navigator.connection.type == Connection.NONE || + navigator.connection.type == Connection.UNKNOWN ) ) { + FMS.offline(); + } + }, + saveCurrentDraft: function() { FMS.router.pause(); FMS.allDrafts.add( FMS.currentDraft ); @@ -75,10 +82,6 @@ var tpl = { } } localStorage.currentDraftID = null; - if ( navigator && navigator.connection && ( navigator.connection.type == Connection.NONE || - navigator.connection.type == Connection.UNKNOWN ) ) { - FMS.offline(); - } }, removeDraft: function(draftID, removePhoto) { @@ -132,7 +135,7 @@ var tpl = { } document.addEventListener('pause', function() { FMS.saveCurrentDraft(); }, false); - document.addEventListener('resume', function() { FMS.loadCurrentDraft(); }, false); + document.addEventListener('resume', function() { FMS.checkOnlineStatus(); FMS.loadCurrentDraft(); }, false); document.addEventListener('backbutton', function() { FMS.router.back(); }, true); document.addEventListener('offline', function() { FMS.offline(); }, true); document.addEventListener('online', function() { FMS.online(); }, true); @@ -142,6 +145,7 @@ var tpl = { FMS.allDrafts.comparator = function(a,b) { var a_date = a.get('created'), b_date = b.get('created'); return a_date === b_date ? 0 : a_date < b_date ? 1 : -1; }; FMS.allDrafts.fetch(); + FMS.checkOnlineStatus(); FMS.loadCurrentDraft(); Backbone.history.start(); |