aboutsummaryrefslogtreecommitdiffstats
path: root/save-html.c
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-08-15 08:07:17 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-17 12:03:06 -0600
commitd2891ecbd0c9cf34fb397586147b1c08cff216dc (patch)
treef1da771372eb71177417fc7dbb6e2092529f59ae /save-html.c
parentd83c36c36b2705701c366e250a05625c4c396853 (diff)
downloadsubsurface-d2891ecbd0c9cf34fb397586147b1c08cff216dc.tar.gz
HTML: Don't export others trip if no dives are selected.
Don't export 'others' trip unless there is really at least one dive to be inserted into the 'others' group. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-html.c')
-rw-r--r--save-html.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/save-html.c b/save-html.c
index 82d81edda..336eff0be 100644
--- a/save-html.c
+++ b/save-html.c
@@ -254,18 +254,23 @@ void write_no_trip(struct membuffer *b, int *dive_no, bool selected_only, const
{
int i;
struct dive *dive;
-
- put_format(b, "{");
- put_format(b, "\"name\":\"Other\",");
- put_format(b, "\"dives\":[");
+ bool found_sel_dive = 0;
for_each_dive (i, dive) {
// 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))
+ if (!dive->divetrip && (dive->selected || !selected_only)) {
+ if (!found_sel_dive) {
+ put_format(b, "{");
+ put_format(b, "\"name\":\"Other\",");
+ put_format(b, "\"dives\":[");
+ found_sel_dive = 1;
+ }
write_one_dive(b, dive, photos_dir, dive_no, list_only);
+ }
}
- put_format(b, "]},\n\n");
+ if (found_sel_dive)
+ put_format(b, "]},\n\n");
}
void write_trip(struct membuffer *b, dive_trip_t *trip, int *dive_no, bool selected_only, const char *photos_dir, const bool list_only)