Skip to content

Commit 529a3de

Browse files
authored
Merge pull request #25 from debugger22/feat-filter-org/user
Add a feature to filter out events of specified repos/orgs
2 parents 5610d50 + 0a17ec3 commit 529a3de

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
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: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ var drawingArea;
55
var width;
66
var height;
77
var volume = 0.6;
8-
var ULTIMATE_DREAM_KILLER = false;
8+
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,8 +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_edits = 0;
26+
total_sounds = 51;
2727

2828
var celesta = [],
2929
clav = [],
@@ -37,7 +37,16 @@ socket.on('github', function (data) {
3737
$('.online-users-count').html(data.connected_users);
3838
data.data.forEach(function(event){
3939
if(!isEventInQueue(event)){
40-
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+
}
4150
}
4251
});
4352
// Don't let the eventQueue grow more than 1000
@@ -123,12 +132,6 @@ $(function(){
123132
}
124133
});
125134

126-
$('#eventConsumptionSlider').slider({
127-
'min': 1,
128-
'max': 100
129-
});
130-
131-
132135
// Main drawing area
133136
svg = d3.select("#area").append("svg");
134137
svg.attr({width: width, height: height});
@@ -192,6 +195,11 @@ $(function(){
192195
// Make header and footer visible
193196
$('body').css('visibility', 'visible');
194197

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

197205

@@ -238,8 +246,8 @@ function playFromQueueExchange1(){
238246
var event = eventQueue.shift();
239247
if(event != null && event.message != null && !shouldEventBeIgnored(event) && svg != null){
240248
playSound(event.message.length*1.1, event.type);
241-
if(!document.hidden)
242-
drawEvent(event, svg);
249+
// if(!document.hidden)
250+
drawEvent(event, svg);
243251
}
244252
setTimeout(playFromQueueExchange1, Math.floor(Math.random() * 1000) + 500);
245253
$('.events-remaining-value').html(eventQueue.length);
@@ -249,8 +257,8 @@ function playFromQueueExchange2(){
249257
var event = eventQueue.shift();
250258
if(event != null && event.message != null && !shouldEventBeIgnored(event) && svg != null){
251259
playSound(event.message.length, event.type);
252-
if(!document.hidden)
253-
drawEvent(event, svg);
260+
// if(!document.hidden)
261+
drawEvent(event, svg);
254262
}
255263
setTimeout(playFromQueueExchange2, Math.floor(Math.random() * 800) + 500);
256264
$('.events-remaining-value').html(eventQueue.length);

0 commit comments

Comments
 (0)