Skip to content

Commit 28fb4aa

Browse files
authored
Merge pull request #368 from w3c/issue-339-example
A couple of small fixes to the example code
2 parents 5d2869b + 7395ba2 commit 28fb4aa

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

index.html

+12-14
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,15 @@ <h2>
442442
a Promise</a></dfn> are used as explained in [[!PROMGUIDE]].
443443
</p>
444444
<p>
445-
The term <dfn><a href=
446-
"https://url.spec.whatwg.org/#url">URL</a></dfn> is defined in the
447-
WHATWG URL standard [[!URL]].
445+
The term <dfn><a href="https://url.spec.whatwg.org/#url">URL</a></dfn>
446+
is defined in the WHATWG URL standard [[!URL]].
448447
</p>
449448
<p>
450449
The terms <dfn><a href=
451450
"https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object">
452451
current settings object</a></dfn> and <dfn><a href=
453-
"https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">relevant
454-
settings object</a></dfn> are defined in [[HTML]].
452+
"https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object">
453+
relevant settings object</a></dfn> are defined in [[HTML]].
455454
</p>
456455
<p>
457456
The term <dfn><a href=
@@ -628,6 +627,7 @@ <h3>
628627
// On navigation of the controller, reconnect automatically.
629628
document.addEventListener("DOMContentLoaded", reconnect);
630629
// Or allow manual reconnection.
630+
const reconnectBtn = document.querySelector("#reconnectBtn");
631631
reconnectBtn.onclick = reconnect;
632632
&lt;/script&gt;
633633
</pre>
@@ -658,26 +658,24 @@ <h3>
658658
&lt;!-- controller.html --&gt;
659659
&lt;button id="disconnectBtn" style="display: none;"&gt;Disconnect&lt;/button&gt;
660660
&lt;button id="stopBtn" style="display: none;"&gt;Stop&lt;/button&gt;
661-
&lt;button id="reconnectBtn" style="display: none;"&gt;Reconnect&lt;/button&gt;
662661
&lt;script&gt;
663662
let connection;
664663

665664
// The Disconnect and Stop buttons are visible if there is a connected presentation
666665
const stopBtn = document.querySelector("#stopBtn");
667-
const reconnectBtn = document.querySelector("#reconnectBtn");
668666
const disconnectBtn = document.querySelector("#disconnectBtn");
669667

670-
stopBtn.onclick = _ => {
668+
stopBtn.onclick = _ =&gt; {
671669
connection &amp;&amp; connection.terminate();
672670
};
673671

674-
disconnectBtn.onclick = _ => {
672+
disconnectBtn.onclick = _ =&gt; {
675673
connection &amp;&amp; connection.close();
676674
};
677675

678676
function setConnection(newConnection) {
679677
// Disconnect from existing presentation, if not attempting to reconnect
680-
if (connection &amp;&amp; connection != newConnection && connection.state != 'closed') {
678+
if (connection &amp;&amp; connection != newConnection &amp;&amp; connection.state != 'closed') {
681679
connection.onclosed = undefined;
682680
connection.close();
683681
}
@@ -700,24 +698,24 @@ <h3>
700698
}
701699

702700
// Monitor the connection state
703-
connection.onconnect = _ => {
701+
connection.onconnect = _ =&gt; {
704702
showConnectedUI();
705703

706704
// Register message handler
707-
connection.onmessage = message => {
705+
connection.onmessage = message =&gt; {
708706
console.log(`Received message: ${message.data}`);
709707
};
710708

711709
// Send initial message to presentation page
712710
connection.send("Say hello");
713711
};
714712

715-
connection.onclose = _ => {
713+
connection.onclose = _ =&gt; {
716714
connection = null;
717715
showDisconnectedUI();
718716
};
719717

720-
connection.onterminate = _ => {
718+
connection.onterminate = _ =&gt; {
721719
// Remove presId from localStorage if exists
722720
delete localStorage["presId"];
723721
connection = null;

0 commit comments

Comments
 (0)