You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/09/18 16:47:24 UTC

[3/6] js commit: [all] Make navigator.onLine be explicitly based on navigator.connection.type.

[all] Make navigator.onLine be explicitly based on navigator.connection.type.

This fixes the property being broken on Android.
https://issues.apache.org/jira/browse/CB-1269


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/b25e91d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/b25e91d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/b25e91d5

Branch: refs/heads/master
Commit: b25e91d5f900c19680fdddc522c04b6d854b2032
Parents: 0982d4d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 5 16:47:15 2012 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Sep 18 10:46:48 2012 -0400

----------------------------------------------------------------------
 lib/common/plugin/network.js |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/b25e91d5/lib/common/plugin/network.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/network.js b/lib/common/plugin/network.js
index 078efb3..adaba5a 100644
--- a/lib/common/plugin/network.js
+++ b/lib/common/plugin/network.js
@@ -21,7 +21,17 @@
 
 var exec = require('cordova/exec'),
     cordova = require('cordova'),
-    channel = require('cordova/channel');
+    channel = require('cordova/channel'),
+    utils = require('cordova/utils');
+
+// Link the onLine property with the Cordova-supplied network info.
+// This works because we clobber the naviagtor object with our own
+// object in bootstrap.js.
+if (typeof navigator != 'undefined') {
+    utils.defineGetter(navigator, 'onLine', function() {
+        return this.connection.type != 'none';
+    });
+}
 
 var NetworkConnection = function () {
     this.type = null;