incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject spec commit: Update Network test to show both new and deprecated network states.
Date Wed, 10 Oct 2012 19:51:27 GMT
Updated Branches:
  refs/heads/master f47c2eee3 -> 38cd17f34


Update Network test to show both new and deprecated network states.

navigator.network.connection.type and navigator.connection.type.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/38cd17f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/38cd17f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/38cd17f3

Branch: refs/heads/master
Commit: 38cd17f3416a1eddd5e69e1bf84dc1199fa85520
Parents: f47c2ee
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Oct 10 15:50:47 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Oct 10 15:50:47 2012 -0400

----------------------------------------------------------------------
 network/index.html |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/38cd17f3/network/index.html
----------------------------------------------------------------------
diff --git a/network/index.html b/network/index.html
index 189e7f3..4eac56c 100644
--- a/network/index.html
+++ b/network/index.html
@@ -31,34 +31,38 @@
       
 <script type="text/javascript" charset="utf-8">
 
-    var deviceReady = false;
 
-    var eventOutput = function(s) {
+    function eventOutput(s) {
         var el = document.getElementById("results");
         el.innerHTML = el.innerHTML + s + "<br>";
-    };
+    }
 
     function printNetwork() {
-        eventOutput("Current network connection type is: " + navigator.network.connection.type);
+        eventOutput("navigator.connection.type=" + navigator.connection.type);
+        eventOutput("navigator.network.connection.type=" + navigator.network.connection.type);
     }
 
     /**
      * Function called when page has finished loading.
      */
     function init() {
+        var deviceReady = false;
+        function onEvent(e) {
+            eventOutput('Event of type: ' + e.type);
+            printNetwork();
+        }
+        document.addEventListener('online', onEvent, false);
+        document.addEventListener('offline', onEvent, false);
         document.addEventListener("deviceready", function() {
             deviceReady = true;
-            console.log("Device="+device.platform+" "+device.version);
-            eventOutput("Network Connection is: " + navigator.network.connection.type);
-            document.addEventListener('online', function() { eventOutput('Online event, connection
is: ' + navigator.network.connection.type); }, false);
-            document.addEventListener('offline', function() { eventOutput('Offline event,
connection is: ' + navigator.network.connection.type); }, false);
-
+            eventOutput("Device="+device.platform+" "+device.version);
+            printNetwork();
         }, false);
         window.setTimeout(function() {
             if (!deviceReady) {
                 alert("Error: Cordova did not initialize.  Demo will not run correctly.");
             }
-        },1000);
+        }, 1000);
     }
 
 </script>


Mime
View raw message