Created
June 5, 2018 13:43
-
-
Save ville6000/a46b239498af88f19d651e06739d9eaa to your computer and use it in GitHub Desktop.
MMArmy record breakdown
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
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