diff options
Diffstat (limited to 'worldmap-save.c')
-rw-r--r-- | worldmap-save.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/worldmap-save.c b/worldmap-save.c index e867846f5..b82ccd3eb 100644 --- a/worldmap-save.c +++ b/worldmap-save.c @@ -6,6 +6,7 @@ #include "membuffer.h" #include "worldmap-save.h" #include "worldmap-options.h" +#include "gettext.h" char *getGoogleApi() { @@ -17,14 +18,20 @@ void put_HTML_date(struct membuffer *b, struct dive *dive) { struct tm tm; utc_mkdate(dive->when, &tm); - put_format(b, "<p>date=%04u-%02u-%02u</p>", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); - put_format(b, "<p>time=%02u:%02u:%02u</p>", tm.tm_hour, tm.tm_min, tm.tm_sec); + put_format(b, "<p>%s: %04u-%02u-%02u</p>", translate("gettextFromC", "Date"), tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); + put_format(b, "<p>%s: %02u:%02u:%02u</p>", translate("gettextFromC", "Time"), tm.tm_hour, tm.tm_min, tm.tm_sec); } void put_HTML_temp(struct membuffer *b, struct dive *dive) { - put_temperature(b, dive->airtemp, "<p>Air Temp: ", " C\\'</p>"); - put_temperature(b, dive->watertemp, "<p>Water Temp: ", " C\\'</p>"); + const char *unit; + double value; + + value = get_temp_units(dive->airtemp.mkelvin, &unit); + put_format(b, "<p>%s: %.1f %s</p>", translate("gettextFromC", "Air Temp"), value, unit); + + value = get_temp_units(dive->watertemp.mkelvin, &unit); + put_format(b, "<p>%s: %.1f %s</p>", translate("gettextFromC", "Water Temp"), value, unit); } char *replace_char(char *str, char replace, char *replace_by) @@ -78,27 +85,31 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive) { if (dive->notes) { char *notes = quote(dive->notes); - put_format(b, "<p>Notes : %s </p>", notes); + put_format(b, "<p>%s: %s </p>", translate("gettextFromC", "Notes"), notes); free(notes); } } -void writeMarkers(struct membuffer *b) +void writeMarkers(struct membuffer *b, const bool selected_only) { int i, dive_no = 0; struct dive *dive; for_each_dive(i, dive) { - /*export selected dives only ?*/ - + 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: '<div id=\"content\">'+'<div id=\"siteNotice\">'+'</div>'+'<div id=\"bodyContent\">"); + put_format(b, "<p><b>%s</b></p>", quote(dive->location)); put_HTML_date(b, dive); - put_duration(b, dive->duration, "<p>duration=", " min</p>"); + put_duration(b, dive->duration, translate("gettextFromC", "<p>Duration: "), translate("gettextFromC", " min</p>")); + put_depth(b, dive->maxdepth, translate("gettextFromC", "<p>Max Depth: "), translate("gettextFromC", " m</p>")); put_HTML_temp(b, dive); put_HTML_notes(b, dive); put_string(b, "</p>'+'</div>'+'</div>'});\ninfowindows.push(tempinfowindow);\n"); @@ -120,7 +131,7 @@ void insert_css(struct membuffer *b) put_format(b, "<style type=\"text/css\">%s</style>\n", css); } -void insert_javascript(struct membuffer *b) +void insert_javascript(struct membuffer *b, const bool selected_only) { put_string(b, "<script type=\"text/javascript\" src=\""); put_string(b, getGoogleApi()); @@ -129,25 +140,25 @@ void insert_javascript(struct membuffer *b) put_string(b, "rotateControl: false,\n\tstreetViewControl: false,\n\tmapTypeControl: false\n};\n"); put_string(b, "map = new google.maps.Map(document.getElementById(\"map-canvas\"),mapOptions);\nvar markers = new Array();"); put_string(b, "\nvar infowindows = new Array();\nvar temp;\nvar tempinfowindow;\n"); - writeMarkers(b); + writeMarkers(b, selected_only); put_string(b, "\nfor(var i=0;i<markers.length;i++)\n\tmarkers[i].setMap(map);\n}\n"); put_string(b, "google.maps.event.addDomListener(window, 'load', initialize);</script>\n"); } -void export(struct membuffer *b) +void export(struct membuffer *b, const bool selected_only) { insert_html_header(b); insert_css(b); - insert_javascript(b); + insert_javascript(b, selected_only); put_string(b, "\t</head>\n<body>\n<div id=\"map-canvas\"></div>\n</body>\n</html>"); } -void export_worldmap_HTML(const char *file_name) +void export_worldmap_HTML(const char *file_name, const bool selected_only) { FILE *f; struct membuffer buf = { 0 }; - export(&buf); + export(&buf, selected_only); f = fopen(file_name, "w+"); if (!f) |