mirror of
https://github.com/sanderfoobar/ircradio.git
synced 2024-12-23 03:02:46 +01:00
Script to open websocket for #now_playing updates
This commit is contained in:
parent
c7a48d2bd9
commit
9716feab33
@ -30,9 +30,29 @@
|
|||||||
<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>
|
||||||
{% block content %} {% endblock %}
|
{% block content %} {% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user