#include #include #include #include #include "dive.h" #include "membuffer.h" #include "save-html.h" #include "worldmap-save.h" #include "worldmap-options.h" #include "gettext.h" char *getGoogleApi() { /* google maps api auth*/ return "https://maps.googleapis.com/maps/api/js?key=AIzaSyDzo9PWsqYDDSddVswg_13rpD9oH_dLuoQ"; } void writeMarkers(struct membuffer *b, const bool selected_only) { int i, dive_no = 0; struct dive *dive; for_each_dive (i, dive) { if (selected_only) { if (!dive->selected) continue; } if (dive->latitude.udeg == 0 && dive->longitude.udeg == 0) continue; put_degrees(b, dive->latitude, "temp = new google.maps.Marker({position: new google.maps.LatLng(", ""); put_degrees(b, dive->longitude, ",", ")});\n"); put_string(b, "markers.push(temp);\ntempinfowindow = new google.maps.InfoWindow({content: '
'+'
'+'
'+'
"); put_HTML_date(b, dive, translate("gettextFromC", "

Date:"), "

"); put_HTML_time(b, dive, translate("gettextFromC", "

Time:"), "

"); put_duration(b, dive->duration, translate("gettextFromC", "

Duration: "), translate("gettextFromC", " min

")); put_depth(b, dive->maxdepth, translate("gettextFromC", "

Max Depth: "), translate("gettextFromC", " m

")); put_HTML_airtemp(b, dive, translate("gettextFromC", "

Air Temp: "), "

"); put_HTML_watertemp(b, dive, translate("gettextFromC", "

Water Temp : "), "

"); put_format(b, "

Location : %s

", quote(dive->location)); put_HTML_notes(b, dive, translate("gettextFromC", "

Notes"), "

"); put_string(b, "

'+'
'+'
'});\ninfowindows.push(tempinfowindow);\n"); 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++; } } void insert_html_header(struct membuffer *b) { put_string(b, "\n\n\n"); put_string(b, "\nWorld Map\n"); put_string(b, ""); } void insert_css(struct membuffer *b) { put_format(b, "\n", css); } void insert_javascript(struct membuffer *b, const bool selected_only) { put_string(b, "\n\n"); } void export(struct membuffer *b, const bool selected_only) { insert_html_header(b); insert_css(b); insert_javascript(b, selected_only); put_string(b, "\t\n\n
\n\n"); } void export_worldmap_HTML(const char *file_name, const bool selected_only) { FILE *f; struct membuffer buf = { 0 }; export(&buf, selected_only); f = fopen(file_name, "w+"); if (!f) printf("error"); /*report error*/ flush_buffer(&buf, f); /*check for writing errors? */ free_buffer(&buf); fclose(f); }