www/js/global.js

Wed, 26 Sep 2018 15:28:59 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 26 Sep 2018 15:28:59 +0200
changeset 70
4da2414eabbc
parent 67
883e897aad40
child 92
fab98e5c86fc
permissions
-rw-r--r--

Jqwidgets upgraded to version 6.0.6

/*****************************************************************************
 * Copyright (C) 2014
 *
 * Michiel Broek <mbroek at mbse dot eu>
 *
 * This file is part of BrewCloud
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * BrewCloud is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ThermFerm; see the file COPYING.  If not, write to the Free
 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *****************************************************************************/


function getLocalization() {
	var localizationobj = {};
	localizationobj.pagerGoToPageString = "Gehe zu:";
	localizationobj.pagerShowRowsString = "Zeige Zeile:";
	localizationobj.pagerRangeString = " von ";
	localizationobj.pagerNextButtonString = "voriger";
	localizationobj.pagerFirstButtonString = "first";
	localizationobj.pagerLastButtonString = "last";
	localizationobj.pagerPreviousButtonString = "nächster";
	localizationobj.sortAscendingString = "Sortiere aufsteigend";
	localizationobj.sortDescendingString = "Sortiere absteigend";
	localizationobj.sortRemoveString = "Entferne Sortierung";
	localizationobj.firstDay = 1;
	localizationobj.percentSymbol = "%";
	localizationobj.currencySymbol = "€";
	localizationobj.currencySymbolPosition = "after";
	localizationobj.decimalSeparator = ",";
	localizationobj.thousandsSeparator = ".";
	var days = {
		// full day names
		names: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"],
		// abbreviated day names
		namesAbbr: ["Sonn", "Mon", "Dien", "Mitt", "Donn", "Fre", "Sams"],
		// shortest day names
		namesShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]
	};
	localizationobj.days = days;
	var months = {
		// full month names (13 months for lunar calendards -- 13th month should be "" if not lunar)
		names: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""],
		// abbreviated month names
		namesAbbr: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez", ""]
	};
	var patterns = {
		d: "dd.MM.yyyy",
		D: "dddd, d. MMMM yyyy",
		t: "HH:mm",
		T: "HH:mm:ss",
		f: "dddd, d. MMMM yyyy HH:mm",
		F: "dddd, d. MMMM yyyy HH:mm:ss",
		M: "dd MMMM",
		Y: "MMMM yyyy"
	}
	localizationobj.patterns = patterns;
	localizationobj.months = months;
	return localizationobj;
}



$(document).ready(function () {

	$("#jqxMenu").jqxMenu({
		width: 1280,
		height: '30px',
		theme: theme
	});
	$("#jqxWidget").css('visibility', 'visible');
});



/*
 * Berekeningen uit https://www.hobbybrouwen.nl/forum/index.php/topic,6079.msg69464.html#msg69464
 */
function toIBU_Tinseth(Use, Form, SG, Volume, Amount, Boiltime, Alpha) {
	var gravity = parseFloat(SG);
	var liters  = parseFloat(Volume);
	var alpha   = parseFloat(Alpha)/100;
	var mass    = parseFloat(Amount) * 1000;
	var time    = parseFloat(Boiltime);
	var fmoment = 1.0;
	var pfactor = 1.0;

	if ((Use == "Dry Hop") || (Use == "Dry hop")) {
		fmoment = 0.0;
	} else if (Use == "Whirlpool") {
		fmoment = 0.0;
	} else if (Use == "Mash") {
		fmoment = 0.7;		// Brouwhulp
	} else if ((Use == "First Wort") || (Use == "First wort"))  {
		fmoment = 1.1;		// Brouwhulp, Louis, Ozzie
	} else if (Use == "Aroma") {
		fmoment = 0.0;
	}

	if (Form == "Pellet") {
		pfactor = 1.1;
	}

	// TODO:  sg = (postBoilGravity - 1.0) * batchSize / boilSize;

	/*
	 * http://realbeer.com/hops/research.html
	 *
	 *                             decimal AA rating * grams hops * 1000
	 * mg/l of added alpha acids = -------------------------------------
	 *			         volume of finished beer in liters
	 *
	 * Bigness factor = 1.65 * 0.000125^(wort gravity - 1)
	 *
	 *                    1 - e^(-0.04 * time in mins)
	 * Boil Time factor = ----------------------------
	 *                               4.15
	 *
	 * decimal alpha acid utilization = Bigness factor * Boil Time factor
	 *
	 * IBUs = decimal alpha acid utilization * mg/l of added alpha acids
	 */
	var AddedAlphaAcids = (alpha * mass * 1000) / liters;
	var Bigness_factor = 1.65 * Math.pow( 0.000125, gravity - 1);
	var BoilTime_factor = ((1 - Math.exp(-0.04 * time)) / 4.15);		// Glen Tinseth
	var utiisation = Bigness_factor * BoilTime_factor;

	console.log(" AddedAlphaAcids:"+AddedAlphaAcids+"  Bigness_factor:"+Bigness_factor+"  BoilTime_factor:"+BoilTime_factor+"  utilisation:"+utiisation);
	console.log(" fmoment:"+fmoment+"  pfactor:"+pfactor);

	var ibu = (Math.round(utiisation * AddedAlphaAcids * fmoment * pfactor * 10) / 10.0);
	return ibu;
}



function toIBU(Use, Form, SG, Volume, Amount, Boiltime, Alpha, Method) {

	console.log("toIBU_Tinseth("+Use+"," + Form + "," + SG + "," + Volume + "," + Amount + "," + Boiltime + "," + Alpha + "," + Method + ")");
	return toIBU_Tinseth(Use, Form, SG, Volume, Amount, Boiltime, Alpha);
}


/*
 * Steinie:
 *
 *
 * HCO3 = CaCo3 x 1,22
 * 1°F = 10mg/L CaCo3
 */

mercurial