Fix an HTML issue.
--- 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'>