summaryrefslogtreecommitdiffstats
path: root/theme/list_lib.js
diff options
context:
space:
mode:
Diffstat (limited to 'theme/list_lib.js')
-rw-r--r--theme/list_lib.js161
1 files changed, 136 insertions, 25 deletions
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 20dc5a79e..0d84516d2 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -626,7 +626,7 @@ function unexpand_trip(trip)
{
trips[trip].expanded = false;
var d = document.getElementById("trip_dive_list_" + trip);
- d.innerHTML ='';
+ d.innerHTML = '';
}
function getItems()
@@ -666,15 +666,7 @@ function rgb(r, g, b)
r = Math.floor(r * 255);
g = Math.floor(g * 255);
b = Math.floor(b * 255);
- return[
- "rgb(",
- r,
- ",",
- g,
- ",",
- b,
- ")"
- ].join("");
+ return["rgb(", r, ",", g, ",", b, ")"].join("");
}
/**
@@ -817,7 +809,7 @@ function get_cylinder_HTML(cylinder)
function get_cylinders_HTML(dive)
{
var result = "";
- result += '<h2>Dive equipments</h2><table><tr><td class="Cyl">Type</td><td class="Cyl">Size</td><td class="Cyl">Work Pressure</td><td class="Cyl">Start Pressure</td><td class="Cyl">End Pressure</td><td class="Cyl">O2</td></tr>';
+ result += '<h2 class="det_hed">Dive equipments</h2><table><tr><td class="words">Type</td><td class="words">Size</td><td class="words">Work Pressure</td><td class="words">Start Pressure</td><td class="words">End Pressure</td><td class="words">O2</td></tr>';
for (var i in dive.Cylinders) {
result += get_cylinder_HTML(dive.Cylinders[i]);
}
@@ -826,11 +818,34 @@ function get_cylinders_HTML(dive)
}
/**
+Return the HTML string for a bookmark entry in the table.
+*/
+function get_bookmark_HTML(event)
+{
+ return '<tr><td class="Cyl">' + event.name + '</td><td class="Cyl">' + event.time + '</td></tr>';
+}
+
+/**
+*Return HTML table of bookmarks of a dive.
+*/
+function get_bookmarks_HTML(dive)
+{
+ 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) {
+ result += get_bookmark_HTML(dive.events[i]);
+ }
+ result += '</table>';
+ return result;
+}
+
+
+/**
*Return HTML main data of a dive
*/
function get_dive_HTML(dive)
{
- return '<h2>Dive Information</h2><table><tr><td class="words">Date: </td><td>' + dive.date +
+ return '<h2 class="det_hed">Dive Information</h2><table><tr><td class="words">Date: </td><td>' + dive.date +
'</td><td class="words">&nbsp&nbsp&nbsp&nbsp&nbspTime: </td><td>' + dive.time +
'</td><td class="words">&nbsp&nbsp&nbsp&nbsp&nbspLocation: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\')\">' +
dive.location + '</a>' +
@@ -846,25 +861,109 @@ function get_dive_HTML(dive)
'</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>';
};
+var ZERO_C_IN_MKELVIN = 273150;
+
+function mkelvin_to_C(mkelvin)
+{
+ return (mkelvin - ZERO_C_IN_MKELVIN) / 1000.0;
+}
+
+function mbar_to_bar(mbar)
+{
+ return mbar / 1000;
+}
+
+function mm_to_meter(mm)
+{
+ return mm / (1000);
+}
+
+var plot1;
+
/**
*Main canvas draw function
*this calls the axis and grid initialization functions.
*/
function canvas_draw()
{
- var c = document.getElementById("profileCanvas");
- c.width = window.innerWidth;
- c.height = window.innerHeight;
- canvas_showGrid();
- canvas_showAxisInfo();
- var ctx = c.getContext("2d");
- ctx.lineWidth = 4 //variable width
- //draw starting line, draw all samples then draw the final line.
- canvas_drawline(ctx, [0,0], points[0]);
- for (var i = 1; i < points.length; i++) {
- canvas_drawline(ctx, points[i - 1], points[i]);
+ document.getElementById("chart1").innerHTML = "";
+ var d1 = new Array();
+ var d2 = new Array();
+ for (var i = 0; i < items[dive_id].samples.length; i++) {
+ d1.push([
+ items[dive_id].samples[i][0] / 60,
+ -1 * mm_to_meter(items[dive_id].samples[i][1])
+ ]);
+ if (items[dive_id].samples[i][2] != 0) {
+ d2.push([
+ items[dive_id].samples[i][0] / 60,
+ mbar_to_bar(items[dive_id].samples[i][2])
+ ]);
+ }
}
- canvas_drawline(ctx, points[points.length - 1], [MAX_WIDTH,0]);
+ plot1 = $.jqplot('chart1', [
+ d1,
+ d2
+ ],
+ {
+ grid : {
+ drawBorder : true,
+ shadow : false,
+ background : 'rgba(0,0,0,0)'
+ },
+ highlighter : {
+ show : true
+ },
+ seriesDefaults : {
+ shadowAlpha : 0.1,
+ shadowDepth : 2,
+ fillToZero : true
+ },
+ series :[
+ {
+ color : 'rgba(35,58,58,.6)',
+ negativeColor : 'rgba(35,58,58,.6)',
+ showMarker : true,
+ showLine : true,
+ fill : true,
+ yaxis : 'yaxis',
+ },
+ {
+ color : 'rgba(44, 190, 160, 0.7)',
+ showMarker : false,
+ rendererOptions : {
+ smooth : true,
+ },
+ yaxis : 'y2axis',
+ },
+ ],
+ axes : {
+ xaxis : {
+ pad : 1.0,
+ tickRenderer : $.jqplot.CanvasAxisTickRenderer,
+ tickOptions : {
+ showGridline : false,
+ formatString : '%i min',
+ angle : -30
+ }
+ },
+ yaxis : {
+ max : 0,
+ tickRenderer : $.jqplot.CanvasAxisTickRenderer,
+ tickOptions : {
+ formatString : '%.2f'
+ },
+ pad : 2.05
+ },
+ y2axis : {
+ tickRenderer : $.jqplot.CanvasAxisTickRenderer,
+ tickOptions : {
+ formatString : '%ibar'
+ },
+ pad : 3.05
+ },
+ }
+ });
}
/**
@@ -883,13 +982,22 @@ function showDiveDetails(dive)
MAX_WIDTH = items[dive_id].duration;
//draw the canvas and initialize the view
- canvas_draw();
document.getElementById("diveinfo").innerHTML = get_dive_HTML(items[dive_id]);
document.getElementById("dive_equipments").innerHTML = get_cylinders_HTML(items[dive_id]);
+ document.getElementById("bookmarks").innerHTML = get_bookmarks_HTML(items[dive_id]);
+ setDiveTitle(items[dive_id]);
//hide the list of dives and show the canvas.
document.getElementById("diveListPanel").style.display = 'none';
document.getElementById("divePanel").style.display = 'block';
+ canvas_draw();
+}
+
+function setDiveTitle(dive)
+{
+ document.getElementById("dive_no").innerHTML = "Dive No. " + (settings.subsurfaceNumbers === '0' ?
+ dive.number : dive.subsurface_number);
+ document.getElementById("dive_location").innerHTML = dive.location;
}
/**
@@ -898,6 +1006,9 @@ function showDiveDetails(dive)
*/
function unshowDiveDetails(dive)
{
+ start = dive_id;
+ viewInPage();
+ plot1 = null;
document.getElementById("diveListPanel").style.display = 'block';
document.getElementById("divePanel").style.display = 'none';
}