Skip to content

Instantly share code, notes, and snippets.

@danheberden
Last active December 20, 2015 21:09
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 danheberden/6195710 to your computer and use it in GitHub Desktop.
Save danheberden/6195710 to your computer and use it in GitHub Desktop.
get eventbrite totals
var sales = {training: 0, conf: 0, team: 0, speaker: 0};
jQuery('#ticketsSalesDiv tr').each(function(i, tr) {
var row = jQuery(tr);
var columns = row.find('td');
var fields = [];
columns.each(function(i, td) {
var column = jQuery(td);
if(i < 1) {
jQuery.each(sales, function(k, v) {
var reg = new RegExp(k, 'i');
if (reg.test(column.text())) { fields.push(k); }
});
console.log(fields);
}
if(i == 2) {
var count = column.text().split('/')
if(count[0]) {
jQuery.each(fields, function(i, field) {
sales[field] += Number(count[0]);
});
}
}
});
});
alert(jQuery.map(sales, function(v, k){ return k + ": " + v; }).join(',\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment