Skip to content

Commit 579613b

Browse files
committed
Fix #560: remove filtering
Signed-off-by: Zoltan Kis <[email protected]>
1 parent 9f15d9a commit 579613b

File tree

1 file changed

+18
-157
lines changed

1 file changed

+18
-157
lines changed

index.html

Lines changed: 18 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,15 +1065,17 @@ <h4>
10651065
<section> <h3>Save and restore game progress with an NFC tag</h3>
10661066
<p>
10671067
Filtering of relevant data sources can be done by the use of
1068-
the <a>NDEFScanOptions</a>. Below we use the custom record identifier
1069-
"`my-game-progress`" as a relative URL so that when we read the data, we
1070-
immediately update the game progress by issuing a write with a custom NDEF
1071-
data layout.
1068+
a custom record identifier, in this case "`my-game-progress`".
1069+
When we read the data, we immediately update the game progress by issuing
1070+
a write with a custom NDEF data layout.
10721071
</p>
10731072
<pre class="example">
10741073
const reader = new NDEFReader();
1075-
await reader.scan({ id: "my-game-progress" });
1074+
await reader.scan();
10761075
reader.onreading = async event => {
1076+
if (event.message.id !== "my-game-progress")
1077+
return;
1078+
10771079
console.log(`Game state: ${ JSON.stringify(event.message.records) }`);
10781080

10791081
const encoder = new TextEncoder();
@@ -1102,9 +1104,7 @@ <h4>
11021104
</p>
11031105
<pre class="example">
11041106
const reader = new NDEFReader();
1105-
await reader.scan({
1106-
mediaType: "application/*json"
1107-
});
1107+
await reader.scan();
11081108
reader.onreading = event => {
11091109
const decoder = new TextDecoder();
11101110
for (const record of event.message.records) {
@@ -1259,7 +1259,7 @@ <h4>
12591259
</p>
12601260
<pre class="example">
12611261
const reader = new NDEFReader();
1262-
await reader.scan({ recordType: "example.com:smart-poster" });
1262+
await reader.scan();
12631263
reader.onreading = event => {
12641264
const externalRecord = event.message.records.find(
12651265
record => record.type == "example.com:smart-poster"
@@ -1352,10 +1352,11 @@ <h4>
13521352
</pre>
13531353
<pre class="example">
13541354
const reader = new NDEFReader();
1355-
await reader.scan({ recordType: "example.com:shoppingItem" });
1355+
await reader.scan();
13561356
reader.onreading = event => {
13571357
const shoppingItemRecord = event.message.records[0];
1358-
if (!shoppingItemRecord) {
1358+
if (!shoppingItemRecord ||
1359+
shoppingItemRecord.recordType !== "example.com:shoppingItem") {
13591360
return;
13601361
}
13611362

@@ -1913,27 +1914,6 @@ <h2>The <dfn>record type</dfn> string</h2>
19131914
</tr>
19141915
</thead>
19151916
<tbody data-link-for="NDEFScanOptions">
1916-
<tr>
1917-
<td><dfn>[[\Id]]</dfn></td>
1918-
<td>`undefined`</td>
1919-
<td>
1920-
The {{NDEFScanOptions}}.<a>id</a> value.
1921-
</td>
1922-
</tr>
1923-
<tr>
1924-
<td><dfn>[[\RecordType]]</dfn></td>
1925-
<td>`undefined`</td>
1926-
<td>
1927-
The {{NDEFScanOptions}}.<a>recordType</a> value.
1928-
</td>
1929-
</tr>
1930-
<tr>
1931-
<td><dfn>[[\MediaType]]</dfn></td>
1932-
<td>`undefined`</td>
1933-
<td>
1934-
The {{NDEFScanOptions}}.<a>mediaType</a> value.
1935-
</td>
1936-
</tr>
19371917
<tr>
19381918
<td><dfn>[[\Signal]]</dfn></td>
19391919
<td>`undefined`</td>
@@ -1944,13 +1924,6 @@ <h2>The <dfn>record type</dfn> string</h2>
19441924
</tbody>
19451925
</table>
19461926

1947-
<p class="note">
1948-
Note that the internal slots of {{NDEFReader}} come from the
1949-
|options:NDEFScanOptions| passed to <a>NDEFReader.scan()</a>.
1950-
Therefore there is maximum one filter associated with any given
1951-
{{NDEFReader}} object and successive invocations of <a>NDEFReader.scan()</a>
1952-
with new |options:NDEFScanOptions| will replace existing filters.
1953-
</p>
19541927
<p>
19551928
The <dfn data-dfn-for="NDEFReader">onreading</dfn> is an {{EventHandler}}
19561929
which is called to notify that new reading is available.
@@ -2191,60 +2164,18 @@ <h3>The <dfn>NDEFWriteOptions</dfn> dictionary</h3>
21912164
<section data-dfn-for="NDEFScanOptions">
21922165
<h3>The <dfn>NDEFScanOptions</dfn> dictionary</h3>
21932166
<p>
2194-
To describe which messages an application is interested in, the
2167+
To pass an [= AbortSignal/aborted flag =], the
21952168
<a>NDEFScanOptions</a> dictionary is used:
21962169
</p>
21972170
<pre class="idl">
21982171
dictionary NDEFScanOptions {
2199-
USVString id;
2200-
USVString recordType;
2201-
USVString mediaType;
22022172
AbortSignal? signal;
22032173
};
22042174
</pre>
22052175
<p>
22062176
The <dfn>signal</dfn> property allows to abort the
22072177
[=NDEFReader/scan()=] operation.
22082178
</p>
2209-
<p>
2210-
The <dfn>id</dfn> property
2211-
denotes the string value which is used for matching the
2212-
<a>record identifier</a> of each
2213-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2214-
If the dictionary member is not present,
2215-
then it will be ignored by the
2216-
<a href="#steps-listen">NFC listen algorithm</a>.
2217-
</p>
2218-
<p>
2219-
The <dfn>recordType</dfn> property
2220-
denotes the string value which is used for matching the
2221-
<a>record type</a> of each
2222-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2223-
If the dictionary member is not present,
2224-
then it will be ignored by the
2225-
<a href="#steps-listen">NFC listen algorithm</a>.
2226-
</p>
2227-
<p>
2228-
The <dfn>mediaType</dfn> property
2229-
denotes the <a>match pattern</a> which is used for matching the
2230-
[=NDEFRecord/mediaType=] property of each
2231-
<a>NDEFRecord</a> object in an <a>NDEF message</a>.
2232-
</p>
2233-
<pre
2234-
title="Filter accepting only JSON content"
2235-
class="example highlight">
2236-
const options = {
2237-
mediaType: "application/*json" // any JSON-based MIME type
2238-
}
2239-
</pre>
2240-
<pre
2241-
title="Filter which only accepts binary content for a custom record identifier"
2242-
class="example highlight">
2243-
const options = {
2244-
id: "my-restaurant-daily-menu",
2245-
mediaType: "application/octet-stream"
2246-
}
2247-
</pre>
22482179
</section> <!-- NDEFScanOptions -->
22492180

22502181
<section id="writing-content">
@@ -3349,28 +3280,6 @@ <h3><dfn>Writing content</dfn></h3>
33493280
then the <a>UA</a> MUST listen to <a>NDEF message</a>s on all connected
33503281
NFC adapters.
33513282
</p>
3352-
<p>
3353-
Each {{NDEFReader}} can accept <a>NDEF message</a>s based on
3354-
data type, and record identifier filters.
3355-
</p>
3356-
3357-
<section> <h3>Match patterns</h3>
3358-
<div>
3359-
A <dfn>match pattern</dfn> is defined by the following ABNF:
3360-
<pre class="abnf">
3361-
match-pattern = top-level-type "/" [ tree "." ] subtype [ "+" suffix ] [ ";" parameters ]
3362-
top-level-type = "*" / &lt; VCHAR except "/" and "*" &gt;
3363-
subtype = "*" / &lt; VCHAR except "+" &gt;
3364-
</pre>
3365-
A <a>match pattern</a> is a
3366-
<a href="http://pubs.opengroup.org/onlinepubs/007904875/utilities/xcu_chap02.html#tag_02_13_03">
3367-
glob</a> used for matching <a>MIME type</a>s,
3368-
for instance the pattern "`application/*+json`" matches
3369-
"`application/calendar+json`", but does not match
3370-
"`application/json`". The pattern
3371-
"`*/*json`", on the other hand, matches both.
3372-
</div>
3373-
</section>
33743283

33753284
<section> <h3>The <strong>scan()</strong> method</h3>
33763285
<p>
@@ -3397,18 +3306,6 @@ <h3><dfn>Writing content</dfn></h3>
33973306
If |key| equals "`signal`" and |value| is not `undefined`, set
33983307
|reader|.<a>[[\Signal]]</a> to |value|.
33993308
</li>
3400-
<li>
3401-
Otherwise, if |key| equals "`id`", set
3402-
|reader|.<a>[[\Id]]</a> to |value|.
3403-
</li>
3404-
<li>
3405-
Otherwise, if |key| equals "`recordType`", set
3406-
|reader|.<a>[[\RecordType]]</a> to |value|.
3407-
</li>
3408-
<li>
3409-
Otherwise, if |key| equals "`mediaType`", set
3410-
|reader|.<a>[[\MediaType]]</a> to |value|.
3411-
</li>
34123309
</ol>
34133310
</li>
34143311
<li>
@@ -3556,49 +3453,13 @@ <h3><dfn>Writing content</dfn></h3>
35563453
<ol class=algorithm>
35573454
<li>
35583455
[= list/For each =] {{NDEFReader}} instance |reader:NDEFReader| in
3559-
the <a>activated reader objects</a>, run the following sub-steps:
3456+
the <a>activated reader objects</a>,
35603457
<ol>
35613458
<li>
3562-
[= list/For each =] |record:NDEFRecord| in |message:NDEFMessage|,
3563-
<ol>
3564-
<li>
3565-
Let |matched:boolean| be `false`.
3566-
</li>
3567-
<li>
3568-
If |reader|.<a>[[\Id]]</a> is not `undefined` and is not equal
3569-
to |record|'s <a href="#dom-ndefrecord-id">id</a>,
3570-
[= iteration/continue =].
3571-
If it is equal, set |matched| to `true`.
3572-
</li>
3573-
<li>
3574-
If |reader|.<a>[[\RecordType]]</a> is not `undefined` and is
3575-
not equal to |record|'s
3576-
<a href="#dom-ndefrecord-recordtype">recordType</a>,
3577-
[= iteration/continue =].
3578-
If it is equal, set |matched| to `true`.
3579-
</li>
3580-
<li>
3581-
If |reader|.<a>[[\MediaType]]</a> is not `undefined` and is not
3582-
equal to
3583-
|record|'s <a href="#dom-ndefrecord-mediatype">mediaType</a>,
3584-
[= iteration/continue =].
3585-
If it is equal, set |matched| to `true`.
3586-
</li>
3587-
<li>
3588-
If |matched| is `true`,
3589-
<ol>
3590-
<li>
3591-
<a>fire an event</a> named "`reading`"
3592-
at |reader| using <a>NDEFReadingEvent</a> with its
3593-
<a>serialNumber</a> attribute initialized to |serialNumber|
3594-
and <a>message</a> attribute initialized to |message|.
3595-
</li>
3596-
<li>
3597-
[= iteration/Break =].
3598-
</li>
3599-
</ol>
3600-
</li>
3601-
</ol>
3459+
<a>fire an event</a> named "`reading`" at |reader| using
3460+
<a>NDEFReadingEvent</a> with its <a>serialNumber</a> attribute
3461+
initialized to |serialNumber| and <a>message</a> attribute
3462+
initialized to |message|.
36023463
</li>
36033464
</ol>
36043465
</li>

0 commit comments

Comments
 (0)