create Note shelving publication draft as proposed on DAP list, update publication dates and status, update status of document, add link to use cases document
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/network-api/NOTE.html Thu Mar 27 12:28:06 2014 -0400
@@ -0,0 +1,292 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr" typeof="bibo:Document w3p:NOTE" about="" property="dcterms:language" content="en">
+<head>
+ <title>The Network Information API</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+
+
+ <style>/*****************************************************************
+ * ReSpec 3 CSS
+ * Robin Berjon - http://berjon.com/
+ *****************************************************************/
+
+/* --- INLINES --- */
+em.rfc2119 {
+ text-transform: lowercase;
+ font-variant: small-caps;
+ font-style: normal;
+ color: #900;
+}
+
+h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
+h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
+ border: none;
+}
+
+dfn {
+ font-weight: bold;
+}
+
+a.internalDFN {
+ color: inherit;
+ border-bottom: 1px solid #99c;
+ text-decoration: none;
+}
+
+a.externalDFN {
+ color: inherit;
+ border-bottom: 1px dotted #ccc;
+ text-decoration: none;
+}
+
+a.bibref {
+ text-decoration: none;
+}
+
+cite .bibref {
+ font-style: normal;
+}
+
+code {
+ color: #ff4500;
+}
+
+/* --- TOC --- */
+.toc a, .tof a {
+ text-decoration: none;
+}
+
+a .secno, a .figno {
+ color: #000;
+}
+
+ul.tof, ol.tof {
+ list-style: none outside none;
+}
+
+.caption {
+ margin-top: 0.5em;
+ font-style: italic;
+}
+
+/* --- TABLE --- */
+table.simple {
+ border-spacing: 0;
+ border-collapse: collapse;
+ border-bottom: 3px solid #005a9c;
+}
+
+.simple th {
+ background: #005a9c;
+ color: #fff;
+ padding: 3px 5px;
+ text-align: left;
+}
+
+.simple th[scope="row"] {
+ background: inherit;
+ color: inherit;
+ border-top: 1px solid #ddd;
+}
+
+.simple td {
+ padding: 3px 10px;
+ border-top: 1px solid #ddd;
+}
+
+.simple tr:nth-child(even) {
+ background: #f0f6ff;
+}
+
+/* --- DL --- */
+.section dd > p:first-child {
+ margin-top: 0;
+}
+
+.section dd > p:last-child {
+ margin-bottom: 0;
+}
+
+.section dd {
+ margin-bottom: 1em;
+}
+
+.section dl.attrs dd, .section dl.eldef dd {
+ margin-bottom: 0;
+}
+
+@media print {
+ .removeOnSave {
+ display: none;
+ }
+}
+</style><link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/W3C-NOTE"><!--[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
+
+ <body class="h-entry" style="" role="document" id="respecDocument"><div class="head" role="contentinfo" id="respecHeader">
+ <p>
+
+ <a href="http://www.w3.org/"><img width="72" height="48" src="https://www.w3.org/Icons/w3c_home" alt="W3C"></a>
+
+ </p>
+ <h1 class="title p-name" id="title" property="dcterms:title">The Network Information API</h1>
+
+ <h2 property="dcterms:issued" datatype="xsd:dateTime" content="2014-04-10T04:00:00.000Z" id="w3c-working-group-note-10-april-2014"><abbr title="World Wide Web Consortium">W3C</abbr> Working Group Note <time class="dt-published" datetime="2014-04-10">10 April 2014</time></h2>
+ <dl>
+
+ <dt>This version:</dt>
+ <dd><a class="u-url" href="http://www.w3.org/TR/2014/NOTE-netinfo-api-20140410/">http://www.w3.org/TR/2014/NOTE-netinfo-api-20140410/</a></dd>
+ <dt>Latest published version:</dt>
+ <dd><a href="http://www.w3.org/TR/netinfo-api/">http://www.w3.org/TR/netinfo-api/</a></dd>
+
+
+ <dt>Latest editor's draft:</dt>
+ <dd><a href="http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html">http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html</a></dd>
+
+
+
+
+
+
+
+ <dt>Editor:</dt>
+ <dd class="p-author h-card vcard" rel="bibo:editor" inlist=""><span typeof="foaf:Person"><span property="foaf:name" class="p-name fn">Mounir Lamouri</span>, <a rel="foaf:workplaceHomepage" class="p-org org h-org h-card" href="http://mozilla.org/">Mozilla</a></span>
+</dd>
+
+
+
+ </dl>
+
+
+
+
+
+ <p class="copyright">
+ <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
+ 2014
+
+ <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
+ (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
+ <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
+ <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>),
+
+ All Rights Reserved.
+
+ <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
+ <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
+
+ <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a>
+
+ rules apply.
+ </p>
+
+
+ <hr>
+</div>
+
+ <section id="abstract" class="introductory" property="dcterms:abstract" datatype="" typeof="bibo:Chapter" resource="#ref" rel="bibo:Chapter"><h2 aria-level="1" role="heading" id="h2_abstract">Abstract</h2><p>
+ The Network Information API provides an interface for web applications to
+ access the underlying connection information of the device.
+ </p></section><section id="sotd" class="introductory" typeof="bibo:Chapter" resource="#ref" rel="bibo:Chapter"><h2 aria-level="1" role="heading" id="h2_sotd">Status of This Document</h2>
+
+
+
+ <p>
+ <em>This section describes the status of this document at the time of its publication.
+ Other documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the
+ latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a> at
+ http://www.w3.org/TR/.</em>
+ </p>
+
+ <p><strong>
+ Work on this document has been discontinued and it should not be
+ referenced or used as a basis for implementation. </strong>
+ </p>
+ <p>The Network Information API was defined to enable API access to
+ network information. While working on this specification the
+ <a href="http://www.w3.org/2009/dap/">Device APIs Working Group</a> encountered issues related to estimating network
+ bandwidth and with providing useful information, deciding to
+ discontinue work until better understanding of the use cases,
+ requirements and approach are available. The functionality
+ described in this specification was initially
+ specified as part of Device APIs Working Group
+ <a href="http://www.w3.org/TR/system-info-api/">System
+ Information API</a> specification but was extracted to create
+ a simpler specification.
+ </p>
+ <p>
+ The <a href="http://w3c-webmob.github.io/netinfo-usecases/">Network
+ Information Use cases and requirements</a> <abbr title="World Wide Web Consortium">W3C</abbr> Note
+ published by the <a href="http://www.w3.org/Mobile/IG/"><abbr title="World Wide Web Consortium">W3C</abbr> Web and Mobile Interest
+ Group</a>
+ is relevant
+ to the Network Information API specification.
+ </p><p>
+ The <a href="http://www.w3.org/2011/07/DeviceAPICharter">Charter
+ of the Device APIs Working Group</a> continues to include
+ this
+ work as "in scope", so the working group could decide to resume work
+ if warranted by new information.
+ </p>
+ <p>The previous published version containing the most recent content
+ is available at the “Previous Version” link noted above.
+ </p>
+
+ <p>
+ This document was published by the <a href="http://www.w3.org/2009/dap/">Device APIs and Policy Working Group</a> as a Working Group Note.
+
+
+ If you wish to make comments regarding this document, please send them to
+ <a href="mailto:public-device-apis@w3.org">public-device-apis@w3.org</a>
+ (<a href="mailto:public-device-apis-request@w3.org?subject=subscribe">subscribe</a>,
+ <a href="http://lists.w3.org/Archives/Public/public-device-apis/">archives</a>).
+
+
+
+
+ All comments are welcome.
+
+ </p>
+
+
+ <p>
+ Publication as a Working Group Note does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr>
+ Membership. This is a draft document and may be updated, replaced or obsoleted by other
+ documents at any time. It is inappropriate to cite this document as other than work in
+ progress.
+ </p>
+
+
+
+ <p>
+
+ This document was produced by a group operating under the
+ <a id="sotd_patent" about="" rel="w3p:patentRules" href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent
+ Policy</a>.
+
+
+
+
+ <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/43696/status" rel="disclosure">public list of any patent
+ disclosures</a>
+
+ made in connection with the deliverables of the group; that page also includes
+ instructions for disclosing a patent. An individual who has actual knowledge of a patent
+ which the individual believes contains
+ <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
+ Claim(s)</a> must disclose the information in accordance with
+ <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
+ 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
+
+
+ </p>
+
+
+
+
+</section>
+
+
+
+
+
+</body></html>
--- a/network-api/Overview.html Thu Mar 27 14:57:56 2014 +0000
+++ b/network-api/Overview.html Thu Mar 27 12:28:06 2014 -0400
@@ -3,374 +3,77 @@
<head>
<title>The Network Information API</title>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
- <script src='https://www.w3.org/Tools/respec/respec-w3c-common' class='remove'></script>
- <script class='remove'>
- var respecConfig = {
- specStatus: "ED",
- shortName: "netinfo-api",
-
-// publishDate: "2012-11-29",
- previousPublishDate: "2011-06-07",
- previousMaturity: "WD",
- edDraftURI: "http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html",
-
- // if this is a LCWD, uncomment and set the end of its review period
- // lcEnd: "2009-08-05",
- noIDLIn: true,
-
- editors: [
- { name: "Mounir Lamouri",
- company: "Mozilla",
- companyURL: "http://mozilla.org/" },
- ],
-
- wg: "Device APIs and Policy Working Group",
- wgURI: "http://www.w3.org/2009/dap/",
- wgPublicList: "public-device-apis",
- wgPatentURI: "http://www.w3.org/2004/01/pp-impl/43696/status"
- };
- </script>
- </head>
+ <script src='https://www.w3.org/Tools/respec/respec-w3c-common' class='remove'></script>
+ <script class='remove'>
+ var respecConfig = {
+ specStatus: "NOTE",
+ shortName: "netinfo-api",
- <body>
- <p style="background: black; color: white; font: 900 1.2em serif; padding: 0.5em 1em; border: dotted yellow 0.3em;">
- The Device APIs Working Group is currently not pursuing the approach
- outlined in this draft, so it should be considered historical.
- Please treat this document with caution and do not reference it or use
- it as the basis for implementation. The domain covered by this document is
- still within the scope of the Working Group as defined in its Charter.
- The Working Group may pursue an alternative API design that is based on
- the current Web browser security model
- </p>
-
- <section id='abstract'>
- The Network Information API provides an interface for web applications to
- access the underlying connection information of the device.
- </section>
+ publishDate: "2014-04-10",
+ previousPublishDate: "2012-11-29",
+ previousMaturity: "WD",
+ edDraftURI: "http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html",
- <section id='sotd'>
- <p>
- The functionality described in this specification was initially specified as part of the
- <a href='http://www.w3.org/TR/system-info-api/'>System Information API</a> but has been
- extracted in order to be more readily available, more straightforward to implement, and
- in order to produce a specification that could be implemented on its own merits without
- interference with other, often unrelated, features.
- </p>
- </section>
+ // if this is a LCWD, uncomment and set the end of its review period
+ // lcEnd: "2009-08-05",
+ noIDLIn: true,
- <section class="informative">
- <h2>Introduction</h2>
- <p>
- The Network Information API provides an interface enabling web applications to access the underlying
- connection information of the device.
- </p>
+ editors: [
+ { name: "Mounir Lamouri",
+ company: "Mozilla",
+ companyURL: "http://mozilla.org/" },
+ ],
- <section>
- <h2>Use Cases</h2>
- <p>
- The main use case of the Network Information API is to allow
- applications to be gentle with the user's bandwidth when they know it
- is rare or expensive. Even if there are not many applications that do
- this currently, this specification offers the the tools needed to
- enable this, allowing it to become more common.
+ wg: "Device APIs and Policy Working Group",
+ wgURI: "http://www.w3.org/2009/dap/",
+ wgPublicList: "public-device-apis",
+ wgPatentURI: "http://www.w3.org/2004/01/pp-impl/43696/status"
+ };
+ </script>
+ </head>
+
+ <body>
+
+ <section id='abstract'>
+ The Network Information API provides an interface for web applications to
+ access the underlying connection information of the device.
+ </section>
+
+ <section id='sotd'>
+ <p><strong>
+ Work on this document has been discontinued and it should not be
+ referenced or used as a basis for implementation. </strong>
+ </p>
+ <p>The Network Information API was defined to enable API access to
+ network information. While working on this specification the
+ <a href="http://www.w3.org/2009/dap/">Device APIs Working Group</a> encountered issues related to estimating network
+ bandwidth and with providing useful information, deciding to
+ discontinue work until better understanding of the use cases,
+ requirements and approach are available. The functionality
+ described in this specification was initially
+ specified as part of Device APIs Working Group
+ <a href="http://www.w3.org/TR/system-info-api/">System
+ Information API</a> specification but was extracted to create
+ a simpler specification.
</p>
<p>
- A few hypothetical examples would be:
- <ul>
- <li>An image viewer showing very low resolution thumbnails when the
- user has a low bandwidth or a metered connection.
- <li>A video game loading low textures when the user has a low
- bandwidth or a metered connection.</li>
- <li>An email client downloading only headers or even asking the user
- to download headers when he/she has a low bandwidth or a metered
- connection.</li>
- <li>Any app trying to aggressively cache any downloaded asset when
- the user has a low bandwidth or a metered connection.</li>
- </ul>
+ The <a href="http://w3c-webmob.github.io/netinfo-usecases/">Network
+ Information Use cases and requirements</a> W3C Note
+ published by the <a href="http://www.w3.org/Mobile/IG/">W3C Web and Mobile Interest
+ Group</a>
+ is relevant
+ to the Network Information API specification.
+ <p>
+ The <a href="http://www.w3.org/2011/07/DeviceAPICharter">Charter
+ of the Device APIs Working Group</a> continues to include
+ this
+ work as "in scope", so the working group could decide to resume work
+ if warranted by new information.
+ </p>
+ <p>The previous published version containing the most recent content
+ is available at the “Previous Version” link noted above.
</p>
</section>
- <section>
- <h2>Outstanding issues</h2>
- <p>
- The specification currently requests the <a>user agent</a> to expose
- two properties: <code>bandwidth</code> and <code>metered</code>. The
- working group currently does not have consensus on these.
- </p>
- <p>
- One concern is that <code>bandwidth</code> may be hard to implement,
- can be quite power-consuming to keep up-to-date and its value might be
- unrelated to the actual connection quality that could be affected by
- the server.<br>
- A solution to fix this would be to return non absolute values that
- couldn't be easily abused and would be more simple to produce for the
- <a>user agent</a>. For example, having a set of values like
- <code>very-slow</code>, <code>slow</code>, <code>fast</code> and
- <code>very-fast</code>. Another solution would be to have only values
- like <code>very-slow</code>, <code>slow</code> and the empty string."
- </p>
- <p>
- <code>metered</code> may also be hard to implement as there is
- currently no standard way for the OS to know if the current connection
- is metered. The approach of the specification is to leave the
- implementation details to the <a>user agent</a>. That way, the
- attribute could return a value based on a heuristic, on knowledge of
- the current connection status or even by directly asking the user for
- the information.<br>
- It is interesting to point that Android 4.1 and Windows 8 both have a
- way to check if the current connection is metered. Android is using a
- boolean (isActiveNetworkMetered()) while Windows 8 allow the developer
- to ask for different information (NetworkCostType,
- ApproachingDataLimit, OverDataLimit, Roaming).
- <!--
- Android: https://developer.android.com/reference/android/net/ConnectivityManager.html#isActiveNetworkMetered%28%29
- Windows: http://msdn.microsoft.com/en-us/library/windows/apps/hh465399.aspx#adapt
- -->
- </p>
- </section>
- </section>
-
- <section id='conformance'>
- <p>
- This specification defines conformance criteria that apply to a single
- product: the <dfn>user agent</dfn> that implements the interfaces that
- it contains.
- </p>
- <p>
- Implementations that use ECMAScript to expose the APIs defined in this specification must implement them in a manner
- consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]].
- </p>
- </section>
-
- <section>
- <h2>Terminology</h2>
- <p>
- The <code><a href="http://dev.w3.org/html5/spec/webappapis.html#event-handlers">
- EventHandler</a></code> interface represents a callback used for event
- handlers as defined in [[!HTML5]].
- </p>
- <p>
- The concepts <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">
- queue a task</a></dfn> and
- <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">
- fire a simple event</a></dfn> are defined in [[!HTML5]].
- </p>
-
- <p>
- The terms <dfn> <a href="http://dev.w3.org/html5/spec/webappapis.html#event-handlers">
- event handlers</a></dfn> and
- <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#event-handler-event-type">
- event handler event types</a></dfn> are defined in [[!HTML5]].
- </p>
-
- <p>
- The concepts of <dfn><a href="http://dev.w3.org/html5/spec/browsers.html#browsing-context">
- browsing context</a></dfn> and
- <dfn><a href="http://dev.w3.org/html5/spec/browsers.html#active-document">
- active document</a></dfn> are defined in [[!HTML5]].
- </p>
-
- <p>
- The concept of document <dfn><a href="http://dev.w3.org/html5/spec/browsers.html#the-document%27s-domain">
- domain</a></dfn> is defined in [[!HTML5]].
- </p>
- </section>
-
- <section>
- <h2>Security and privacy considerations</h2>
- <p>
- The API defined in this specification is used to determine the connection information
- of the hosting device. The information disclosed has minimal
- impact on privacy or fingerprinting, and therefore is exposed without
- permission grants. For example, authors cannot directly know what kind of connection
- is currently in use by the hosting device.
- </p>
- </section>
-
- <section>
- <h2>The <a>NetworkInformation</a> interface</h2>
- <p>
- The <a>NetworkInformation</a> interface is exposed on the
- <code>Navigator</code> object.
- </p>
- <div class='idl' title='Navigator implements NetworkInformation'></div>
- <dl title='[NoInterfaceObject] interface NetworkInformation' class='idl'>
- <dt>readonly attribute Connection connection</dt>
- <dd>
- The object from which connection information is accessed.
- </dd>
- </dl>
- </section>
-
- <section>
- <h2>The <a>Connection</a> interface</h2>
- <p>
- The <a>Connection</a> interface provides a handle to the device's connection information.
- </p>
- <dl title='[NoInterfaceObject]
- interface Connection : EventTarget' class='idl'>
- <dt>readonly attribute double bandwidth</dt>
- <dd>
- The <a>user agent</a> MUST set the value of the <code>bandwidth</code> attribute to:
- <ul>
- <li>0 if the user is currently offline;</li>
- <li>Infinity if the bandwidth is unknown;</li>
- <li>an estimation of the current bandwidth in MB/s (Megabytes per seconds) available for communication with the
- <a>browsing context</a> <a>active document</a>'s <a>domain</a>.
- </li>
- </ul>
- </dd>
- <dt>readonly attribute boolean metered</dt>
- <dd>
- <p>
- A connection is <dfn>metered</dfn> when the user's connection is subject to a limitation from his Internet Service Provider
- strong enough to request web applications to be careful with the bandwidth usage.
- </p>
- <div class="note">
- What is a metered connection is voluntarily left to the <a>user agent</a> to judge. It would not be possible to give an exhaustive
- list of limitations considered strong enough to flag the connection as metered and even if doable, some limitations can be
- considered strong or weak depending on the context.<br>
- Examples of metered connections are mobile connections with a small bandwidth quota or connections with a pay-per use plan.
- </div>
- <p>
- The <a>user agent</a> MUST set the value of the <code>metered</code> attribute to true if the connection with the
- <a>browsing context</a> <a>active document</a>'s <a>domain</a> is <a title='metered'>metered</a> and false otherwise.
- If the implementation is not able to know the status of the connection or if the user is offline, the value MUST be set to false.
- </p>
- <div class="note">
- If unable to know if a connection is metered, a <a>user agent</a> could ask the user about the status of his current connection.
- For example, a preference could let the user define if the mobile connection used on the device is metered.
- </div>
- </dd>
- <dt>[TreatNonCallableAsNull] attribute EventHandler onchange</dt>
- <dd></dd>
- </dl>
-
- <p>
- When the <code>Connection</code> changes, the <a>user agent</a> MUST <a>queue a task</a> which updates
- the <code>Connection</code> properties and <a>fire a simple event</a> named <code>change</code> at the
- <code>Connection</code> object.
- </p>
-
- <p>
- When the user goes online or offline, in addition to the <code>change</code> event fired on the <code>Connection</code>
- object, the <a>user agent</a> has to <a>fire a simple event</a> named either <code>online</code> or <code>offline</code>
- depending on the applicable value, as defined in [[!HTML5]].
- </p>
-
- <section>
- <h2>Event handlers</h2>
- <p>
- The following are the <a>event handlers</a> (and their corresponding
- <a>event handler event types</a>) that MUST be supported as
- attributes by the <code>Connection</code> object:
- </p>
-
- <table class="simple">
- <thead>
- <tr>
- <th>event handler</th>
- <th>event handler event type</th>
- </tr>
- </thead>
- <tbody>
-
- <tr>
- <td><strong><code>onchange</code></strong></td>
- <td><code>change</code></td>
- </tr>
- </tbody>
- </table>
- </section>
- </section>
-
- <section class='informative'>
- <h2>Examples</h2>
- <p>
- This trivial example writes the connection bandwidth to the console and shows it again each time it is changing:
- </p>
- <pre class="example highlight">
- function show() {
- console.log(navigator.connection.bandwidth);
- }
-
- navigator.connection.addEventListener('change', show, false);
-
- show();
- </pre>
-
- <p>
- This example shows how an image viewer can select a low definition or a high definition image based on the
- current connection bandwidth:
- </p>
- <pre class="example highlight">
- <!DOCTYPE>
- <html>
- <head>
- <title>Pony viewer</title>
- </head>
- <body>
- <img id='pony' alt="An image showing a pony" title="My precious!">
- <script>
- var i = document.getElementById('pony');
-
- if (navigator.connection.bandwidth > 2) {
- i.src = "http://example.com/pony_hd.png";
- } else {
- i.src = "http://example.com/pony_ld.png";
- }
- </script>
- </body>
- </html>
- </pre>
-
- <p>
- This example shows how an application can prevent automatic polling using the metered attribute:
- </p>
- <pre class="example highlight">
- <!DOCTYPE html>
- <html>
- <head>
- <title>Conditional polling</title>
- <script>
- var gPreviousMetered = navigator.connection.metered;
- var gIntervalId;
-
- function poll() {
- // poll stuff
- }
-
- 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);
-
- // 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'>
- <h2>Acknowledgments</h2>
- <p>
- Thanks to Robin Berjon, Frederick Hirsch and Jonas Sicking for their help.
- </p>
- </section>
- </body>
-</html>
+ </body>
+ </html>