]> code.octet-stream.net Git - broadcaster/blob - server/templates/index.html
Make headings consistent in UI
[broadcaster] / server / templates / index.html
1 <script type="text/javascript">
2 function connectWebsocket() {
3 console.log("Attempting to create websocket connection for radio status sync")
4 const cookieValue = document.cookie
5 .split("; ")
6 .find((row) => row.startsWith("broadcast_session="))
7 ?.split("=")[1];
8 const socket = new WebSocket("/web-ws");
9 socket.addEventListener("open", (event) => {
10 socket.send(cookieValue);
11 });
12 socket.addEventListener("message", (event) => {
13 console.log("Received a status update from server")
14 const connected = document.getElementById('connected-radios');
15 connected.innerHTML = event.data;
16 });
17 socket.addEventListener("close", (event) => {
18 console.log("Websocket closed. Will retry in 10 seconds.")
19 setTimeout(connectWebsocket, 10000);
20 });
21 }
22 // initial connection on page load
23 connectWebsocket();
24 </script>
25 <h1>Connected Radios</h1>
26 <div id="connected-radios">
27 <i>Loading...</i>
28 </div>