@@ -442,16 +442,15 @@ <h2>
442
442
a Promise</ a > </ dfn > are used as explained in [[!PROMGUIDE]].
443
443
</ p >
444
444
< 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]].
448
447
</ p >
449
448
< p >
450
449
The terms < dfn > < a href =
451
450
"https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object ">
452
451
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]].
455
454
</ p >
456
455
< p >
457
456
The term < dfn > < a href =
628
627
// On navigation of the controller, reconnect automatically.
629
628
document.addEventListener("DOMContentLoaded", reconnect);
630
629
// Or allow manual reconnection.
630
+ const reconnectBtn = document.querySelector("#reconnectBtn");
631
631
reconnectBtn.onclick = reconnect;
632
632
</script>
633
633
</ pre >
@@ -658,26 +658,24 @@ <h3>
658
658
<!-- controller.html -->
659
659
<button id="disconnectBtn" style="display: none;">Disconnect</button>
660
660
<button id="stopBtn" style="display: none;">Stop</button>
661
- <button id="reconnectBtn" style="display: none;">Reconnect</button>
662
661
<script>
663
662
let connection;
664
663
665
664
// The Disconnect and Stop buttons are visible if there is a connected presentation
666
665
const stopBtn = document.querySelector("#stopBtn");
667
- const reconnectBtn = document.querySelector("#reconnectBtn");
668
666
const disconnectBtn = document.querySelector("#disconnectBtn");
669
667
670
- stopBtn.onclick = _ => {
668
+ stopBtn.onclick = _ => {
671
669
connection && connection.terminate();
672
670
};
673
671
674
- disconnectBtn.onclick = _ => {
672
+ disconnectBtn.onclick = _ => {
675
673
connection && connection.close();
676
674
};
677
675
678
676
function setConnection(newConnection) {
679
677
// Disconnect from existing presentation, if not attempting to reconnect
680
- if (connection && connection != newConnection && connection.state != 'closed') {
678
+ if (connection && connection != newConnection && connection.state != 'closed') {
681
679
connection.onclosed = undefined;
682
680
connection.close();
683
681
}
@@ -700,24 +698,24 @@ <h3>
700
698
}
701
699
702
700
// Monitor the connection state
703
- connection.onconnect = _ => {
701
+ connection.onconnect = _ => {
704
702
showConnectedUI();
705
703
706
704
// Register message handler
707
- connection.onmessage = message => {
705
+ connection.onmessage = message => {
708
706
console.log(`Received message: ${message.data}`);
709
707
};
710
708
711
709
// Send initial message to presentation page
712
710
connection.send("Say hello");
713
711
};
714
712
715
- connection.onclose = _ => {
713
+ connection.onclose = _ => {
716
714
connection = null;
717
715
showDisconnectedUI();
718
716
};
719
717
720
- connection.onterminate = _ => {
718
+ connection.onterminate = _ => {
721
719
// Remove presId from localStorage if exists
722
720
delete localStorage["presId"];
723
721
connection = null;
0 commit comments