- From: Dominique Hazael-Massieux via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 16 Jun 2010 09:54:19 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/system-info
In directory hutz:/tmp/cvs-serv1928
Modified Files:
Overview.html
Log Message:
improve Wifi connection monitor example
Index: Overview.html
===================================================================
RCS file: /sources/public/2009/dap/system-info/Overview.html,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- Overview.html 16 Jun 2010 05:11:02 -0000 1.120
+++ Overview.html 16 Jun 2010 09:54:16 -0000 1.121
@@ -527,13 +527,20 @@
<section>
<h4>ECMAScript Example</h4>
- <pre class="sh_javascript example">// Find if the current connection is WiFi, and if so monitor its signal strength
+ <pre class="sh_javascript example">// Find the first of the current connections that is on WiFi, and if so monitor its signal strength
navigator.system.get("Network",success,null);
function success(network) {
- var active = network.activeConnections[0];
- if (active.type === active.TYPE_WIFI)
- navigator.system.monitor("Connection",{id:active.id},wifiMonitorCB);
+ var activeConnections = network.activeConnections;
+ for (var i=0; i < activeConnections.length; i++) {
+ var active = activeConnections[i];
+ if (active.type === active.TYPE_WIFI) {
+ navigator.system.monitor("Connection", {id: active.id}, wifiMonitorCB);
+ // wifiMonitorCB is a user defined function that would
+ // monitor the signal strength
+ break;
+ }
+ }
}
function wifiMonitorCB(connection) {
Received on Wednesday, 16 June 2010 09:54:23 UTC