The attached patch fixes the problem.
some array index in the exported javascript where missing which caused
the JS function to crash.
Tested on poltsi's log.
--
Regards,
Gehad Elrobey
>From 72abca2088020000d11af4cad2f77ac83318518d Mon Sep 17 00:00:00 2001
From: Gehad elrobey <[email protected]>
Date: Fri, 4 Apr 2014 16:23:15 +0200
Subject: [PATCH] Javascript exported code throws errors when dives are missing
The world map exported Javascript sometimes fail because dives with
no coarinates are neglected during exporting which leaves some array
indexes missing and corrupt the javascript.
Signed-off-by: Gehad elrobey <[email protected]>
---
worldmap-save.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/worldmap-save.c b/worldmap-save.c
index b1a8ce6..c193d72 100644
--- a/worldmap-save.c
+++ b/worldmap-save.c
@@ -85,7 +85,7 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive)
void writeMarkers(struct membuffer *b)
{
- int i;
+ int i, dive_no = 0;
struct dive *dive;
for_each_dive(i, dive) {
@@ -102,8 +102,9 @@ void writeMarkers(struct membuffer *b)
put_HTML_temp(b, dive);
put_HTML_notes(b, dive);
put_string(b, "</p>'+'</div>'+'</div>'});\ninfowindows.push(tempinfowindow);\n");
- put_format(b, "google.maps.event.addListener(markers[%d], 'mouseover', function() {\ninfowindows[%d].open(map,markers[%d]);}", i, i, i);
- put_format(b, ");google.maps.event.addListener(markers[%d], 'mouseout', function() {\ninfowindows[%d].close();});\n", i, i);
+ put_format(b, "google.maps.event.addListener(markers[%d], 'mouseover', function() {\ninfowindows[%d].open(map,markers[%d]);}", dive_no, dive_no, dive_no);
+ put_format(b, ");google.maps.event.addListener(markers[%d], 'mouseout', function() {\ninfowindows[%d].close();});\n", dive_no, dive_no);
+ dive_no++;
}
}
--
1.8.3.2
_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface