diff -r 9d1af81b20ef -r 9ac2fb6b1311 www/js/prod_edit.js --- a/www/js/prod_edit.js Wed Mar 18 19:46:15 2020 +0100 +++ b/www/js/prod_edit.js Wed Mar 18 20:29:23 2020 +0100 @@ -64,6 +64,7 @@ ok_yeasts = 1, // Yeasts are in stock ok_waters = 1, // Waters are in stock + data_loaded = 0; error_count = 0; hop_flavour = 0, @@ -567,6 +568,7 @@ calcStage(); $('#jqxTabs').jqxTabs('select', 2); console.log('main data ready'); + data_loaded = 1; }, loadError: function(jqXHR, status, error) { console.log('main data load error: ' + status + ' ' + error); @@ -2781,6 +2783,7 @@ } function MashpH() { + console.log('MashpH()'); var n = 0, pH = 5.4, deltapH = 0.001, deltapd = 0.1, pd = ProtonDeficit(pH); while (((pd < -deltapd) || (pd > deltapd)) && (n < 2000)) { @@ -2811,7 +2814,12 @@ function calcWater() { - //console.log('calcWater()'); + console.log('calcWater()'); + if (! data_loaded) { + console.log('failsave'); + return; + } + var liters = 0, calcium = 0, magnesium = 0, @@ -2870,9 +2878,10 @@ $('#wg_sulfate').val(Math.round(sulfate * 10) / 10); // Note: brouwhulp has the malts included here in the result. //var wg_ph = ph; + var mash_ph = Round(MashpH(), 1); $('#wg_ph').val(Round(ph, 1)); - $('#wb_ph').val(Round(MashpH(), 1)); - $('#est_mash_ph').val(Round(MashpH(), 1)); + $('#wb_ph').val(mash_ph); + $('#est_mash_ph').val(mash_ph); bicarbonate = total_alkalinity * 1.22; wg_bicarbonate = bicarbonate;