mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
HTML: add weight systems to the dive equipments section.
Add weights systems to the dive equipment list. 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>
This commit is contained in:
parent
979ea564a0
commit
4d6ff4c8d1
2 changed files with 50 additions and 0 deletions
22
save-html.c
22
save-html.c
|
@ -44,6 +44,27 @@ void put_HTML_bookmarks(struct membuffer *b, struct dive *dive)
|
|||
put_string(b, "],");
|
||||
}
|
||||
|
||||
static void put_weightsystem_HTML(struct membuffer *b, struct dive *dive)
|
||||
{
|
||||
int i, nr;
|
||||
|
||||
nr = nr_weightsystems(dive);
|
||||
|
||||
put_string(b, "\"Weights\":[");
|
||||
|
||||
for (i = 0; i < nr; i++) {
|
||||
weightsystem_t *ws = dive->weightsystem + i;
|
||||
int grams = ws->weight.grams;
|
||||
const char *description = ws->description;
|
||||
|
||||
put_string(b, "{");
|
||||
put_format(b, "\"weight\":\"%d\",", grams);
|
||||
write_attribute(b, "description", description);
|
||||
put_string(b, "},");
|
||||
}
|
||||
put_string(b, "],");
|
||||
}
|
||||
|
||||
static void put_cylinder_HTML(struct membuffer *b, struct dive *dive)
|
||||
{
|
||||
int i, nr;
|
||||
|
@ -199,6 +220,7 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d
|
|||
put_HTML_notes(b, dive, "\"notes\":\"", "\",");
|
||||
if (!list_only) {
|
||||
put_cylinder_HTML(b, dive);
|
||||
put_weightsystem_HTML(b, dive);
|
||||
put_HTML_samples(b, dive);
|
||||
put_HTML_bookmarks(b, dive);
|
||||
write_dive_status(b, dive);
|
||||
|
|
|
@ -735,6 +735,28 @@ function lastNonZero()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*Return the HTML string for a dive weight entry in the table.
|
||||
*/
|
||||
function get_weight_HTML(weight)
|
||||
{
|
||||
return '<tr><td class="Cyl">' + gram_to_km(weight.weight) + ' kg ' + '</td><td class="Cyl">' + weight.description + '</td></tr>';
|
||||
}
|
||||
|
||||
/**
|
||||
*Return HTML table of weights of a dive.
|
||||
*/
|
||||
function get_weights_HTML(dive)
|
||||
{
|
||||
var result = "";
|
||||
result += '<table><tr><td class="words">Weight</td><td class="words">Type</td></tr>';
|
||||
for (var i in dive.Weights) {
|
||||
result += get_weight_HTML(dive.Weights[i]);
|
||||
}
|
||||
result += '</table>';
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*Return the HTML string for a dive cylinder entry in the table.
|
||||
*/
|
||||
|
@ -890,6 +912,11 @@ function mm_to_meter(mm)
|
|||
return mm / (1000);
|
||||
}
|
||||
|
||||
function gram_to_km(gram)
|
||||
{
|
||||
return gram / 1000;
|
||||
}
|
||||
|
||||
function ml_to_litre(ml)
|
||||
{
|
||||
return ml / (1000);
|
||||
|
@ -1067,6 +1094,7 @@ function showDiveDetails(dive)
|
|||
//draw the canvas and initialize the view
|
||||
document.getElementById("diveinfo").innerHTML = get_dive_HTML(items[dive_id]);
|
||||
document.getElementById("dive_equipments").innerHTML = get_cylinders_HTML(items[dive_id]);
|
||||
document.getElementById("dive_equipments").innerHTML += get_weights_HTML(items[dive_id]);
|
||||
document.getElementById("bookmarks").innerHTML = get_bookmarks_HTML(items[dive_id]);
|
||||
document.getElementById("divestats").innerHTML = get_status_HTML(items[dive_id]);
|
||||
document.getElementById("slider").innerHTML = get_dive_photos(items[dive_id]);
|
||||
|
|
Loading…
Add table
Reference in a new issue