Skip to content

Instantly share code, notes, and snippets.

@radusuciu
Last active May 6, 2016 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radusuciu/5edc7429a61d9542480f733f129ccdf0 to your computer and use it in GitHub Desktop.
Save radusuciu/5edc7429a61d9542480f733f129ccdf0 to your computer and use it in GitHub Desktop.
$ = requirejs('jquery');
var $rows = $('tbody tr').slice(2),
group = null;
$rows.each(function() {
var $this = $(this),
id = $this.find('td').eq(0).text().trim();
if (id) {
// let's tally up the previous group and decide what to do with it
if (group !== null) {
// if we've got a singleton then we highlight it
// check for two because we start with header
if (group.length === 2) {
$(group).css('background', 'yellow');
}
}
// if id is defined, we have a new group, we can check median ratio
// to see if we should skip it
var groupRatio = $this.find('td').eq(6).text().trim();
if (parseFloat(groupRatio) == 20) {
group = [ this ];
} else {
group = null;
return;
}
} else {
if (group !== null) {
// if group is already defined then add this one to the stack
group.push(this);
if (group.length > 2) {
// if we've already got a non-singleton, then we can skip ahead
group = null;
return;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment