Skip to content

Commit 3151fbe

Browse files
committed
Add a feature to filter out events of specified repos/orgs
1 parent 6c6a64c commit 3151fbe

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

app/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ <h2 class="online-users-text"><span class="odometer online-users-count"></span>
6969
</div>
7070
</div>
7171
<div id="config-area">
72-
<div id="consumption-rate-div">
73-
Set events consumption rate <div id="eventConsumptionSlider"></div>
72+
<div id="org-repo-filter-div">
73+
Enter your organization's or repository's names to filter events&nbsp; <input type="text" id="org-repo-filter-name" placeholder="github google facebook"/>
7474
</div>
7575
<div class="site-description">
7676
<h4>About</h4>

app/public/css/main.css

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,29 @@ circle {
155155
font-weight: 300;
156156
}
157157

158-
#consumption-rate-div{
158+
#org-repo-filter-div{
159159
width: 50%;
160160
margin: 0 auto;
161161
margin-bottom: 0px;
162-
visibility: hidden;
163162
}
164163

165-
#eventConsumptionSlider{
166-
margin-top: 20px;
167-
width: 300px;
164+
#org-repo-filter-name{
165+
width: 20%;
166+
color: gray;
167+
padding: 5px;
168+
padding-left: 10px;
169+
border: none;
170+
background: #F1F1F1;
171+
font-family: 'Josefin Sans', sans-serif;
172+
font-size: 1em;
168173
}
169174

170175
.site-description{
171176
font-size: 1em;
172177
line-height: 1.6em;
173178
width: 50%;
174179
margin: 0 auto;
180+
margin-top: 50px;
175181
}
176182

177183
footer{

app/public/js/main.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var width;
66
var height;
77
var volume = 0.6;
88
var ULTIMATE_DREAM_KILLER = false; // https://github.com/debugger22/github-audio/pull/19
9+
var orgRepoFilterNames;
910

1011
var scale_factor = 6,
1112
note_overlap = 2,
@@ -22,7 +23,7 @@ var svg_background_color_online = '#0288D1',
2223
pull_request_color = 'rgb(46, 204, 113)',
2324
comment_color = 'rgb(46, 204, 113)'
2425
edit_color = '#fff',
25-
total_sounds = 51,
26+
total_sounds = 51;
2627

2728
var celesta = [],
2829
clav = [],
@@ -31,12 +32,21 @@ var svg_background_color_online = '#0288D1',
3132

3233

3334

34-
var socket = io(document.location.hostname + ":8000");
35+
var socket = io(document.location.hostname);
3536
socket.on('github', function (data) {
3637
$('.online-users-count').html(data.connected_users);
3738
data.data.forEach(function(event){
3839
if(!isEventInQueue(event)){
39-
eventQueue.push(event);
40+
// Filter out events only specified by the user
41+
if(orgRepoFilterNames != null && orgRepoFilterNames != []){
42+
// Don't consider pushes to github.io repos when org filter is on
43+
if(new RegExp(orgRepoFilterNames.join("|")).test(event.repo_name)
44+
&& event.repo_name.indexOf('github.io') == -1){
45+
eventQueue.push(event);
46+
}
47+
}else{
48+
eventQueue.push(event);
49+
}
4050
}
4151
});
4252
// Don't let the eventQueue grow more than 1000
@@ -122,12 +132,6 @@ $(function(){
122132
}
123133
});
124134

125-
$('#eventConsumptionSlider').slider({
126-
'min': 1,
127-
'max': 100
128-
});
129-
130-
131135
// Main drawing area
132136
svg = d3.select("#area").append("svg");
133137
svg.attr({width: width, height: height});
@@ -191,6 +195,11 @@ $(function(){
191195
// Make header and footer visible
192196
$('body').css('visibility', 'visible');
193197

198+
$('#org-repo-filter-name').on('input', function() {
199+
orgRepoFilterNames = $('#org-repo-filter-name').val().split(' ');
200+
eventQueue = [];
201+
});
202+
194203
});
195204

196205

0 commit comments

Comments
 (0)