summaryrefslogtreecommitdiffstats
path: root/save-html.c
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-06-08 07:56:54 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-15 09:18:11 -0700
commitc7bc364ca160461ac755682c523acc07fe1a74bd (patch)
tree9f557af7489a48fa23321913e68a3f4781464af5 /save-html.c
parent4a69dea972775e666e2309cab0a04d948f54d7b4 (diff)
downloadsubsurface-c7bc364ca160461ac755682c523acc07fe1a74bd.tar.gz
HTML: export DC samples to JSON format.
-Export Dive computer samples to JSON format, for dive profile plotting. -Add maxdepth and duration to attributes of the JSON dive object. 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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/save-html.c b/save-html.c
index 501bc21cc..61c453d88 100644
--- a/save-html.c
+++ b/save-html.c
@@ -1,5 +1,20 @@
#include "save-html.h"
#include "gettext.h"
+#include "stdio.h"
+
+void put_HTML_samples(struct membuffer *b, struct dive *dive)
+{
+ int i;
+ put_format(b, "\"maxdepth\":%d,", dive->dc.maxdepth.mm);
+ put_format(b, "\"duration\":%d,", dive->dc.duration.seconds);
+ put_string(b, "\"samples\":\[");
+ struct sample *s = dive->dc.sample;
+ for (i = 0; i < dive->dc.samples; i++) {
+ put_format(b, "[%d,%d],", s->time.seconds, s->depth.mm);
+ s++;
+ }
+ put_string(b, "],");
+}
void put_HTML_date(struct membuffer *b, struct dive *dive, const char *pre, const char *post)
{
@@ -103,6 +118,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no)
write_attribute(b, "suit", dive->suit);
put_HTML_tags(b, dive, "\"tags\":", ",");
put_HTML_notes(b, dive, "\"notes\":\"", "\",");
+ put_HTML_samples(b, dive);
put_string(b, "},\n");
(*dive_no)++;
}