Skip to content

Instantly share code, notes, and snippets.

@said-and-done
Last active December 15, 2016 10:31
Show Gist options
  • Select an option

  • Save said-and-done/df82f52e5fc250d25434da0638b8f78e to your computer and use it in GitHub Desktop.

Select an option

Save said-and-done/df82f52e5fc250d25434da0638b8f78e to your computer and use it in GitHub Desktop.
var current = $('.mainNavTabs li.active a').attr('href').substr(1);
if(current == 'nutrients'){
var rows = 'Type\tgram';
var cols = ['Fedt', 'Protein', 'Kulhydrat (tilgængelig)', 'Kostfibre'];
$('tr.nutrient-row td').filter(function(){
return cols.indexOf($(this).text()) != -1;
}).each(function(){
var self = $(this);
var name = self.text();
var g = self.next('td').text().replace(' g', '');
rows += '\n'+[name, g].join('\t');
});
alert(rows)
}else if(current == 'meals'){
var rows = 'Ingredient\tgram\tkalorier';
$('tr.food, tr.total').each(function(){
var self = $(this);
var name = self.find('td:eq(0)').find('.hasMeasurePullRight').remove().end().text();
var g = self.find('td:eq(1)').text().replace(' g', '');
var kcal = self.find('td:eq(2)').text().replace(' kcal', '');
rows += '\n'+[name, g, kcal].join('\t');
});
alert(rows)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment