Set the connection based on navigator.onLine