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="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
|
<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.
|
Your browser does not support the HTML5 Audio element.
|
||||||
</audio>
|
</audio>
|
||||||
<ul id="history"><li><div class="spinner"></div></li></ul>
|
|
||||||
|
<ul id="history">
|
||||||
|
<li><div class="spinner"></div></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>Ⓐ</p>
|
<p>Ⓐ</p>
|
||||||
</footer>
|
</footer>
|
||||||
@ -25,15 +29,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
|
var url = 'wss://radio.anarchyplanet.org/ws';
|
||||||
|
var audioUrl = "https://radio.anarchyplanet.org:8443/radio.ogg";
|
||||||
|
|
||||||
var player = document.getElementById('player');
|
var player = document.getElementById('player');
|
||||||
var rng = Math.floor(Math.random() * 10000);
|
player.onerror = play;
|
||||||
player.src = player.src + '?nocache=' + rng;
|
player.onended = play;
|
||||||
|
|
||||||
|
var hist = document.getElementById("history");
|
||||||
|
|
||||||
function update(msg) {
|
function update(msg) {
|
||||||
document.title = msg.data + " - APR";
|
document.title = msg.data + " - APR";
|
||||||
|
|
||||||
var hist = document.getElementById("history");
|
|
||||||
|
|
||||||
hist.insertAdjacentHTML("afterbegin", `<li>${msg.data}</li>`);
|
hist.insertAdjacentHTML("afterbegin", `<li>${msg.data}</li>`);
|
||||||
|
|
||||||
if(hist.childElementCount >= 10) {
|
if(hist.childElementCount >= 10) {
|
||||||
@ -42,22 +49,35 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
var url = 'wss://radio.anarchyplanet.org/ws';
|
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
|
|
||||||
ws.onmessage = function(e) {
|
ws.onopen = function(e) {
|
||||||
update(e);
|
hist.innerHTML = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onclose = function(e) {
|
ws.onclose = function(e) {
|
||||||
|
hist.innerHTML = '<li><div class="spinner"></div></li>';
|
||||||
setTimeout(connect, 1000);
|
setTimeout(connect, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onerror = function(e) {
|
ws.onerror = function(e) {
|
||||||
ws.close();
|
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();
|
connect();
|
||||||
</script>
|
</script>
|
||||||
<noscript>Enable javascript for song information.</noscript>
|
<noscript>Enable javascript for song information.</noscript>
|
||||||
|
Loading…
Reference in New Issue
Block a user