Skip to content

Instantly share code, notes, and snippets.

@hyonschu
Created May 15, 2013 03:04
Show Gist options
  • Save hyonschu/5581382 to your computer and use it in GitHub Desktop.
Save hyonschu/5581382 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src = "jquery-1.9.1.min.js"></script>
<body>
<script>
$(document).ready( function() {
$(".calculate").click( function() {
var bfp = 1-($(".bodyfat").val()/100);
var lean = $(".weight").val()*bfp
var ree = (lean*11);
var tef = parseInt(lean*1.1);
var restcal = parseInt(ree+tef);
var proteincal = (lean).toFixed(1);
var fatcal = ((0.65)*(restcal/9)).toFixed(1);
$(".calcs").empty();
$(".lean").append(lean);
$(".ree").append(ree);
$(".tef").append(tef);
$(".restcal").prepend(restcal);
$(".proteincal").prepend(proteincal);
$(".fatcal").prepend(fatcal);
});
});
</script>
<h1>/r/ketogains Macro Calculator</h1>
<div id = "1" style="float:left; width:300px">
<h2>Body Comp Breakdown</h2>
<p>Your weight in lbs </P>
<p><input type ="text" class="weight" value="170"></input> </p>
<p>Your body fat %</p>
<p><input class = "bodyfat" value="13"></input>%</p>
<p><button class="calculate" value="calculate">calculate!</button></p>
<p>Your lean weight:</P>
<p><strong><text class = "lean calcs">0</text> lbs</strong> lean body mass.</P>
<p><a href = "http://www.vacumed.com/293.html" target="_blank">Resting Energy Expenditure</a> (REE)<p>
<p><strong><span class="ree calcs"></span></strong> kcal per day.
<p><a href = "http://en.wikipedia.org/wiki/Thermic_effect_of_food" target="_blank">Thermic Effect of Food</a> (TEF)</p>
<p><strong><span class="tef calcs"></span></strong> kcal per day.
</div>
<div id = "2" style="float:left; width:300px">
<h2> Recommended Intake</h2>
<p>Maintenance calories</a> <h3><span class = "restcal calcs"></span> calories per day </h3>
<p>Protein Intake</a> <h3><span class = "proteincal calcs"></span>g of protein per day </h3>
<p>Fat Intake</a> <h3><span class = "fatcal calcs"></span>g of fat per day </h3>
<p>Carbs Intake</a> <h3><span class = "carbcal calcs"></span>g of carbs per day </h3>
</div>
<div id = "3" style="float:left; width:400px">
<h2>Macro Breakdowns</h2>
<span class="fats">
<span style%
</span>
<span class="protein">
%
</span>
<span class="carbs">
%
</span>
</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment