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 <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Gehad elrobey 2014-07-08 17:59:56 +02:00 committed by Dirk Hohndel
parent b9d04c0cf4
commit 266e3a6cdd

View file

@ -669,13 +669,32 @@ 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 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. *Return the HTML string for a dive cylinder entry in the table.
*/ */
function get_cylinder_HTML(cylinder) function get_cylinder_HTML(cylinder)
{ {
return '<tr><td class="Cyl">' + cylinder.Type + '</td><td class="Cyl">' + cylinder.Size + '</td><td class="Cyl">' + cylinder.WPressure + '</td>' + var cSPressure = cylinder.SPressure;
'<td class="Cyl">' + cylinder.SPressure + '</td><td class="Cyl">' + cylinder.EPressure + '</td><td class="Cyl">' + cylinder.O2 + '</td></tr>'; 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 '<tr><td class="Cyl">' + cylinder.Type + '</td><td class="Cyl">' + cylinder.Size + '</td><td class="Cyl">' + cylinder.WPressure + '</td>' + '<td class="Cyl">' + cSPressure + '</td><td class="Cyl">' + cEPressure + '</td><td class="Cyl">' + cylinder.O2 + '</td></tr>';
} }
/** /**
@ -705,6 +724,7 @@ function get_bookmark_HTML(event)
*/ */
function get_bookmarks_HTML(dive) function get_bookmarks_HTML(dive)
{ {
if (dive.events <= 0) return "";
var result = ""; var result = "";
result += '<h2 class="det_hed">Events</h2><table><tr><td class="words">Name</td><td class="words">Time</td></tr>'; result += '<h2 class="det_hed">Events</h2><table><tr><td class="words">Name</td><td class="words">Time</td></tr>';
for (var i in dive.events) { for (var i in dive.events) {