summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bairadio.js33
-rw-r--r--index.html3
2 files changed, 28 insertions, 8 deletions
diff --git a/bairadio.js b/bairadio.js
index 104e2f3..df63006 100644
--- a/bairadio.js
+++ b/bairadio.js
@@ -1,4 +1,5 @@
var selected = "";
+var shows = [];
function update(first) {
var first = first || false;
@@ -43,12 +44,16 @@ function update(first) {
var sel = document.getElementById("server_name");
sel.textContent = "";
-
var selectedPos = 0;
+ var currentShows = [];
for (var i = -1; ++i < resp.length;) {
var o = document.createElement("option");
resp[i].listenurl = resp[i].listenurl.replace("http://bienvenidoainternet.org:8000", "");
o.value = resp[i].listenurl;
+ if (checkNew(resp[i].listenurl) && !first) {
+ addMsg("Ha comenzado una nueva transmisión: " + resp[i].server_name);
+ }
+ currentShows.push(resp[i].listenurl);
o.textContent = resp[i].server_name;
if (resp[i].server_description) {
o.textContent += ": " + resp[i].server_description;
@@ -60,6 +65,7 @@ function update(first) {
sel.appendChild(o);
}
resp = resp[selectedPos];
+ shows = currentShows;
var currentListen = document.getElementById("current_server");
currentListen.value = resp.server_name;
@@ -72,7 +78,7 @@ function update(first) {
if (document.getElementById("chat-filter")) { filterChat(true); }
}
- var current = artist.textContent + title.textContent;
+ var currentSong = artist.textContent + title.textContent;
if (resp.artist) {
resp.artist = resp.artist.trim();
@@ -90,7 +96,7 @@ function update(first) {
}
if (title.textContent != resp.title) {
var history = document.getElementById("history");
- history.innerHTML += '<div class="pastsong">' + current + '</div>';
+ history.innerHTML += '<div class="pastsong">' + currentSong + '</div>';
history.scrollTop = history.scrollHeight;
title.textContent = resp.title;
@@ -117,6 +123,19 @@ function update(first) {
}
}
+function checkNew(mount) {
+ var isNew = true;
+ for (var i = -1; ++i < shows.length;) {
+ if (mount == shows[i]) {
+ isNew = false;
+ break;
+ }
+ }
+ if (isNew) { shows.push(mount); }
+
+ return isNew;
+}
+
function startVisualization() {
var ctx = new AudioContext();
var audio = document.getElementById("stream");
@@ -295,12 +314,12 @@ function checkSend(e) {
var msgField = document.getElementById("msg_type");
var msg = msgField.value.trim();
- var stream = document.getElementById("current_server").value;
+ var show = document.getElementById("current_server").value;
if (!msg) { return; }
if (chatConnected) {
sendMsg("MSG:" + escapeColon(stream) + ":" + escapeColon(msg));
- addMsg(msg, stream, false, true);
+ addMsg(msg, show, false, true);
} else { return; }
msgField.value = "";
@@ -350,11 +369,11 @@ function filterChat(enable) {
if (filter) { filter.parentElement.removeChild(filter); }
if (enable) {
- var current = document.getElementById("current_server").value;
+ var currentShow = document.getElementById("current_server").value;
var style = document.createElement("style");
style.id = "chat-filter";
style.textContent = '[data-stream] { display: none; }';
- style.textContent += '[data-stream^="' + current + '"] { display: block; }';
+ style.textContent += '[data-stream^="' + currentShow + '"] { display: block; }';
document.getElementsByTagName("head")[0].appendChild(style);
}
diff --git a/index.html b/index.html
index c983957..5c2e978 100644
--- a/index.html
+++ b/index.html
@@ -81,6 +81,7 @@
<div id="footer">
bmus v0.4 ★
- <a href="https://bienvenidoainternet.org/" target="_blank">Bienvenido a Internet</a> ★ 2010-2020
+ <a href="https://bienvenidoainternet.org/" target="_blank">Bienvenido a Internet</a>
+ ★ 2010-2020
</div>
</body>