Skip to content

Commit 934c053

Browse files
committed
Reapply #565: remove filtering (#600)
Signed-off-by: Zoltan Kis <[email protected]>
1 parent 0b9dc7a commit 934c053

File tree

1 file changed

+21
-159
lines changed

1 file changed

+21
-159
lines changed

index.html

Lines changed: 21 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,15 +1246,16 @@ <h4>
12461246
<section> <h3>Save and restore game progress with an NFC tag</h3>
12471247
<p>
12481248
Filtering of relevant data sources can be done by the use of
1249-
the <a>NDEFScanOptions</a>. Below we use the custom record identifier
1250-
"`my-game-progress`" as a relative URL so that when we read the data, we
1251-
immediately update the game progress by issuing a write with a custom NDEF
1252-
data layout.
1249+
a custom record identifier, in this case "`my-game-progress`".
1250+
When we read the data, we immediately update the game progress by issuing
1251+
a write with a custom NDEF data layout.
12531252
</p>
12541253
<pre class="example">
12551254
const reader = new NDEFReader();
1256-
await reader.scan({ id: "my-game-progress" });
1255+
await reader.scan();
12571256
reader.onreading = async event => {
1257+
if (event.message.id !== "my-game-progress")
1258+
return;
12581259
console.log(`Game state: ${ JSON.stringify(event.message.records) }`);
12591260

12601261
const encoder = new TextEncoder();
@@ -1283,9 +1284,7 @@ <h4>
12831284
</p>
12841285
<pre class="example">
12851286
const reader = new NDEFReader();
1286-
await reader.scan({
1287-
mediaType: "application/*json"
1288-
});
1287+
await reader.scan();
12891288
reader.onreading = event => {
12901289
const decoder = new TextDecoder();
12911290
for (const record of event.message.records) {
@@ -1438,7 +1437,7 @@ <h4>
14381437
</p>
14391438
<pre class="example">
14401439
const reader = new NDEFReader();
1441-
await reader.scan({ recordType: "example.com:smart-poster" });
1440+
await reader.scan();
14421441
reader.onreading = event => {
14431442
const externalRecord = event.message.records.find(
14441443
record => record.type == "example.com:smart-poster"
@@ -1531,10 +1530,11 @@ <h4>
15311530
</pre>
15321531
<pre class="example">
15331532
const reader = new NDEFReader();
1534-
await reader.scan({ recordType: "example.com:shoppingItem" });
1533+
await reader.scan();
15351534
reader.onreading = event => {
15361535
const shoppingItemRecord = event.message.records[0];
1537-
if (!shoppingItemRecord) {
1536+
if (!shoppingItemRecord ||
1537+
shoppingItemRecord.recordType !== "example.com:shoppingItem") {
15381538
return;
15391539
}
15401540

@@ -1992,7 +1992,8 @@ <h2>The <dfn>record type</dfn> string</h2>
19921992
interface NDEFWriter {
19931993
constructor();
19941994

1995-
Promise&lt;undefined&gt; write(NDEFMessageSource message, optional NDEFWriteOptions options={});
1995+
Promise&lt;undefined&gt; write(NDEFMessageSource message,
1996+
optional NDEFWriteOptions options={});
19961997
};
19971998

19981999
[SecureContext, Exposed=Window]
@@ -2093,26 +2094,6 @@ <h2>The <dfn>record type</dfn> string</h2>
20932094
</thead>
20942095
<tbody data-link-for="NDEFScanOptions">
20952096
<tr>
2096-
<td><dfn>[[\Id]]</dfn></td>
2097-
<td>`undefined`</td>
2098-
<td>
2099-
The {{NDEFScanOptions}}.<a>id</a> value.
2100-
</td>
2101-
</tr>
2102-
<tr>
2103-
<td><dfn>[[\RecordType]]</dfn></td>
2104-
<td>`undefined`</td>
2105-
<td>
2106-
The {{NDEFScanOptions}}.<a>recordType</a> value.
2107-
</td>
2108-
</tr>
2109-
<tr>
2110-
<td><dfn>[[\MediaType]]</dfn></td>
2111-
<td>`undefined`</td>
2112-
<td>
2113-
The {{NDEFScanOptions}}.<a>mediaType</a> value.
2114-
</td>
2115-
</tr>
21162097
<tr>
21172098
<td><dfn>[[\Signal]]</dfn></td>
21182099
<td>`undefined`</td>
@@ -2123,13 +2104,6 @@ <h2>The <dfn>record type</dfn> string</h2>
21232104
</tbody>
21242105
</table>
21252106

2126-
<p class="note">
2127-
Note that the internal slots of {{NDEFReader}} come from the
2128-
|options:NDEFScanOptions| passed to <a>NDEFReader.scan()</a>.
2129-
Therefore there is maximum one filter associated with any given
2130-
{{NDEFReader}} object and successive invocations of <a>NDEFReader.scan()</a>
2131-
with new |options:NDEFScanOptions| will replace existing filters.
2132-
</p>
21332107
<p>
21342108
The <dfn data-dfn-for="NDEFReader">onreading</dfn> is an {{EventHandler}}
21352109
which is called to notify that new reading is available.
@@ -2364,60 +2338,18 @@ <h3>The <dfn>NDEFWriteOptions</dfn> dictionary</h3>
23642338
<section data-dfn-for="NDEFScanOptions">
23652339
<h3>The <dfn>NDEFScanOptions</dfn> dictionary</h3>
23662340
<p>
2367-
To describe which messages an application is interested in, the
2368-
<a>NDEFScanOptions</a> dictionary is used:
2341+
To stop listening to NDEF messages, an [= AbortSignal/aborted flag =]
2342+
can be used in the <a>NDEFScanOptions</a> dictionary:
23692343
</p>
23702344
<pre class="idl">
23712345
dictionary NDEFScanOptions {
2372-
USVString id;
2373-
USVString recordType;
2374-
USVString mediaType;
2375-
AbortSignal? signal;
2346+
AbortSignal signal;
23762347
};
23772348
</pre>
23782349
<p>
23792350
The <dfn>signal</dfn> property allows to abort the
23802351
{{NDEFReader/scan()}} operation.
23812352
</p>
2382-
<p>
2383-
The <dfn>id</dfn> property
2384-
denotes the string value which is used for matching the
2385-
<a>record identifier</a> of each
2386-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2387-
If the dictionary member is not present,
2388-
then it will be ignored by the
2389-
<a href="#steps-listen">NFC listen algorithm</a>.
2390-
</p>
2391-
<p>
2392-
The <dfn>recordType</dfn> property
2393-
denotes the string value which is used for matching the
2394-
<a>record type</a> of each
2395-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2396-
If the dictionary member is not present,
2397-
then it will be ignored by the
2398-
<a href="#steps-listen">NFC listen algorithm</a>.
2399-
</p>
2400-
<p>
2401-
The <dfn>mediaType</dfn> property
2402-
denotes the <a>match pattern</a> which is used for matching the
2403-
{{NDEFRecord/mediaType}} property of each
2404-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2405-
</p>
2406-
<pre
2407-
title="Filter accepting only JSON content"
2408-
class="example highlight">
2409-
const options = {
2410-
mediaType: "application/*json" // any JSON-based MIME type
2411-
}
2412-
</pre>
2413-
<pre
2414-
title="Filter which only accepts binary content for a custom record identifier"
2415-
class="example highlight">
2416-
const options = {
2417-
id: "my-restaurant-daily-menu",
2418-
mediaType: "application/octet-stream"
2419-
}
2420-
</pre>
24212353
</section> <!-- NDEFScanOptions -->
24222354

24232355
<section id="writing-content">
@@ -3522,28 +3454,6 @@ <h3><dfn>Writing content</dfn></h3>
35223454
then the <a>UA</a> MUST listen to <a>NDEF message</a>s on all connected
35233455
NFC adapters.
35243456
</p>
3525-
<p>
3526-
Each {{NDEFReader}} can accept <a>NDEF message</a>s based on
3527-
data type, and record identifier filters.
3528-
</p>
3529-
3530-
<section> <h3>Match patterns</h3>
3531-
<div>
3532-
A <dfn>match pattern</dfn> is defined by the following ABNF:
3533-
<pre class="abnf">
3534-
match-pattern = top-level-type "/" [ tree "." ] subtype [ "+" suffix ] [ ";" parameters ]
3535-
top-level-type = "*" / &lt; VCHAR except "/" and "*" &gt;
3536-
subtype = "*" / &lt; VCHAR except "+" &gt;
3537-
</pre>
3538-
A <a>match pattern</a> is a
3539-
<a href="http://pubs.opengroup.org/onlinepubs/007904875/utilities/xcu_chap02.html#tag_02_13_03">
3540-
glob</a> used for matching <a>MIME type</a>s,
3541-
for instance the pattern "`application/*+json`" matches
3542-
"`application/calendar+json`", but does not match
3543-
"`application/json`". The pattern
3544-
"`*/*json`", on the other hand, matches both.
3545-
</div>
3546-
</section>
35473457

35483458
<section> <h3>The <strong>scan()</strong> method</h3>
35493459
<p>
@@ -3570,18 +3480,6 @@ <h3><dfn>Writing content</dfn></h3>
35703480
If |key| equals "`signal`" and |value| is not `undefined`, set
35713481
|reader|.<a>[[\Signal]]</a> to |value|.
35723482
</li>
3573-
<li>
3574-
Otherwise, if |key| equals "`id`", set
3575-
|reader|.<a>[[\Id]]</a> to |value|.
3576-
</li>
3577-
<li>
3578-
Otherwise, if |key| equals "`recordType`", set
3579-
|reader|.<a>[[\RecordType]]</a> to |value|.
3580-
</li>
3581-
<li>
3582-
Otherwise, if |key| equals "`mediaType`", set
3583-
|reader|.<a>[[\MediaType]]</a> to |value|.
3584-
</li>
35853483
</ol>
35863484
</li>
35873485
<li>
@@ -3726,49 +3624,13 @@ <h3><dfn>Writing content</dfn></h3>
37263624
<ol class=algorithm>
37273625
<li>
37283626
[= list/For each =] {{NDEFReader}} instance |reader:NDEFReader| in
3729-
the <a>activated reader objects</a>, run the following sub-steps:
3627+
the <a>activated reader objects</a>,
37303628
<ol>
37313629
<li>
3732-
[= list/For each =] |record:NDEFRecord| in |message:NDEFMessage|,
3733-
<ol>
3734-
<li>
3735-
Let |matched:boolean| be `false`.
3736-
</li>
3737-
<li>
3738-
If |reader|.<a>[[\Id]]</a> is not `undefined` and is not equal
3739-
to |record|'s <a href="#dom-ndefrecord-id">id</a>,
3740-
[= iteration/continue =].
3741-
If it is equal, set |matched| to `true`.
3742-
</li>
3743-
<li>
3744-
If |reader|.<a>[[\RecordType]]</a> is not `undefined` and is
3745-
not equal to |record|'s
3746-
<a href="#dom-ndefrecord-recordtype">recordType</a>,
3747-
[= iteration/continue =].
3748-
If it is equal, set |matched| to `true`.
3749-
</li>
3750-
<li>
3751-
If |reader|.<a>[[\MediaType]]</a> is not `undefined` and is not
3752-
equal to
3753-
|record|'s <a href="#dom-ndefrecord-mediatype">mediaType</a>,
3754-
[= iteration/continue =].
3755-
If it is equal, set |matched| to `true`.
3756-
</li>
3757-
<li>
3758-
If |matched| is `true`,
3759-
<ol>
3760-
<li>
3761-
<a>fire an event</a> named "`reading`"
3762-
at |reader| using <a>NDEFReadingEvent</a> with its
3763-
<a>serialNumber</a> attribute initialized to |serialNumber|
3764-
and <a>message</a> attribute initialized to |message|.
3765-
</li>
3766-
<li>
3767-
[= iteration/Break =].
3768-
</li>
3769-
</ol>
3770-
</li>
3771-
</ol>
3630+
<a>fire an event</a> named "`reading`" at |reader| using
3631+
<a>NDEFReadingEvent</a> with its <a>serialNumber</a> attribute
3632+
initialized to |serialNumber| and <a>message</a> attribute
3633+
initialized to |message|.
37723634
</li>
37733635
</ol>
37743636
</li>

0 commit comments

Comments
 (0)