Skip to content

Commit 003beeb

Browse files
author
Dave Newman
committed
Add live stats to streams
1 parent 8a47924 commit 003beeb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
function updateLiveStats() {
3+
$.getJSON(<%== live_stream_stats_path(@user.username).to_json %>, function(data) {
4+
var connections = 0;
5+
if (data) {
6+
connections = data.connections;
7+
}
8+
9+
$('#js-live-viewers').text(connections)
10+
})
11+
}
12+
setInterval(updateLiveStats, 5000)
13+
updateLiveStats()
14+
</script>

app/views/streams/show.html.haml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
-# follow
4949
-# donate
5050

51-
.right.diminish.px1
52-
=icon("eye", class: 'h5')
53-
%span#js-live-viewers
51+
- if @stream.active
52+
.right.diminish.px1
53+
=icon("eye", class: 'h5')
54+
%span#js-live-viewers
5455

5556
%a.right.diminish.px1.pointer{href: "mailto:support@coderwall.com?subject=reporting%20#{@user.username}"}
5657
=icon('flag', class: 'h5')
@@ -91,3 +92,4 @@
9192
#bsap_1305410.bsarocks.bsap_74f50e679004d8f4d62fec4b0f74ccf1
9293

9394
= render 'chat'
95+
= render 'live_stats'

0 commit comments

Comments
 (0)