aboutsummaryrefslogtreecommitdiffstats
path: root/static/scripts/spotify.js
blob: e6551a8ede0bf5cdec21600a9706a1ead9f885f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
const connectWebsocket = () => {
    document.getElementById('connection-status').innerHTML = "Connecting...";
    let url = new URL(window.location.href);
    url.protocol = url.protocol.replace('http', 'ws');
    const socket = new WebSocket(url);
    socket.onmessage = (event) => {
        const data = JSON.parse(event.data);
        console.log(data);
    }
}

document.addEventListener("DOMContentLoaded", connectWebsocket);