Skip to content

Instantly share code, notes, and snippets.

@phaas
Last active August 29, 2015 13:56
Show Gist options
  • Save phaas/8984608 to your computer and use it in GitHub Desktop.
Save phaas/8984608 to your computer and use it in GitHub Desktop.
function ready(fn) {
if( document.readyState === "complete" ) {
fn();
return;
}
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fn);
} else {
document.attachEvent('onreadystatechange', function() {
if (document.readyState === 'interactive')
fn();
});
}
}
ready(updateBugList);
function updateBugList() {
var rows = document.querySelectorAll("table.data tr"),
users = {},
enhancement = false;
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
if(row.querySelector('a[name=ENHANCEMENT]')) {
enhancement = true;
}
if (enhancement) {
row.remove();
continue;
} else if (!row.children[7]) {
continue;
}
var owner = row.children[7].textContent;
if (! owner || "Owner" === owner) {
continue;
}
if(users[owner]) {
users[owner].count++;
} else {
users[owner] = {
count: 1,
name: owner,
slug: owner.replace( /\s/g, '')
};
}
row.classList.add('bug');
row.classList.add(users[owner].slug);
}
var div = document.createElement("div"),
ul = document.createElement('ul'),
userList = [];
for (var owner in users) {
userList.push(users[owner]);
}
userList.sort(function(a,b){
if (a.name > b.name) {
return 1;
} else if (b.name > a.name) {
return -1;
} else {
return 0;
}
});
for (var i = 0; i < userList.length; i++) {
var user = userList[i],
li = document.createElement('li'),
a = document.createElement('a');
ul.appendChild(li);
li.appendChild(a);
a.textContent = user.name + ': ' + user.count;
a.href = '#bugs';
a.setAttribute('data-slug', user.slug);
a.onclick = function() {
showBugs(this.getAttribute('data-slug'));
}
}
div.appendChild(ul);
document.body.insertBefore(div, document.querySelector('table.data'));
var hide = document.querySelectorAll("table.info, table.heading, br, hr");
for (var i = 0; i < hide.length; i++) {
hide[i].style.display = 'none';
}
}
function showBugs(slug) {
var bugs = document.querySelectorAll('.bug'),
selected = document.querySelectorAll('.' + slug);
for (var i = 0; i < bugs.length; i++) {
bugs[i].style.display = 'none';
}
for (var i = 0; i < selected.length; i++) {
selected[i].style.display = '';
if (i % 2 == 0) {
selected[i].classList.remove('odd');
selected[i].classList.add('even');
} else {
selected[i].classList.remove('even');
selected[i].classList.add('odd');
}
}
}
@phaas
Copy link
Author

phaas commented Feb 13, 2014

javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://rawgithub.com/phaas/8984608/raw/d953781c590f7328967849b04c3c3e0583a7b0b9/buglist.js';})();

javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://gist.github.com/phaas/8984608/raw/d953781c590f7328967849b04c3c3e0583a7b0b9/buglist.js';})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment