Skip to content

Instantly share code, notes, and snippets.

@claytantor
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claytantor/8703677 to your computer and use it in GitHub Desktop.
Save claytantor/8703677 to your computer and use it in GitHub Desktop.
Jquery Original Gravity
$('#btn_og').click(function() {
//get form values
temp_val = $('#og_wort_temp').val();
og_val = $('#og_value').val();
actual_og = $('#og_actual').val();
t2 = 1.34722124e-4*temp_val;
t3 = 2.04052596e-6*temp_val*temp_val;
t4 = 2.32820948e-9*temp_val*temp_val*temp_val;
sgcf = 1.00130346 - t2 + t3 -t4
sg = og_val * sgcf
$('#og_actual').html(Math.round(sg * 100) / 100 +' %');
OE = -668.962 + 1262.45*sg - 776.43*sg*sg + 182.94*sg*sg*sg
$('#actual_oe').html(Math.round(OE * 100) / 100 +' %');
max_alc = (sg -1) * 105 * 1.25;
$('#max_alcohol').html(Math.round(max_alc * 100) / 100+' %');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment