Hi miika,

I attached patches for the mentioned bug and other random fixes.
Now I think the exports are quite stable.

There is one remaining known bug in the keyboard arrows navigation between
dives I will fix it and submit a patch later.
I ll also work on some style enhancement.

thanks.


On Sun, Aug 10, 2014 at 6:22 PM, Miika Turkia <miika.tur...@gmail.com>
wrote:

> Thanks. I just fixed a few typos and will send versions with my SOB... I'd
> be interested in testing the multilingual support, but to test it properly
> requires the translations to be available.
>
> The bug I mentioned earlier about the missing trips seems to occur when
> exporting selected dives. Even if I try to export two trips, the trips are
> not shown, but all the exported dives are assigned to the "trip" *other*.
>
> miika
>
>
> On Sun, Aug 10, 2014 at 12:41 PM, Gehad Elrobey <gehadelro...@gmail.com>
> wrote:
>
>> Hi miika,
>>
>> Here are another four patches on the top of the previously sent patches.
>> This is a try to make the HTML exports Multilingual I also fixed some
>> bugs.
>> I still need to update the user-manual if you find that these patches are
>> good.
>>
>> Thanks.
>>
>>
>> On Fri, Aug 8, 2014 at 6:22 PM, Miika Turkia <miika.tur...@gmail.com>
>> wrote:
>>
>>> On Fri, Aug 8, 2014 at 5:32 PM, Gehad Elrobey <gehadelro...@gmail.com>
>>> wrote:
>>>
>>>> I have attached some patches that improves the statistics table view
>>>> and fix the cells layout.
>>>>
>>>> Thanks, I'll take a look later.
>>>
>>>>
>>>>
>>>> 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?
>>>>
>>>
>>> when I export one trip, and open the HTML, the trip mode does not show
>>> the trip info. The attached screenshot will hopefully clarify.
>>>
>>> miika
>>>
>>
>>
>
From 01d93c2e9892c9a6271209f8c0a4dffb054921b4 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 14 Aug 2014 06:32:47 +0300
Subject: [PATCH 7/7] HTML: Add coordinates to the HTML exports

-Export dive coordinates (if exist) to JSON file.
-Add dive coordinates to list view and detailed dive view.
-Add hyperlink that opens the dive location in a new tab viewed in
google maps.

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

diff --git a/save-html.c b/save-html.c
index 1efc6b9..0288d44 100644
--- a/save-html.c
+++ b/save-html.c
@@ -122,6 +122,21 @@ void put_HTML_samples(struct membuffer *b, struct dive *dive)
 	put_string(b, "],");
 }
 
