Skip to content

Instantly share code, notes, and snippets.

@shali3
Last active January 21, 2016 09:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shali3/4c38cd2b355ebc9d1749 to your computer and use it in GitHub Desktop.
Save shali3/4c38cd2b355ebc9d1749 to your computer and use it in GitHub Desktop.
Calculates calories from heart rate in RunKeeper
// You can use this code snippet on runkeeper edit activity page to calculate clories according to your heartrate.
// This is very useful when you're tacking indoor (stopwatch) activities that only track heart rate and time.
// To run this you can add a bookmark to you browser with the following line instead of an address:
// javascript:$.get('https://gist.githubusercontent.com/shali3/4c38cd2b355ebc9d1749/raw',eval)
// Please fork this gist and and adjust the parametes here.
// Formula source: http://www.shapesense.com/fitness-exercise/calculators/heart-rate-based-calorie-burn-calculator.aspx
var hr=parseInt($('#avgHeartRate').val()),
kg=70, // Add your weight here (in Kg).
age=27,// Add your age here.
dh=$('#durationHours').val()*1,
dm=$('#durationMinutes').val()*1,
ds=$('#durationSeconds').val()*1,
h=dh+((dm+(ds/60))/60),
maleCal= Math.round(((-55.0969 + (0.6309*hr) + (0.1988*kg) + (0.2017*age))/4.184)*60*h),
femaleCal=Math.round(((-20.4022 + (0.4472*hr) - (0.1263*kg) + (0.074 *age))/4.184)*60*h),
cal=maleCal; // Choose your gender here.
$('#calorieEditLink').click();
$('#calories').val(cal);
$('.editSaveButton.medium').click();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment