# HG changeset patch # User Michiel Broek # Date 1583685835 -3600 # Node ID 92afe6b59610dd28e7ed5aac1e99cbc0bcabc9bb # Parent a42166cbb19a3a823463f7db47e4f4fdb451d775 Division by zero protection diff -r a42166cbb19a -r 92afe6b59610 www/js/mon_ispindel.js --- a/www/js/mon_ispindel.js Sun Mar 08 17:11:18 2020 +0100 +++ b/www/js/mon_ispindel.js Sun Mar 08 17:43:55 2020 +0100 @@ -138,23 +138,33 @@ $('#gaugeContainer_temperature').jqxGauge({ caption: { value: record.temperature.toFixed(3) + '°C' }}); $('#gaugeContainer_temperature').jqxGauge({ value: record.temperature }); - var og = plato_to_sg(record.og_gravity); var sg = plato_to_sg(record.gravity); - var svg = 100 * (og - sg) / (og - 1); $('#info_battery').val(record.battery); $('#info_tilt').val(record.angle); $('#info_plato').val(record.gravity); $('#info_sg').val(sg); - $('#vg_og1').html(og.toFixed(4)); - $('#vg_og2').html(record.og_gravity.toFixed(1) + '°P'); - $('#vg_sg1').html(sg.toFixed(4)); - $('#vg_sg2').html(record.gravity.toFixed(1) + '°P'); - $('#vg_svg').html(svg.toFixed(1) + '%') - $('#vg_abv').html(abvol(og, sg).toFixed(2) + '%'); + if (record.og_gravity) { + var og = plato_to_sg(record.og_gravity); + var svg = 100 * (og - sg) / (og - 1); - var gravity = plato_to_sg(record.gravity) * 1000; + $('#vg_og1').html(og.toFixed(4)); + $('#vg_og2').html(record.og_gravity.toFixed(1) + '°P'); + $('#vg_sg1').html(sg.toFixed(4)); + $('#vg_sg2').html(record.gravity.toFixed(1) + '°P'); + $('#vg_svg').html(svg.toFixed(1) + '%') + $('#vg_abv').html(abvol(og, sg).toFixed(2) + '%'); + } else { + $('#vg_og1').html(''); + $('#vg_og2').html(''); + $('#vg_sg1').html(''); + $('#vg_sg2').html(''); + $('#vg_svg').html(''); + $('#vg_abv').html(''); + } + + var gravity = sg * 1000; $('#gaugeContainer_gravity').jqxLinearGauge({ value: gravity }); } });