From a6fcd4f99f22342da67dadb149d66f3f4ecec061 Mon Sep 17 00:00:00 2001 From: Gehad Date: Fri, 4 Apr 2014 16:39:39 +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 Signed-off-by: Dirk Hohndel --- worldmap-save.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/worldmap-save.c b/worldmap-save.c index b1a8ce68d..c193d72c1 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, "

'+''+''});\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++; } }