+void put_HTML_coordinates(struct membuffer *b, struct dive *dive)
+{
+	degrees_t latitude = dive->latitude;
+	degrees_t longitude = dive->longitude;
+
+	//don't put coordinates if in (0,0)
+	if (!latitude.udeg && !longitude.udeg)
+		return;
+
+	put_string(b, "\"coordinates\":{");
+	put_degrees(b, latitude, "\"lat\":\"", "\",");
+	put_degrees(b, longitude, "\"lon\":\"", "\",");
+	put_string(b, "},");
+}
+
 void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post)
 {
 	struct tm tm;
@@ -207,6 +222,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d
 	put_HTML_date(b, dive, "\"date\":\"", "\",");
 	put_HTML_time(b, dive, "\"time\":\"", "\",");
 	write_attribute(b, "location", dive->location);
+	put_HTML_coordinates(b, dive);
 	put_format(b, "\"rating\":%d,", dive->rating);
 	put_format(b, "\"visibility\":%d,", dive->visibility);
 	put_format(b, "\"dive_duration\":\"%u:%02u min\",",
@@ -390,7 +406,7 @@ void export_translation(const char *file_name)
 	write_attribute(b, "Events", translate("gettextFromC", "Events"));
 	write_attribute(b, "Name", translate("gettextFromC", "Name"));
 	write_attribute(b, "Value", translate("gettextFromC", "Value"));
-
+	write_attribute(b, "Coordinates", translate("gettextFromC", "Coordinates"));
 	write_attribute(b, "Dive_Status", translate("gettextFromC", "Dive Status"));
 
 	put_format(b, "}");
diff --git a/theme/list_lib.js b/theme/list_lib.js
index d9e3922..09348a1 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -208,7 +208,7 @@ function getExpanded(dive)
 {
 	var res = '<table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Location + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + getDiveCoor(dive) +
 		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
 		  '</td></tr></table>' +
@@ -499,7 +499,7 @@ Set.prototype.intersect = function(another_set)
 	}
 	var result = new Array();
 	for (var i = 0; i < another_set.keys.length; i++) {
-		if(this.contains(another_set.keys[i])) {
+		if (this.contains(another_set.keys[i])) {
 			result.push(another_set.keys[i]);
 		}
 	};
@@ -896,6 +896,21 @@ function get_bookmarks_HTML(dive)
 	return result;
 }
 
+function getDiveCoorString(coordinates){
+	res = "";
+	lat = coordinates.lat;
+	lon = coordinates.lon;
+	res += float_to_deg(lat) +' , '+ float_to_deg(lon);
+	return res;
+}
+
+function getDiveCoor(dive)
+{
+	if (!dive.coordinates)
+		return "";
+	return '<td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Coordinates + ': </td><td>' + '<a href="http://www.google.com/maps/@'+dive.coordinates.lat+','+dive.coordinates.lon+',13z" target="_blank">' + getDiveCoorString(dive.coordinates) + '</a></td>';
+}
+
 /**
 *Return HTML main data of a dive
 */
@@ -903,8 +918,8 @@ function get_dive_HTML(dive)
 {
 	var res = '<h2 class="det_hed">' + translate.Dive_information + '</h2><table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Location + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
-		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a></td>' + getDiveCoor(dive) +
+		  '</tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
 		  '</td></tr></table>' +
 		  '<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air +
@@ -1000,6 +1015,14 @@ function int_to_time(n)
 	return Math.floor((n) / 60) + ":" + format_two_digit((n) % (60)) + " min";
 }
 
+function float_to_deg(flt){
+	var deg = 0|flt;
+	flt = (flt<0?flt=-flt:flt);
+        var min = 0|flt%1*60;
+        var sec = (0|flt*60%1*6000)/100;
+        return deg + "&deg; " + min +"' " + sec +"\"";
+}
+
 /**
 *Main canvas draw function
 *this calls the axis and grid initialization functions.
@@ -1225,7 +1248,7 @@ function switchDives(e)
 
 function scrollToTheTop()
 {
-	window.scrollTo(0,0);
+	window.scrollTo(0, 0);
 }
 
 window.onresize = function(event)
-- 
1.9.1

From 8daad056db4cdf65ff9e340bd9f3d4971e43d9bf Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 14 Aug 2014 05:38:40 +0300
Subject: [PATCH 6/7] HTML: Sort by number based on the chosen number format.

sorting by the number must be based on either subsurface number or the
regular indexing as choosed in settings.json

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

diff --git a/theme/list_lib.js b/theme/list_lib.js
index ba7046e..d9e3922 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -374,9 +374,14 @@ function cmpNumAsc(j, iSmaller)
 	return items[j].subsurface_number < items[iSmaller].subsurface_number;
 }
 
+function cmpNumAsc(j, iSmaller)
+{
+	return settings.subsurfaceNumbers === '0' ? items[j].number < items[iSmaller].number  : items[j].subsurface_number < items[iSmaller].subsurface_number;
+}
+
 function cmpNumDes(j, iSmaller)
 {
-	return items[j].subsurface_number > items[iSmaller].subsurface_number;
+	return settings.subsurfaceNumbers === '0' ? items[j].number > items[iSmaller].number  : items[j].subsurface_number > items[iSmaller].subsurface_number;
 }
 
 function cmpTimeAsc(j, iSmaller)
-- 
1.9.1

From 6489d6d6076c112cc5ab5ccf6db3847cb24f64c4 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 14 Aug 2014 05:30:36 +0300
Subject: [PATCH 5/7] HTML: export selected dives in trips.

when exporting selected dives, traverse the trips and export the trip if
it contains at least one selected dive then search for all selected
dives in this trip.

Exporting selected dives only must contain trip infromation.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 save-html.c | 63 +++++++++++++++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/save-html.c b/save-html.c
index 695221e..1efc6b9 100644
--- a/save-html.c
+++ b/save-html.c
@@ -232,7 +232,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d
 	(*dive_no)++;
 }
 
-void write_no_trip(struct membuffer *b, int *dive_no, const char *photos_dir, const bool list_only)
+void write_no_trip(struct membuffer *b, int *dive_no, bool selected_only, const char *photos_dir, const bool list_only)
 {
 	int i;
 	struct dive *dive;
@@ -242,25 +242,36 @@ void write_no_trip(struct membuffer *b, int *dive_no, const char *photos_dir, co
 	put_format(b, "\"dives\":[");
 
 	for_each_dive (i, dive) {
-		if (!dive->divetrip)
+		// write dive if it doesn't belong to any trip and the dive is selected
+		// or we are in exporting all dives mode.
+		if (!dive->divetrip && (dive->selected || !selected_only))
 			write_one_dive(b, dive, photos_dir, dive_no, list_only);
 	}
 	put_format(b, "]},\n\n");
 }
 
-void write_trip(struct membuffer *b, dive_trip_t *trip, int *dive_no, const char *photos_dir, const bool list_only)
+void write_trip(struct membuffer *b, dive_trip_t *trip, int *dive_no, bool selected_only, const char *photos_dir, const bool list_only)
 {
 	struct dive *dive;
-
-	put_format(b, "{");
-	put_format(b, "\"name\":\"%s\",", trip->location);
-	put_format(b, "\"dives\":[");
+	bool found_sel_dive = 0;
 
 	for (dive = trip->dives; dive != NULL; dive = dive->next) {
+		if (!dive->selected && selected_only)
+			continue;
+
+		// save trip if found at least one selected dive.
+		if (!found_sel_dive) {
+			found_sel_dive = 1;
+			put_format(b, "{");
+			put_format(b, "\"name\":\"%s\",", trip->location);
+			put_format(b, "\"dives\":[");
+		}
 		write_one_dive(b, dive, photos_dir, dive_no, list_only);
 	}
 
-	put_format(b, "]},\n\n");
+	// close the trip object if contain dives.
+	if (found_sel_dive)
+		put_format(b, "]},\n\n");
 }
 
 void write_trips(struct membuffer *b, const char *photos_dir, bool selected_only, const bool list_only)
@@ -272,34 +283,20 @@ void write_trips(struct membuffer *b, const char *photos_dir, bool selected_only
 	for (trip = dive_trip_list; trip != NULL; trip = trip->next)
 		trip->index = 0;
 
-	if (selected_only) {
-		put_format(b, "{");
-		put_format(b, "\"name\":\"Other\",");
-		put_format(b, "\"dives\":[");
-
-		for_each_dive (i, dive) {
-			if (!dive->selected)
-				continue;
-			write_one_dive(b, dive, photos_dir, &dive_no, list_only);
-		}
-		put_format(b, "]},\n\n");
-	} else {
-
-		for_each_dive (i, dive) {
-			trip = dive->divetrip;
-
-			/*Continue if the dive have no trips or we have seen this trip before*/
-			if (!trip || trip->index)
-				continue;
+	for_each_dive (i, dive) {
+		trip = dive->divetrip;
 
-			/* We haven't seen this trip before - save it and all dives */
-			trip->index = 1;
-			write_trip(b, trip, &dive_no, photos_dir, list_only);
-		}
+		/*Continue if the dive have no trips or we have seen this trip before*/
+		if (!trip || trip->index)
+			continue;
 
-		/*Save all remaining trips into Others*/
-		write_no_trip(b, &dive_no, photos_dir, list_only);
+		/* We haven't seen this trip before - save it and all dives */
+		trip->index = 1;
+		write_trip(b, trip, &dive_no, selected_only, photos_dir, list_only);
 	}
+
+	/*Save all remaining trips into Others*/
+	write_no_trip(b, &dive_no, selected_only, photos_dir, list_only);
 }
 
 void export_list(struct membuffer *b, const char *photos_dir, bool selected_only, const bool list_only)
-- 
1.9.1

From d69edb889452b85a1d76f7dc90d7e9e2e8a20694 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Wed, 13 Aug 2014 06:38:33 +0300
Subject: [PATCH 4/7] HTML: arrow navigation is based on full dive list.

The navigation arrows from the detailed dive view is based on the full
dive list, regardless of 'items_to_show' list.

This can introduce unexpected behaviour if some search results or
explicitly sorted list are shown in the list view. then restoring this
list view from the detailed dive view after some arrow navigation.

Arrow navigation must be separte and don't change the 'start_id'
variable.

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

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 1a40eeb..ba7046e 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -1182,7 +1182,6 @@ function setDiveTitle(dive)
 */
 function unshowDiveDetails(dive)
 {
-	start = dive_id;
 	viewInPage();
 	plot1 = null;
 	document.getElementById("diveListPanel").style.display = 'block';
-- 
1.9.1

From f5561fbe5f17fb7fb05585413df699232c65ca3f Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Tue, 12 Aug 2014 13:30:18 +0300
Subject: [PATCH 3/7] HTML: Scroll page to the top before showing the detailed
 view.

When looking at the dive list view, clicking on the 'show more details'
retains the view at the current vertical position, meaning that the
graph is somewhere above, outside the page view.

Page must be scrolled to the top before viewing the detailed dive view.

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

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 8c365d5..1a40eeb 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -1166,6 +1166,7 @@ function showDiveDetails(dive)
 	document.getElementById("diveListPanel").style.display = 'none';
 	document.getElementById("divePanel").style.display = 'block';
 	canvas_draw();
+	scrollToTheTop();
 }
 
 function setDiveTitle(dive)
@@ -1218,6 +1219,11 @@ function switchDives(e)
 	}
 }
 
+function scrollToTheTop()
+{
+	window.scrollTo(0,0);
+}
+
 window.onresize = function(event)
 {
 	if (plot1)
-- 
1.9.1

From cbf65727cd9576770917233d8be4f3c68f154d32 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Mon, 11 Aug 2014 17:25:13 +0300
Subject: [PATCH 2/7] HTML: don't update axis on window resize

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
---
 theme/list_lib.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 085d049..8c365d5 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -1222,7 +1222,7 @@ window.onresize = function(event)
 {
 	if (plot1)
 		plot1.replot({
-			resetAxes : true
+			resetAxes : false
 		});
 };
 
-- 
1.9.1

From 80b0bdb9c77180a68f0a69555c3a3bac64c46f21 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Mon, 11 Aug 2014 17:20:34 +0300
Subject: [PATCH 1/7] HTML: Fix sorting water and air temperature values

Parse values by float instead of integer.

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

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 348765b..085d049 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -401,22 +401,22 @@ function cmpDateDes(j, iSmaller)
 
 function cmpAtempAsc(j, iSmaller)
 {
-	return parseInt(items[j].temperature.air, 10) < parseInt(items[iSmaller].temperature.air, 10);
+	return parseFloat(items[j].temperature.air, 10) < parseFloat(items[iSmaller].temperature.air, 10);
 }
 
 function cmpAtempDes(j, iSmaller)
 {
-	return parseInt(items[j].temperature.air, 10) > parseInt(items[iSmaller].temperature.air, 10);
+	return parseFloat(items[j].temperature.air, 10) > parseFloat(items[iSmaller].temperature.air, 10);
 }
 
 function cmpWtempAsc(j, iSmaller)
 {
-	return parseInt(items[j].temperature.water, 10) < parseInt(items[iSmaller].temperature.water, 10);
+	return parseFloat(items[j].temperature.water, 10) < parseFloat(items[iSmaller].temperature.water, 10);
 }
 
 function cmpWtempDes(j, iSmaller)
 {
-	return parseInt(items[j].temperature.water, 10) > parseInt(items[iSmaller].temperature.water, 10);
+	return parseFloat(items[j].temperature.water, 10) > parseFloat(items[iSmaller].temperature.water, 10);
 }
 
 function sort_it(sortOn, function_)
-- 
1.9.1

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

Reply via email to