From 9e09bc0f523df6d7fa30ad1a15e619e5622bffb1 Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 10 Mar 2015 02:05:28 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- theme/list_lib.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'theme') diff --git a/theme/list_lib.js b/theme/list_lib.js index ceaa9c9bc..986833a13 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -805,6 +805,14 @@ var points; //reference to the samples array of the shown dive. var ZERO_C_IN_MKELVIN = 273150; 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() { 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; 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 === "--") { -- cgit v1.2.3-70-g09d2