- From: Mercurial notifier <cvsmail@w3.org>
- Date: Mon, 05 Nov 2012 21:53:45 +0000
- To: public-dap-commits@w3.org
changeset: 270:5af8a0637294 user: Mounir Lamouri <mounir.lamouri@gmail.com> date: Mon Nov 05 16:43:41 2012 +0000 files: network-api/Overview.html description: Fix an HTML issue. diff -r 20ab51fe20f3 -r 5af8a0637294 network-api/Overview.html --- a/network-api/Overview.html Mon Nov 05 16:39:27 2012 +0000 +++ b/network-api/Overview.html Mon Nov 05 16:43:41 2012 +0000 @@ -238,60 +238,56 @@ <p> This trivial example writes the connection bandwidth to the console and shows it again each time it is changing: </p> - <div class="example"> - <pre class="example highlight"> - function show() { - console.log(navigator.connection.bandwidth); - } + <pre class="example highlight"> + function show() { + console.log(navigator.connection.bandwidth); + } - navigator.connection.addEventListener('change', show, false); + navigator.connection.addEventListener('change', show, false); - show(); - </pre> - </div> + show(); + </pre> <p> This example shows how an application can prevent automatic polling using the metered attribute: </p> - <div class="example"> - <pre class="example highlight"> - <!DOCTYPE html> - <html> - <head> - <title>Conditional polling</title> - <script> - var gPreviousMetered = navigator.connection.metered; - var gIntervalId; + <pre class="example highlight"> + <!DOCTYPE html> + <html> + <head> + <title>Conditional polling</title> + <script> + var gPreviousMetered = navigator.connection.metered; + var gIntervalId; - function poll() { - // poll stuff + function poll() { + // poll stuff + } + + navigator.connection.addEventListener('change', function() { + if (gPreviousMetered == navigator.connection.metered) { + return; } - navigator.connection.addEventListener('change', function() { - if (gPreviousMetered == navigator.connection.metered) { - return; - } + gPreviousMetered = navigator.connection.metered; + if (navigator.connection.metered) { + gIntervalId = setInterval(poll, 1000); + } else { + clearInterval(gIntervalId); + } + }, false); - gPreviousMetered = navigator.connection.metered; - if (navigator.connection.metered) { - gIntervalId = setInterval(poll, 1000); - } else { - clearInterval(gIntervalId); - } - }, false); - - // At load time. - if (!navigator.connection.metered) { - gIntervalId = setInterval(poll, 1000); - } - </script> - </head> - <body> - <button onclick="poll();">Poll</button> - </body> - </html> - </pre> - </div> + // At load time. + if (!navigator.connection.metered) { + gIntervalId = setInterval(poll, 1000); + } + </script> + </head> + <body> + <button onclick="poll();">Poll</button> + </body> + </html> + </pre> </section> <section class='appendix'>
Received on Monday, 5 November 2012 21:53:47 UTC