From 266e3a6cdd5b5bc510fa7b4daa3f59be13f0006e Mon Sep 17 00:00:00 2001 From: Gehad elrobey Date: Tue, 8 Jul 2014 17:59:56 +0200 Subject: HTML: add empty values of pressure cylinders When the dive cylinder (start pressure or end pressure) is not set, enter the values of the pressure in the first and the last samples instead. Use the first / last non-zero values. Signed-off-by: Gehad elrobey Signed-off-by: Miika Turkia Signed-off-by: Dirk Hohndel --- theme/list_lib.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'theme') diff --git a/theme/list_lib.js b/theme/list_lib.js index 718ea4cc7..798c40a41 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -669,13 +669,32 @@ var points; //reference to the samples array of the shown dive. var ZERO_C_IN_MKELVIN = 273150; var plot1; +function lastNonZero() +{ + for(var i = items[dive_id].samples.length-1; i >= 0; i--){ + if(items[dive_id].samples[i][2] != 0) + return items[dive_id].samples[i][2]; + } +} + /** *Return the HTML string for a dive cylinder entry in the table. */ function get_cylinder_HTML(cylinder) { - return '' + cylinder.Type + '' + cylinder.Size + '' + cylinder.WPressure + '' + - '' + cylinder.SPressure + '' + cylinder.EPressure + '' + cylinder.O2 + ''; + var cSPressure = cylinder.SPressure; + var cEPressure = cylinder.EPressure; + + if (cSPressure === "--") { + cSPressure = mbar_to_bar(items[dive_id].samples[0][2]) + " bar"; + } + + if (cEPressure === "--") { + var nonZeroCEPressure = lastNonZero(); + cEPressure = mbar_to_bar(nonZeroCEPressure) + " bar"; + } + + return '' + cylinder.Type + '' + cylinder.Size + '' + cylinder.WPressure + '' + '' + cSPressure + '' + cEPressure + '' + cylinder.O2 + ''; } /** @@ -705,6 +724,7 @@ function get_bookmark_HTML(event) */ function get_bookmarks_HTML(dive) { + if (dive.events <= 0) return ""; var result = ""; result += '

Events

'; for (var i in dive.events) { -- cgit v1.2.3-70-g09d2
NameTime