mirror of
https://github.com/sanderfoobar/ircradio.git
synced 2024-12-23 11:12:41 +01:00
Script to open websocket for #now_playing updates
This commit is contained in:
parent
c7a48d2bd9
commit
9716feab33
@ -30,6 +30,26 @@
|
|||||||
<title>IRC!Radio</title>
|
<title>IRC!Radio</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var ws = new WebSocket('wss://' + document.domain + ':' + location.port + '/ws');
|
||||||
|
|
||||||
|
ws.onmessage = function (event) {
|
||||||
|
// console.log(event.data);
|
||||||
|
json = JSON.parse(event.data);
|
||||||
|
np = json.now_playing;
|
||||||
|
document.querySelector("#now_playing").innerText = np;
|
||||||
|
// console.log(np);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onclose = function(event) {
|
||||||
|
console.log("WebSocket is closed now.");
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user