Skip to content

Commit f958dbf

Browse files
committed
Add 'set the application badge for installed web application' algo
1 parent cfeb3f2 commit f958dbf

File tree

1 file changed

+72
-22
lines changed

1 file changed

+72
-22
lines changed

index.html

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ <h2>
101101
</pre>
102102
<p data-cite="notifications">
103103
On some operating systems [=badge/setting=] a badge can require
104-
permission from the user. In this case, a developer need to query the
104+
permission from the user. In this case, a developer needs to query the
105105
"[=notifications=]" permissions status before [=badge/setting=] a
106106
badge. If the permission is not granted, the developer will need to
107107
prompt for permission via the
@@ -267,6 +267,34 @@ <h3>
267267
<h2>
268268
Setting the application badge
269269
</h2>
270+
<p>
271+
To <dfn>set badge value</dfn> given a [=badge=] |badge| and an optional
272+
{{unsigned long long}} |contents| value:
273+
</p>
274+
<ol class="algorithm">
275+
<li>Switching on |contents|, if it happens to be the case that:
276+
<dl class="switch">
277+
<dt>
278+
|contents| was not passed:
279+
</dt>
280+
<dd>
281+
[=badge/Set=] |badge| to [=badge/"flag"=].
282+
</dd>
283+
<dt>
284+
|contents| is 0:
285+
</dt>
286+
<dd>
287+
[=badge/Set=] |badge| to [=badge/"nothing"=].
288+
</dd>
289+
<dt>
290+
|contents|:
291+
</dt>
292+
<dd>
293+
[=badge/Set=] |badge| to |contents|.
294+
</dd>
295+
</dl>
296+
</li>
297+
</ol>
270298
<p>
271299
To <dfn>set the application badge</dfn> of platform object
272300
|context:platform object| to an optional {{unsigned long long}}
@@ -306,27 +334,10 @@ <h2>
306334
</li>
307335
</ol>
308336
</li>
309-
<li>Switching on |contents|, if it happens to be the case that:
310-
<dl class="switch">
311-
<dt>
312-
|contents| was not passed:
313-
</dt>
314-
<dd>
315-
[=badge/Set=] |badge| to [=badge/"flag"=].
316-
</dd>
317-
<dt>
318-
|contents| is 0:
319-
</dt>
320-
<dd>
321-
[=badge/Set=] |badge| to [=badge/"nothing"=].
322-
</dd>
323-
<dt>
324-
|contents|:
325-
</dt>
326-
<dd>
327-
[=badge/Set=] |badge| to |contents|.
328-
</dd>
329-
</dl>
337+
<li>Let |badge| be the [=installed web application=]'s associated
338+
[=badge=].
339+
</li>
340+
<li>[=Set badge value=] given |badge| and |contents|.
330341
</li>
331342
<li>[=Queue a global task=] on the [=DOM manipulation task source=]
332343
given |global| to [=resolve=] |promise| with `undefined`.
@@ -336,6 +347,45 @@ <h2>
336347
<li>Return |promise|.
337348
</li>
338349
</ol>
350+
<p>
351+
To <dfn class="export">set the application badge for an installed web
352+
application</dfn> given a URL |appId| and either a {{boolean}} or
353+
{{unsigned long long}} |contents| value. It returns a boolean
354+
indicating whether the operation was successful:
355+
</p>
356+
<ol class="algorithm">
357+
<li>Let |app| be the [=installed web application=] identified by
358+
|appId|.
359+
</li>
360+
<li>If no such [=installed web application=] exists, return false.
361+
</li>
362+
<li>Let |badge| be |app|'s associated [=badge=].
363+
</li>
364+
<li>[=In parallel=]:
365+
<dl class="switch">
366+
<dt>
367+
|contents| is `true`:
368+
</dt>
369+
<dd>
370+
[=badge/Set=] |badge| to [=badge/"flag"=].
371+
</dd>
372+
<dt>
373+
|contents| is `false` or 0:
374+
</dt>
375+
<dd>
376+
[=badge/Set=] |badge| to [=badge/"nothing"=].
377+
</dd>
378+
<dt>
379+
Otherwise:
380+
</dt>
381+
<dd>
382+
[=badge/Set=] |badge| to |contents|.
383+
</dd>
384+
</dl>
385+
</li>
386+
<li>Return true.
387+
</li>
388+
</ol>
339389
</section>
340390
<section>
341391
<h2>

0 commit comments

Comments
 (0)