HTML: Report start cylinder pressure correctly.

Report start cylinder pressure from the samples with empty value.
Must search for the first nonzero value.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Gehad elrobey 2015-03-10 02:05:28 +02:00 committed by Dirk Hohndel
parent d922dbbd99
commit 9e09bc0f52

View file

@ -805,6 +805,14 @@ var points; //reference to the samples array of the shown dive.
var ZERO_C_IN_MKELVIN = 273150; var ZERO_C_IN_MKELVIN = 273150;
var plot1; var plot1;
function firstNonZero()
{
for(var i = 0; i <= items[dive_id].samples.length-1; i++){
if(items[dive_id].samples[i][2] !== 0)
return items[dive_id].samples[i][2];
}
}
function lastNonZero() function lastNonZero()
{ {
for(var i = items[dive_id].samples.length-1; i >= 0; i--){ for(var i = items[dive_id].samples.length-1; i >= 0; i--){
@ -847,7 +855,8 @@ function get_cylinder_HTML(cylinder)
var cEPressure = cylinder.EPressure; var cEPressure = cylinder.EPressure;
if (cSPressure === "--") { if (cSPressure === "--") {
cSPressure = Math.round(put_pressure_unit(items[dive_id].samples[0][2])).toFixed(1) + " " + pressure_unit; var nonZeroCSPressure = firstNonZero();
cSPressure = Math.round(put_pressure_unit(nonZeroCSPressure)).toFixed(1) + " " + pressure_unit;
} }
if (cEPressure === "--") { if (cEPressure === "--") {