Last active
May 6, 2016 23:44
-
-
Save radusuciu/5edc7429a61d9542480f733f129ccdf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ = 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