From: Gehad elrobey <gehadelro...@gmail.com>

Export events to detailed dive view and add events to the profile.
Events names must appear on mouse hover.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 save-html.c       |  2 +-
 theme/list_lib.js | 35 ++++++++++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/save-html.c b/save-html.c
index d459b0e..e1116aa 100644
--- a/save-html.c
+++ b/save-html.c
@@ -17,7 +17,7 @@ void put_HTML_bookmarks(struct membuffer *b, struct dive 
*dive)
        put_string(b, "\"events\":[");
        while (ev) {
                put_format(b, "{\"name\":\"%s\",", ev->name);
-               put_format(b, "\"time\":\"%d:%02d min\",},", 
FRACTION(ev->time.seconds, 60));
+               put_format(b, "\"time\":\"%d\",},", ev->time.seconds);
                ev = ev->next;
        }
        put_string(b, "],");
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 4347475..da63f0c 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -822,7 +822,7 @@ 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 '<tr><td class="Cyl">' + event.name + '</td><td class="Cyl">' + 
int_to_time(event.time) + '</td></tr>';
 }
 
 /**
@@ -878,6 +878,14 @@ function mm_to_meter(mm)
        return mm / (1000);
 }
 
+function format_two_digit(n){
+    return n > 9 ? "" + n: "0" + n;
+}
+
+function int_to_time (n){
+       return  Math.floor((n) /60) +":"+ format_two_digit((n) % (60))+" min";
+}
+
 var plot1;
 
 /**
@@ -889,6 +897,7 @@ function canvas_draw()
        document.getElementById("chart1").innerHTML = "";
        var d1 = new Array();
        var d2 = new Array();
+       var d3 = new Array();
        for (var i = 0; i < items[dive_id].samples.length; i++) {
                d1.push([
                        items[dive_id].samples[i][0] / 60,
@@ -901,9 +910,18 @@ function canvas_draw()
                        ]);
                }
        }
+       for (var i = 0; i < items[dive_id].events.length; i++) {
+               //var x = get_sample(items[dive_id].events[i].time);
+               d3.push([
+                       items[dive_id].events[i].time / 60,
+                       0,
+                       //-1 * mm_to_meter(items[dive_id].samples[x][1])
+                       ]);
+       }
        plot1 = $.jqplot('chart1', [
                                           d1,
-                                          d2
+                                          d2,
+                                          d3
                                   ],
                         {
                                 grid : {
@@ -912,7 +930,13 @@ function canvas_draw()
                                         background : 'rgba(0,0,0,0)'
                                 },
                                 highlighter : {
-                                        show : true
+                                        show : true,
+                                        tooltipContentEditor: function(str, 
seriesIndex, pointIndex, jqPlot) {
+                                               if(seriesIndex===2)
+                                               return 
items[dive_id].events[pointIndex].name;
+                                               else
+                                               return str;
+                                        }
                                 },
                                 seriesDefaults : {
                                         shadowAlpha : 0.1,
@@ -936,6 +960,11 @@ function canvas_draw()
                                                 },
                                                 yaxis : 'y2axis',
                                         },
+                                        {
+                                                 showLine:false,
+                                                 markerOptions: { size: 10, 
style:"o" },
+                                                 pointLabels: { show:false, } ,
+                                        },
                                 ],
                                 axes : {
                                         xaxis : {
-- 
1.9.1

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to