Fix start pressure cylinder values.

-- 
regards,
Gehad
From 8a211da68dabdbccb856f60b68d965777758d81d Mon Sep 17 00:00:00 2001
From: Gehad elrobey <[email protected]>
Date: Tue, 10 Mar 2015 02:05:28 +0200
Subject: [PATCH 2/2] 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 <[email protected]>
---
 theme/list_lib.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/theme/list_lib.js b/theme/list_lib.js
index ceaa9c9..986833a 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 === "--") {
-- 
2.1.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to