I have attached some patches that improves the statistics table view and
fix the cells layout.



On Mon, Aug 4, 2014 at 6:40 PM, Miika Turkia <miika.tur...@gmail.com> wrote:

> Looking good, but some more improvements needed after a brief test:
>
> - When I export dives from one trip only, the trip mode sorting shows all
> the exported dives under other.
>

I don't understand this, could you clarify that please?



> - The yearly statistics layout needs some work, at least on my FF 30.0
>   - The table is too wide for my 1600 pix wide screen as a lot of space is
> wasted on the cells unnecessarily
>   - Total time is wrapped too much as shown on attached screenshot
>
> I'll re-send the current patch set with my SOB later today.
>
> miika
>
>
> On Mon, Aug 4, 2014 at 5:03 PM, Gehad Elrobey <gehadelro...@gmail.com>
> wrote:
>
>> Hi Miika,
>>
>> Sorry for the delay, I had some family vacations this week.
>> I Implemented the yearly statistics into the HTML exports (Patches are
>> attached), also there are some patches not applied to current master yet..
>> I am waiting your feedback.
>>
>> Regards,
>> Gehad
>>
>>
>> On Mon, Jul 28, 2014 at 5:14 PM, Miika Turkia <miika.tur...@gmail.com>
>> wrote:
>>
>>> Thanks, you had one 'return' missing, which I added and did some
>>> rewording on the commit messages.
>>>
>>> The lines on the horizontal axis are a bit weird currently. Shown on the
>>> attached screenshot. The depth and pressure units get misaligned due to the
>>> static temperature fix (I guess).
>>>
>>> miika
>>>
>>>
>>>
>>> On Sun, Jul 27, 2014 at 11:01 PM, Gehad Elrobey <gehadelro...@gmail.com>
>>> wrote:
>>>
>>>> I Attached four patches that fix the mentioned bugs. I ll still work on
>>>> more improvements for the current javascript code.
>>>>
>>>> Regards,
>>>> Gehad
>>>>
>>>>
>>>> On Fri, Jul 25, 2014 at 8:02 AM, Miika Turkia <miika.tur...@gmail.com>
>>>> wrote:
>>>>
>>>>> On Thu, Jul 24, 2014 at 10:29 PM, Gehad Elrobey <
>>>>> gehadelro...@gmail.com> wrote:
>>>>>
>>>>>>
>>>>>> I attached a patch with two more fixes.
>>>>>> Now most of the bugs list seems to be resolved.
>>>>>>
>>>>>
>>>>> It seems that the temperature graph is not drawn, if the temperature
>>>>> is constant the whole dive.
>>>>>
>>>>> The layout seems to change for me when I open a dive on the divelist.
>>>>> This is due to scrollbar appears on the browser window. If you could come
>>>>> up with something that keeps the layout the same in this case. This
>>>>> requires on my screen that I export just a few dives, having 10 dives on
>>>>> the page causes the scroll bar to be there to begin with.
>>>>>
>>>>> Could give a - as value for such events that don't have any sensible
>>>>> values. I suppose that heading is the only event where value 0 makes 
>>>>> sense.
>>>>>
>>>>> Dive equipments seems to only include the cylinder information. It
>>>>> could have also weight and suite... or the title should be changed to
>>>>> cylinder.
>>>>>
>>>>>
>>>>>
>>>>>> what do you recommend to be added for now? and what things are
>>>>>> missing or need to be fixed as a priority?
>>>>>>
>>>>>
>>>>> A statistics page could be next one to implement. Yearly and trip
>>>>> based stats of the key values. You could also implement something that is
>>>>> currently missing from Subsurface GUI - statistics of how many specific
>>>>> tags are there, how many dives with certain buddies etc. One could come up
>>>>> with quite a few ideas about how to graph different statistics out of the
>>>>> date that is kept... But take small steps implementing this stuff. Better
>>>>> to have basic stuff properly implemented first than a whole lot of
>>>>> incomplete mess...
>>>>>
>>>>>
>>>>>> On Mon, Jul 21, 2014 at 7:32 AM, Miika Turkia <miika.tur...@gmail.com
>>>>>> > wrote:
>>>>>>
>>>>>>> On Mon, Jul 21, 2014 at 8:16 AM, Gehad Elrobey <
>>>>>>> gehadelro...@gmail.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hi miika,
>>>>>>>>
>>>>>>>> On Sun, Jul 20, 2014 at 8:02 AM, Miika Turkia <
>>>>>>>> miika.tur...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> New bugs I spotted:
>>>>>>>>>
>>>>>>>>> - The tooltip on temperature graphs shows actually the time
>>>>>>>>> (concatenated with temperature unit).
>>>>>>>>>
>>>>>>>>
>>>>>>>> what is it supposed to show? I think this is consistent will all
>>>>>>>> the other curves in the profile.
>>>>>>>>
>>>>>>>
>>>>>>>  It should show the temperature value. The temperature graph is
>>>>>>> drawn based on the temperature correctly, but the tooltip shows time 
>>>>>>> since
>>>>>>> start of the time, not the temperature.
>>>>>>>
>>>>>>
>>>>>> I Can't reproduce this at all, this is working correctly with me in
>>>>>> all the dives I have (Please see the attachments).
>>>>>>
>>>>>
>>>>> Seems that I mis-read the value - thought the time is part of the
>>>>> temperature. Maybe you could use colon instead of comma to separate the
>>>>> time from the actual value. It would be a bit clearer that it is not 8,6 C
>>>>> :D
>>>>>
>>>>> miika
>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I Also fixed the previous patches, and attached some new patches
>>>>>>>> with them.
>>>>>>>> There are still three bugs that I am working on them now.
>>>>>>>>
>>>>>>>
>>>>>>> Thanks, I'll have a look later.
>>>>>>>
>>>>>>>
>>>>>>>>  - I am not sure about the search of location - e.g. if I write
>>>>>>>>> "Mexico somethingthatdoesnotexist", I get all the locations in Mexico.
>>>>>>>>> - Zooming in (ctrl++) and out (ctrl+-) and restoring zoom level
>>>>>>>>> (ctrl+0) on firefox does not rescale the graph properly
>>>>>>>>> - The heading and gaschange switches should use the value field
>>>>>>>>> from the event, not the type field (type is still internal to 
>>>>>>>>> subsurface,
>>>>>>>>> and does not provide any useful information to the users, on the 
>>>>>>>>> other hand
>>>>>>>>> value would e.g. tell what gas we changed to)
>>>>>>>>>
>>>>>>>>
>>>>>>>> Regarding the event value, is exporting the event value as a number
>>>>>>>> is useful? or there is some enum strings that must be shown instead?
>>>>>>>>
>>>>>>>
>>>>>>> The heading is degrees, as in compass.
>>>>>>>
>>>>>>> The gas change event's value contains the o2 per centage, of the gas
>>>>>>> mix, or it can also contain the o2 and he content. Low order bits being 
>>>>>>> o2
>>>>>>> and high order bits the he:
>>>>>>> he = cur_event.value >> 16
>>>>>>> o2 = cur_event.value & 0xffff
>>>>>>>
>>>>>>> miika
>>>>>>>
>>>>>>>
>>>>>>>>  - If I go to next dive on detailed view, and hit one extra right
>>>>>>>>> arrows after reaching the last dive, first click on left does not 
>>>>>>>>> change
>>>>>>>>> the selection, only re-clicking on left does
>>>>>>>>>
>>>>>>>>> I'll still do a bit of poking around once I have more time...
>>>>>>>>>
>>>>>>>>> miika
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, Jul 19, 2014 at 6:30 AM, Gehad Elrobey <
>>>>>>>>> gehadelro...@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> I Attached some bug fixes, Still working on the remaining bugs.
>>>>>>>>>>
>>>>>>>>>> Regards,
>>>>>>>>>> Gehad.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Tue, Jul 15, 2014 at 11:22 PM, Tomaz Canabrava <
>>>>>>>>>> tcanabr...@kde.org> wrote:
>>>>>>>>>>
>>>>>>>>>>> On Tue, Jul 15, 2014 at 4:31 PM, Anton Lundin <gla...@acc.umu.se>
>>>>>>>>>>> wrote:
>>>>>>>>>>> > On 15 July, 2014 - Anton Lundin wrote:
>>>>>>>>>>> >
>>>>>>>>>>> >> On 15 July, 2014 - Miika Turkia wrote:
>>>>>>>>>>> >>
>>>>>>>>>>> >> > A few more bugs:
>>>>>>>>>>> >> > - Trimix dives are missing He content (use e.g. test20.xml
>>>>>>>>>>> for testing
>>>>>>>>>>> >> > purposes) - Reported by Roberto, but mailing list was not
>>>>>>>>>>> included
>>>>>>>>>>> >>
>>>>>>>>>>> >> Gaah. This is code that uses the event data straight off. In
>>>>>>>>>>> the case of
>>>>>>>>>>> >> SAMPLE_EVENT_GASCHANGE especially we need to map the event to
>>>>>>>>>>> the
>>>>>>>>>>> >> available cylinders and that way figure out which gas we are
>>>>>>>>>>> using.
>>>>>>>>>>> >>
>>>>>>>>>>> >> Almost every place where we use get_gasmix_from_event we
>>>>>>>>>>> should be using
>>>>>>>>>>> >> get_cylinder_index instead and grab the "real" gasmix from
>>>>>>>>>>> the cylinder,
>>>>>>>>>>> >> except the case where get_gasmix_from_event is called from
>>>>>>>>>>> >> get_cylinder_index =)
>>>>>>>>>>> >>
>>>>>>>>>>> >>
>>>>>>>>>>> >> This was more work than anticipated when i first gave it a
>>>>>>>>>>> stab. If no
>>>>>>>>>>> >> one else untangles this I'll give it another stab later.
>>>>>>>>>>> >>
>>>>>>>>>>> >>
>>>>>>>>>>> >
>>>>>>>>>>> > Gaah 2.
>>>>>>>>>>> >
>>>>>>>>>>> > I of course miss-read the report and i was talking about what
>>>>>>>>>>> we write
>>>>>>>>>>> > in the regular-non-html-ui.
>>>>>>>>>>> >
>>>>>>>>>>> > I found another bug.
>>>>>>>>>>>
>>>>>>>>>>> :P
>>>>>>>>>>>
>>>>>>>>>>> > //Anton
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> subsurface mailing list
>>>>>>>>>>> subsurface@hohndel.org
>>>>>>>>>>> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
From ba44c3d1e01a6868a1017d4fdb4941d0e18da50c Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Fri, 8 Aug 2014 17:18:09 +0300
Subject: [PATCH 5/5] HTML: Enhance Yearly statistics table.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 theme/light.css   |  9 +++++++--
 theme/list_lib.js | 10 +++++++++-
 theme/sand.css    | 15 ++++++++++++---
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/theme/light.css b/theme/light.css
index a1acbfa..baa04b6 100644
--- a/theme/light.css
+++ b/theme/light.css
@@ -129,7 +129,6 @@ input[type=checkbox]{
 	font-weight:bold;
 }
 
-
 #controller{
 	min-width:200px;
 	padding:10px;
@@ -159,8 +158,14 @@ input[type=checkbox]{
 }
 
 .statscell{
-	min-width:100px;
+	min-width:120px;
+	height: 25px;
 	margin:0px;
+	text-align:center;
+}
+
+.stats_row{
+	background-color:rgba(125,125,125,0.3);
 }
 
 #stats_header{
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 2c915ad..089f8bf 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -690,11 +690,19 @@ function getDiveStats(){
 function getStatsRows(){
 	var res = "";
 	for(var i = 0; i < divestat.length ; i++) {
-	res += '<tr><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>';
+	res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>';
 	}
 	return res;
 }
 
+function stats_row_highlight(row){
+	row.style.backgroundColor = "rgba(125,125,125,0.7)";
+}
+
+function stats_row_unhighlight(row){
+	row.style.backgroundColor = "rgba(125,125,125,0.3)";
+}
+
 //trips
 
 var tripsShown;
diff --git a/theme/sand.css b/theme/sand.css
index befa861..b2f35bb 100644
--- a/theme/sand.css
+++ b/theme/sand.css
@@ -147,7 +147,7 @@ input[type=checkbox]{
 	width:90%;
 	margin:0% 5% 0% 5%;
 	margin-bottom:50px;
-	background-color: rgba(88,121,139,0.3);
+	background-color: rgba(253, 195, 141,0.3);
 	box-shadow: 10px 10px 5px #888888;
 }
 
@@ -156,9 +156,18 @@ input[type=checkbox]{
 	overflow-y:hidden;
 }
 .statscell{
-	border-style:solid;
-	padding-right:100px;
+	min-width:120px;
+	height: 25px;
 	margin:0px;
+	text-align:center;
+}
+
+.stats_row{
+	background-color:rgba(125,125,125,0.3);
+}
+
+#stats_header{
+	background-color:#EFC15F;
 }
 
 button,#no_dives_selector{
-- 
1.9.1

From 32d44233b7ac90309807e677937a535e498d93e8 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 17:11:42 +0300
Subject: [PATCH 4/5] HTML: export dive duration value to the detailed view.

Dive duration value is missing in the dive exports

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 save-html.c       | 2 ++
 theme/list_lib.js | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/save-html.c b/save-html.c
index 652ffb4..6190c36 100644
--- a/save-html.c
+++ b/save-html.c
@@ -209,6 +209,8 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d
 	write_attribute(b, "location", dive->location);
 	put_format(b, "\"rating\":%d,", dive->rating);
 	put_format(b, "\"visibility\":%d,", dive->visibility);
+	put_format(b, "\"dive_duration\":\"%u:%02u min\",",
+		   FRACTION(dive->duration.seconds, 60));
 	put_string(b, "\"temperature\":{");
 	put_HTML_airtemp(b, dive, "\"air\":\"", "\",");
 	put_HTML_watertemp(b, dive, "\"water\":\"", "\",");
diff --git a/theme/list_lib.js b/theme/list_lib.js
index ade54c8..2c915ad 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -212,7 +212,8 @@ function getExpanded(dive)
 		  '</td></tr></table>' +
 		  '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-		  '</td></tr></table><table><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
+		  '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
+		  '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
 		  '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
 		  '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
 		  '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
@@ -890,7 +891,8 @@ function get_dive_HTML(dive)
 	       '</td></tr></table>' +
 	       '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
 	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-	       '</td></tr></table><table><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
+	       '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
+	       '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
 	       '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
 	       '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
 	       '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
-- 
1.9.1

From 1b0b13107848238333c39e5989171c8544bff45a Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 16:11:23 +0300
Subject: [PATCH 3/5] HTML: Add total row to yearly statistics table.

Add new row to the yearly statistics table containing the total. Total
values are calculated to some columns only, it doesn't make any sense to
add the total value to other columns (Temperature cols for example).

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 30 ++++++++++++++++++++++++++++++
 qt-ui/divelogexportdialog.h   |  6 ++++++
 2 files changed, 36 insertions(+)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 0b6ab73..9156f17 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -139,6 +139,12 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 	QFile file(filename);
 	file.open(QIODevice::WriteOnly | QIODevice::Text);
 	QTextStream out(&file);
+
+	stats_t total_stats;
+
+	total_stats.selection_size = 0;
+	total_stats.total_time.seconds = 0;
+
 	int i = 0;
 	out << "divestat=[";
 	if (ui->exportStatistics->isChecked()) {
@@ -160,13 +166,37 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 			out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
 			out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
 			out << "},";
+			total_stats.selection_size += stats_yearly[i].selection_size;
+			total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
 			i++;
 		}
 	}
+	exportHTMLstatisticsTotal(out, &total_stats);
 	out << "]";
 	file.close();
 }
 
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
+{
+	out << "{";
+	out << "\"YEAR\":\"Total\",";
+	out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
+	out << "\"TOTAL_TIME\":\"" << get_time_string(total_stats->total_time.seconds, 0) << "\",";
+	out << "\"AVERAGE_TIME\":\"--\",";
+	out << "\"SHORTEST_TIME\":\"--\",";
+	out << "\"LONGEST_TIME\":\"--\",";
+	out << "\"AVG_DEPTH\":\"--\",";
+	out << "\"MIN_DEPTH\":\"--\",";
+	out << "\"MAX_DEPTH\":\"--\",";
+	out << "\"AVG_SAC\":\"--\",";
+	out << "\"MIN_SAC\":\"--\",";
+	out << "\"MAX_SAC\":\"--\",";
+	out << "\"AVG_TEMP\":\"--\",";
+	out << "\"MIN_TEMP\":\"--\",";
+	out << "\"MAX_TEMP\":\"--\",";
+	out << "},";
+}
+
 void DiveLogExportDialog::on_exportGroup_buttonClicked(QAbstractButton *button)
 {
 	showExplanation();
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index e398a5a..8472f80 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -2,12 +2,18 @@
 #define DIVELOGEXPORTDIALOG_H
 
 #include <QDialog>
+#include <QTextStream>
+#include "helpers.h"
+#include "statistics.h"
+
 class QAbstractButton;
 
 namespace Ui {
 	class DiveLogExportDialog;
 }
 
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats);
+
 class DiveLogExportDialog : public QDialog {
 	Q_OBJECT
 
-- 
1.9.1

From 8459dd93ebb11af923795c125a86b40c06d2595f Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 11:10:59 +0300
Subject: [PATCH 2/5] HTML: Search results must be sorted by default.

-Fix search results to be sorted by default.
-Fix two typos.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 theme/list_lib.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 684d92e..ade54c8 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -218,7 +218,7 @@ function getExpanded(dive)
 		  '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
 		  '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>';
 	if (settings.listOnly === '0') {
-		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">show more details</a></center>';
+		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">Show more details</a></center>';
 	}
 	return res;
 };
@@ -271,7 +271,7 @@ var locat = true;
 This variable keep the state of the col.
 which is sorted upon it.
 */
-var sort_based_on = 1; // sorting is based on number by default.
+var sort_based_on = '1'; // sorting is based on number by default.
 
 function change_sort_col(sortOn)
 {
@@ -679,7 +679,7 @@ function showStats()
 function getDiveStats(){
 	var res = "";
 	res += '<table><tr id="stats_header">';
-	res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Avarage Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Avarage Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>';
+	res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Average Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Average Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>';
 	res += '</tr>';
 	res += getStatsRows();
 	res += '</table>';
-- 
1.9.1

From ba3577b060e119ffe9eeaea8eddacd2772747881 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Mon, 4 Aug 2014 14:02:16 +0300
Subject: [PATCH 1/5] HTML: Make export statistics optional.

make exporting statistics to the HTML page optional.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 41 ++++++++++++++++++++++-------------------
 qt-ui/divelogexportdialog.ui  |  4 ++--
 theme/dive_export.html        |  3 +++
 3 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 03bdaf9..0b6ab73 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -93,6 +93,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
 
 	exportHTMLsettings(json_settings);
 	exportHTMLstatistics(stat_file);
+
 	export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());
 
 	QString searchPath = getSubsurfaceDataPath("theme");
@@ -140,25 +141,27 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 	QTextStream out(&file);
 	int i = 0;
 	out << "divestat=[";
-	while (stats_yearly != NULL && stats_yearly[i].period) {
-		out << "{";
-		out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
-		out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
-		out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
-		out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
-		out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
-		out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
-		out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
-		out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
-		out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
-		out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
-		out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
-		out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
-		out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
-		out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
-		out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
-		out << "},";
-		i++;
+	if (ui->exportStatistics->isChecked()) {
+		while (stats_yearly != NULL && stats_yearly[i].period) {
+			out << "{";
+			out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
+			out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
+			out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
+			out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
+			out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
+			out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
+			out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
+			out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
+			out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
+			out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
+			out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
+			out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
+			out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
+			out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
+			out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
+			out << "},";
+			i++;
+		}
 	}
 	out << "]";
 	file.close();
diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui
index aeed088..0e8ef4a 100644
--- a/qt-ui/divelogexportdialog.ui
+++ b/qt-ui/divelogexportdialog.ui
@@ -216,9 +216,9 @@
            </widget>
           </item>
           <item row="1" column="0">
-           <widget class="QCheckBox" name="checkBox_2">
+           <widget class="QCheckBox" name="exportStatistics">
             <property name="text">
-             <string>Minimum Javascript</string>
+             <string>Export Yearly Statistics</string>
             </property>
            </widget>
           </item>
diff --git a/theme/dive_export.html b/theme/dive_export.html
index 91b0ef7..065a8a4 100644
--- a/theme/dive_export.html
+++ b/theme/dive_export.html
@@ -121,6 +121,9 @@ window.onload=function(){
 	showAllDives();
 	document.getElementById("divePanel").style.display='none';
 	document.getElementById("diveStat").style.display='none';
+	if (divestat.length <= 0)
+		document.getElementById("stats_button").style.display='none';
+
 	document.body.style.visibility='visible';
 
 	document.onkeydown = switchDives;
-- 
1.9.1

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

Reply via email to