Skip to content

Instantly share code, notes, and snippets.

@ville6000
Created June 5, 2018 13:43
Show Gist options
  • Save ville6000/a46b239498af88f19d651e06739d9eaa to your computer and use it in GitHub Desktop.
Save ville6000/a46b239498af88f19d651e06739d9eaa to your computer and use it in GitHub Desktop.
MMArmy record breakdown
var record = {};
jQuery('.record').find('tr').each(function(idx, el) {
var row = jQuery(el);
var key = (row.find('td:first-child').hasClass('win') || row.find('td:first-child').hasClass('winTitle')) ? 'wins' : 'losses';
var result = row.find('td').eq(5).text();
var result_key = 'ko';
if (idx > 0) {
if (result.indexOf('Decision') >= 0) {
result_key = 'decision';
} else if (result.indexOf('Submission') >= 0) {
result_key = 'submission';
}
if (typeof record[key] === 'undefined') {
record[key] = {
decision: 0,
submission: 0,
ko: 0
};
}
record[key][result_key]++
}
});
console.log(record);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment