Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
do not use navigator.onLine check any more (Chrome Bug), #322
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Sep 24, 2014
1 parent 09ca4f9 commit 0c3e4f0
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/js/module/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,20 @@ define( [ 'gui', 'settings', 'store', 'jquery' ], function( gui, settings, store

function checkOnlineStatus() {
var online;
//console.log('checking connection status');
//navigator.onLine is totally unreliable (returns incorrect trues) on Firefox, Chrome, Safari (on OS X 10.8),
//but I assume falses are correct
if ( navigator.onLine ) {
if ( !uploadOngoingID ) {
$.ajax( {
type: 'GET',
url: CONNECTION_URL,
cache: false,
dataType: 'json',
timeout: 3000,
complete: function( response ) {
//important to check for the content of the no-cache response as it will
//start receiving the fallback page specified in the manifest!
online = typeof response.responseText !== 'undefined' && response.responseText === 'connected';
_setOnlineStatus( online );
}
} );
}
} else {
_setOnlineStatus( false );
if ( !uploadOngoingID ) {
$.ajax( {
type: 'GET',
url: CONNECTION_URL,
cache: false,
dataType: 'json',
timeout: 3000,
complete: function( response ) {
//important to check for the content of the no-cache response as it will
//start receiving the fallback page specified in the manifest!
online = typeof response.responseText !== 'undefined' && response.responseText === 'connected';
_setOnlineStatus( online );
}
} );
}
}

Expand Down

0 comments on commit 0c3e4f0

Please sign in to comment.