Created
May 15, 2013 04:09
-
-
Save hyonschu/5581598 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> | |
<body> | |
<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><h2>Your lean weight:</h2></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">0</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">0</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">0</span> calories per day </h3></p> | |
<p>Protein Intake</a> <h3><span class = "proteing calcs">0</span>g of protein per day </h3></p> | |
<p>Fat Intake</a> <h3><span class = "fatg calcs">0</span>g of fat per day </h3></p> | |
<p>Carbs Intake</a> <h3><span class = "carbg calcs">0</span>g of carbs MAX per day </h3></p> | |
</div> | |
<div id = "3" style="float:left; width:400px"> | |
<h2>Macro Breakdowns</h2> | |
<div width="300"> | |
<span class="charts"></span> | |
<p><button class="breakdown">Break it DOWN!</button></p> | |
</div> | |
</div> | |
<script> | |
$(document).ready( function() { | |
$(".breakdown").click( function() { | |
$(".charts").empty(); | |
var bfp = 1-($(".bodyfat").val()/100); | |
var lean = $(".weight").val()*bfp | |
var ree = parseInt(lean*11); | |
var tef = parseInt(lean*1.1); | |
var totalcal = parseInt(ree+tef); | |
var proteing = (lean*0.8).toFixed(1); | |
var fatg = ((totalcal*(2/3))/9).toFixed(1) | |
var carbg = ((totalcal-(fatg*9)-(proteing*4))/4).toFixed(1); | |
var proteincal = proteing*4; | |
var fatcal = fatg*9; | |
var carbcal = carbg*4; | |
var proteinw = (proteincal/totalcal).toFixed(1); | |
var fatw = (fatcal/totalcal).toFixed(1); | |
var carbw = (carbcal/totalcal).toFixed(1); | |
$(".charts").prepend( | |
"<p><div style='float: left; background-color: yellow; width: "+fatw*300+"px;'><center>"+fatw*100+"%</div><div style='float: left; background-color: blue; width: "+proteinw*300+"px;'><center>"+proteinw*100+"%</div><div style='float: left; background-color: red; width: "+carbw*300+"px;'><center>"+carbw*100+"%</div></p></br>" | |
); | |
}) | |
$(".calculate").click( function() { | |
var bfp = 1-($(".bodyfat").val()/100); | |
var lean = $(".weight").val()*bfp | |
var ree = parseInt(lean*11); | |
var tef = parseInt(lean*1.1); | |
var totalcal = parseInt(ree+tef); | |
var proteing = (lean*0.8).toFixed(1); | |
var fatg = ((totalcal*(2/3))/9).toFixed(1) | |
var carbg = ((totalcal-(fatg*9)-(proteing*4))/4).toFixed(1); | |
var proteincal = proteing*4; | |
var fatcal = fatg*9; | |
var carbcal = carbg*4; | |
$(".calcs").empty(); | |
$(".lean").append(lean); | |
$(".ree").append(ree); | |
$(".tef").append(tef); | |
$(".restcal").prepend(ree+tef); | |
$(".proteing").prepend(proteing); | |
$(".fatg").prepend(fatg); | |
$(".carbg").prepend(carbg); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment