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
6 .find((row) =
> row.startsWith(
"broadcast_session="))
8 const socket = new WebSocket(
"/web-ws");
9 socket.addEventListener(
"open", (event) =
> {
10 socket.send(cookieValue);
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;
17 socket.addEventListener(
"close", (event) =
> {
18 console.log(
"Websocket closed. Will retry in 10 seconds.")
19 setTimeout(connectWebsocket,
10000);
22 // initial connection on page load
28 <p>Your username is: {{.Username}}.
</p>
29 <p><a href=
"/logout">Log Out
</a></p>
31 <p><a href=
"/login">Log In
</a></p>
33 <p><a href=
"/files/">File Management
</a></p>
34 <p><a href=
"/playlists/">Playlist Management
</a></p>
35 <p><a href=
"/radios/">Radio Management
</a></p>
36 <h2>Connected Radios
</h2>
37 <div id=
"connected-radios">