Created
May 15, 2013 07:11
-
-
Save hyonschu/5582150 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script src = "jquery-1.9.1.min.js"></script> | |
<script src = "ketogains.js"></script> | |
<body> | |
<h1>/r/ketogains Macro Calculator</h1> | |
<div id = "1" style="float:left; width:300px"> | |
<h2>Start Here</h2> | |
<p><input type ="text" class="weight" value="170.5" size="5"></input> Your weight in lbs</p> | |
<p><input class = "bodyfat" value="13.0" size="5"></input> Your body fat %</p> | |
<p><input class = "cardiom" value="30" size="5"></input> Min of Cardio</p> | |
<p><input class = "liftm" value="30" size="5"></input> Min of Lifting</p> | |
<p><button class="calculate" value="calculate">Calculate!</button></p> | |
<h2>Body Comp Breakdown</h2> | |
<p><strong><text class = "lean calcs">0</text> lbs</strong> lean body mass.</P> | |
<p><strong><span class="ree calcs">0</span></strong> kcal <a href = "http://www.vacumed.com/293.html" target="_blank">Resting Energy Expend</a></p> | |
<p><strong><span class="tef calcs">0</span></strong> kcal <a href = "http://en.wikipedia.org/wiki/Thermic_effect_of_food" target="_blank">Thermal Effect of Food</a></p> | |
<p><strong><span class="cardioc calcs">0</span></strong> cardio kcal burned</p> | |
<p><strong><span class="liftc calcs">0</span></strong> lifting kcal burned</p> | |
</div> | |
<div id = "2" style="float:left; width:350px"> | |
<h2> Rest Day Intake</h2> | |
<p>You should eat: <strong><span class = "restcal calcs">0</span> calories or less </strong></p> | |
<p>Protein Intake: <strong><span class = "proteing calcs">0</span> g of protein/ day </strong></p> | |
<p>Fat Intake: <strong><span class = "fatg calcs">0</span> g of fat/ day </strong></p> | |
<p>Carbs Intake: <strong><span class = "carbg calcs">0</span> g of carbs MAX/ day </strong></p> | |
<p> </p> | |
<h2> Workout Day Intake</h2> | |
<p>You should eat: <strong><span class = "workcal calcs">0</span> calories </strong></p> | |
<p>Protein Intake: <strong><span class = "wproteing calcs">0</span> g of protein/ day </strong></p> | |
<p>Fat Intake: <strong><span class = "wfatg calcs">0</span> g of fat/ day </strong></p> | |
<p>Carbs Intake: <strong><span class = "wcarbg calcs">0</span> g of carbs MAX/ day </strong></p> | |
</div> | |
<div id = "3" style="float:left; width:400px"> | |
<h2> Your Macro Breakdowns</h2> | |
<div width="400"><span class="charts"></span> | |
<p><button class="breakdown">Break it DOWN!</button> <-- CLICK AFTER SETTING MACROS</p> | |
<p>Assumptions:</P> | |
<ul> | |
<li> The calculations assume a male in his 20-30s </li> | |
<li> Women have different caloric needs.</li> | |
<li> However, the calculator can be used as a guide</li> | |
<li> Rest days require 0.8g of protein per lb of lean weight</li> | |
<li> Workout days require 1.2g </li> | |
<li> Carbs should be 5% of caloric intake</li> | |
<li> The remainder of calories come from fats</li> | |
<li> Exercises assume 8 kcal/minute. Everyone is different </li> | |
<li> Eat less on rest days to lose weight. </li> | |
</div> | |
</div> | |
<script> | |
calculated=false; | |
$(document).ready( | |
function(){ | |
$(".calculate").click(function(){ | |
bfp=1-($(".bodyfat").val()/100).toFixed(2); | |
lean=($(".weight").val()*bfp).toFixed(2); | |
ree=lean*11; | |
tef=lean*(1.1).toFixed(2); | |
totalcal=ree+tef; | |
proteing=(lean*0.8).toFixed(2); | |
carbg=(totalcal*0.05/4).toFixed(2); | |
fatg=((totalcal-(carbg*4)-(proteing*4))/9).toFixed(2); | |
proteincal=proteing*4; | |
cardioc=parseInt($(".cardiom").val()*8); | |
liftc=parseInt($(".liftm").val()*8); | |
wproteing=(lean*1.2).toFixed(2); | |
workcal=(totalcal+cardioc+liftc).toFixed(2); | |
wcarbg=(workcal*0.05/4).toFixed(2); | |
wfatg=((workcal-(wproteing*4)-(wcarbg*4))/9).toFixed(2); | |
$(".calcs").empty(); | |
$(".lean").append(lean); | |
$(".ree").append(ree); | |
$(".tef").append(tef); | |
$(".restcal").prepend(totalcal); | |
$(".proteing").prepend(proteing); | |
$(".fatg").prepend(fatg); | |
$(".carbg").prepend(carbg); | |
$(".cardioc").prepend(cardioc); | |
$(".liftc").prepend(liftc); | |
$(".workcal").prepend(workcal); | |
$(".wproteing").prepend(wproteing); | |
$(".wfatg").prepend(wfatg); | |
$(".wcarbg").prepend(wcarbg); | |
calculated=true | |
}); | |
$(".breakdown").click(function(){ | |
if(calculated==false){ | |
alert("You need to calculate your macros first!"); | |
} | |
else{ | |
$(".charts").empty(); | |
var fatcal=fatg*9; | |
var carbcal=carbg*4; | |
var proteinw=(proteincal/totalcal); | |
var fatw=(fatcal/totalcal); | |
var carbw=(carbcal/totalcal); | |
var wproteinw=((wproteing*4)/workcal); | |
var wfatw=((wfatg*9)/workcal); | |
var wcarbw=((wcarbg*4)/workcal); | |
var barc="<h4>Resting Calories Ratio</h4><p><div style='float: left; background-color: yellow; width: "+fatw*350+"px;'><center>"+(fatw*100).toFixed(1)+"</div><div style='float: left; background-color: blue; width: "+proteinw*350+"px;'><center>"+(proteinw*100).toFixed(1)+"</div><div style='float: left; background-color: red; width: "+carbw*350+"px;'><center>"+(carbw*100).toFixed(0)+"</div></p><br><br><h4>Workout Calories Ratios</h4><div style='float: left; background-color: yellow; width: "+wfatw*350+"px;'><center>"+(wfatw*100).toFixed(1)+"</div><div style='float: left; background-color: blue; width: "+wproteinw*350+"px;'><center>"+(wproteinw*100).toFixed(1)+"</div><div style='float: left; background-color: red; width: "+wcarbw*350+"px;'><center>"+(wcarbw*100).toFixed(0)+"</div></p>";$(".charts").append(barc).slideDown()} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment