clean up
This commit is contained in:
parent
a5f489691d
commit
c9642ba76d
115
index.html
115
index.html
@ -1,77 +1,66 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>APR</title>
|
<title>APR</title>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="./assets/stylesheets/normalize.css">
|
<link rel="stylesheet" href="./assets/stylesheets/normalize.css">
|
||||||
<link rel="stylesheet" href="./assets/stylesheets/mini-dark.css">
|
<link rel="stylesheet" href="./assets/stylesheets/mini-dark.css">
|
||||||
<link rel="stylesheet" href="./assets/stylesheets/custom.css">
|
<link rel="stylesheet" href="./assets/stylesheets/custom.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="content">
|
||||||
<div id="content">
|
<h1>Anarchy PlⒶnet Radio</h1>
|
||||||
<h1>Anarchy PlⒶnet Radio</h1>
|
<div class="container">
|
||||||
<div class="container">
|
<div class="row">
|
||||||
<div class="row">
|
<div class="col-sm-12 col-md-8 col-md-offset-2">
|
||||||
|
<audio id="player" controls src="https://radio.anarchyplanet.org:8443/radio.ogg">
|
||||||
<div class="col-sm-12 col-md-8 col-md-offset-2">
|
Your browser does not support the HTML5 Audio element.
|
||||||
<audio id="player" controls src="https://radio.anarchyplanet.org:8443/radio.ogg"></audio>
|
</audio>
|
||||||
|
<ul id="history"></ul>
|
||||||
<ul id="history"></ul>
|
<footer>
|
||||||
|
<p>Ⓐ</p>
|
||||||
<footer>
|
</footer>
|
||||||
<p>Ⓐ</p>
|
</div>
|
||||||
</footer>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<script>
|
||||||
</div>
|
var player = document.getElementById('player');
|
||||||
|
var rng = Math.floor(Math.random() * 10000);
|
||||||
|
player.src = player.src + '?nocache=' + rng;
|
||||||
|
|
||||||
<script>
|
function update(msg) {
|
||||||
var player = document.getElementById('player');
|
document.title = msg.data + " - APR";
|
||||||
var rng = Math.floor(Math.random() * 10000);
|
|
||||||
player.src = player.src + '?nocache=' + rng;
|
|
||||||
|
|
||||||
function update(msg) {
|
var hist = document.getElementById("history");
|
||||||
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) {
|
||||||
|
hist.removeChild(hist.lastChild);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if(hist.childElementCount >= 10) {
|
function connect() {
|
||||||
hist.removeChild(hist.lastChild);
|
var url = 'wss://radio.anarchyplanet.org/ws';
|
||||||
}
|
var ws = new WebSocket(url);
|
||||||
};
|
|
||||||
|
|
||||||
function connect() {
|
ws.onmessage = function(e) {
|
||||||
console.log('connecting');
|
update(e);
|
||||||
|
};
|
||||||
|
|
||||||
var url = 'wss://radio.anarchyplanet.org/ws';
|
ws.onclose = function(e) {
|
||||||
var ws = new WebSocket(url);
|
setTimeout(connect, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
ws.onmessage = function(e) {
|
ws.onerror = function(e) {
|
||||||
update(e);
|
ws.close();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
ws.onclose = function(e) {
|
connect();
|
||||||
setTimeout(connect, 1000);
|
</script>
|
||||||
};
|
<noscript>Enable javascript for song information.</noscript>
|
||||||
|
</body>
|
||||||
ws.onerror = function(e) {
|
|
||||||
ws.close();
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(ws);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<noscript>Please enable javascript to use the audio player.</noscript>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
6
main.go
6
main.go
@ -47,15 +47,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Broadcast([]byte(metadata))
|
|
||||||
|
|
||||||
history.Value = metadata
|
history.Value = metadata
|
||||||
history = history.Next()
|
history = history.Next()
|
||||||
|
|
||||||
|
m.Broadcast([]byte(metadata))
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
|
|
||||||
m.HandleConnect(func(s *melody.Session) {
|
m.HandleConnect(func(s *melody.Session) {
|
||||||
for j := 0; j < 10; j++ {
|
for i := 0; i < history.Len(); i++ {
|
||||||
if history.Value != nil {
|
if history.Value != nil {
|
||||||
s.Write([]byte(history.Value.(string)))
|
s.Write([]byte(history.Value.(string)))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user