summaryrefslogtreecommitdiffstats
path: root/theme
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-07-08 17:59:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-11 06:58:53 -0700
commit266e3a6cdd5b5bc510fa7b4daa3f59be13f0006e (patch)
tree665dbadb3e119a5ac5201e7e48541765a014bd03 /theme
parentb9d04c0cf49fba0906b2f431bf5d17763a24eb8a (diff)
downloadsubsurface-266e3a6cdd5b5bc510fa7b4daa3f59be13f0006e.tar.gz
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>
Diffstat (limited to 'theme')
-rw-r--r--theme/list_lib.js24
1 files changed, 22 insertions, 2 deletions
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 '<tr><td class="Cyl">' + cylinder.Type + '</td><td class="Cyl">' + cylinder.Size + '</td><td class="Cyl">' + cylinder.WPressure + '</td>' +
- '<td class="Cyl">' + cylinder.SPressure + '</td><td class="Cyl">' + cylinder.EPressure + '</td><td class="Cyl">' + cylinder.O2 + '</td></tr>';
+ 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 '<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)
{
+ if (dive.events <= 0) return "";
var result = "";
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) {