forked from rfa/radioweb
clean up
This commit is contained in:
parent
65be5202ed
commit
3e787b486f
38
index.html
38
index.html
@ -13,10 +13,14 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
|
||||
<audio id="player" controls src="https://radio.anarchyplanet.org:8443/radio.ogg">
|
||||
<audio id="player" controls="controls" preload="all" src="https://radio.anarchyplanet.org:8443/radio.ogg">
|
||||
Your browser does not support the HTML5 Audio element.
|
||||
</audio>
|
||||
<ul id="history"><li><div class="spinner"></div></li></ul>
|
||||
|
||||
<ul id="history">
|
||||
<li><div class="spinner"></div></li>
|
||||
</ul>
|
||||
|
||||
<footer>
|
||||
<p>Ⓐ</p>
|
||||
</footer>
|
||||
@ -25,15 +29,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var url = 'wss://radio.anarchyplanet.org/ws';
|
||||
var audioUrl = "https://radio.anarchyplanet.org:8443/radio.ogg";
|
||||
|
||||
var player = document.getElementById('player');
|
||||
var rng = Math.floor(Math.random() * 10000);
|
||||
player.src = player.src + '?nocache=' + rng;
|
||||
player.onerror = play;
|
||||
player.onended = play;
|
||||
|
||||
var hist = document.getElementById("history");
|
||||
|
||||
function update(msg) {
|
||||
document.title = msg.data + " - APR";
|
||||
|
||||
var hist = document.getElementById("history");
|
||||
|
||||
hist.insertAdjacentHTML("afterbegin", `<li>${msg.data}</li>`);
|
||||
|
||||
if(hist.childElementCount >= 10) {
|
||||
@ -42,22 +49,35 @@
|
||||
};
|
||||
|
||||
function connect() {
|
||||
var url = 'wss://radio.anarchyplanet.org/ws';
|
||||
var ws = new WebSocket(url);
|
||||
|
||||
ws.onmessage = function(e) {
|
||||
update(e);
|
||||
ws.onopen = function(e) {
|
||||
hist.innerHTML = "";
|
||||
};
|
||||
|
||||
ws.onclose = function(e) {
|
||||
hist.innerHTML = '<li><div class="spinner"></div></li>';
|
||||
setTimeout(connect, 1000);
|
||||
};
|
||||
|
||||
ws.onerror = function(e) {
|
||||
ws.close();
|
||||
};
|
||||
|
||||
ws.onmessage = function(e) {
|
||||
update(e);
|
||||
};
|
||||
}
|
||||
|
||||
function play(e) {
|
||||
if(e !== undefined) console.log(e);
|
||||
var rng = Math.floor(Math.random() * 1000000);
|
||||
player.src = audioUrl + '?nocache=' + rng;
|
||||
player.load();
|
||||
player.play();
|
||||
}
|
||||
|
||||
play();
|
||||
connect();
|
||||
</script>
|
||||
<noscript>Enable javascript for song information.</noscript>
|
||||
|
Loading…
Reference in New Issue
Block a user