diff options
author | jay | 2020-03-13 01:46:03 -0300 |
---|---|---|
committer | jay | 2020-03-13 01:46:03 -0300 |
commit | 10f0f6e995d5081332f3976ca7091c9c92752113 (patch) | |
tree | 0fcba2292bdff7e7a44dffd364e363eac7e8690c /bairadio.js | |
parent | f1a92c9845f2bd729942ba53426a4b42e67bf9a1 (diff) | |
download | bairadio-frontend-10f0f6e995d5081332f3976ca7091c9c92752113.tar.gz bairadio-frontend-10f0f6e995d5081332f3976ca7091c9c92752113.tar.xz bairadio-frontend-10f0f6e995d5081332f3976ca7091c9c92752113.zip |
Nuevas emisiones son informadas en chat
Diffstat (limited to 'bairadio.js')
-rw-r--r-- | bairadio.js | 33 |
1 files changed, 26 insertions, 7 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); } |