Resending as requested.

miika

---------- Forwarded message ----------
From: Miika Turkia <miika.tur...@gmail.com>
Date: Sun, Aug 10, 2014 at 6:30 PM
Subject: HTML export patches
To: Subsurface Mailing List <subsurface@hohndel.org>


Hi, here are some patches (from Gehad) to the HTML export. A couple of new
strings now that 4.2 is out :D

Now there should be language support on the HTML export, but I couldn't
test that feature due to missing translations.

Gehad: have you taken into account that some of the translations will
contain characters that should be quoted?

miika
From 14525ed3e05c7895958fdb6da64f435870de3ed5 Mon Sep 17 00:00:00 2001
From: Miika Turkia <miika.tur...@gmail.com>
Date: Sun, 10 Aug 2014 18:10:07 +0300
Subject: [PATCH 10/10] Fix typo on HTML export

Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 save-html.c       | 2 +-
 theme/list_lib.js | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/save-html.c b/save-html.c
index 150ee3c..02d131e 100644
--- a/save-html.c
+++ b/save-html.c
@@ -338,7 +338,7 @@ void export_translation(const char *file_name){
 	write_attribute(b, "Number", translate("gettextFromC", "Number"));
 	write_attribute(b, "Date", translate("gettextFromC", "Date"));
 	write_attribute(b, "Time", translate("gettextFromC", "Time"));
-	write_attribute(b, "Locaiton", translate("gettextFromC", "Locaiton"));
+	write_attribute(b, "Location", translate("gettextFromC", "Location"));
 	write_attribute(b, "Air_Temp", translate("gettextFromC", "Air Temp"));
 	write_attribute(b, "Water_Temp", translate("gettextFromC", "Water Temp"));
 	write_attribute(b, "dives", translate("gettextFromC", "dives"));
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 8c2faca..348765b 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -208,7 +208,7 @@ function getExpanded(dive)
 {
 	var res = '<table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Location + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
 		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
 		  '</td></tr></table>' +
@@ -898,7 +898,7 @@ function get_dive_HTML(dive)
 {
 	var res = '<h2 class="det_hed">' + translate.Dive_information + '</h2><table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Location + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
 		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
 		  '</td></tr></table>' +
@@ -1231,7 +1231,7 @@ function translate_page()
 	document.getElementById("number_header").innerHTML = translate.Number;
 	document.getElementById("date_header").innerHTML = translate.Date;
 	document.getElementById("time_header").innerHTML = translate.Time;
-	document.getElementById("location_header").innerHTML = translate.Locaiton;
+	document.getElementById("location_header").innerHTML = translate.Location;
 	document.getElementById("air_temp_header").innerHTML = translate.Air_Temp;
 	document.getElementById("water_temp_header").innerHTML = translate.Water_Temp;
 	document.getElementById("adv_srch_sp").innerHTML = translate.Advanced_Search;
-- 
1.9.1

From d09f73642abbcf93cf65502dcca6ca25128ff181 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Sun, 10 Aug 2014 12:25:03 +0300
Subject: [PATCH 09/10] HTML: show translated words dynamically from JSON
 translation file.

Make HTML exports Multilingual by showing dynamically the HTML words
from JSON files. The needed words are translated using the translation
API in subsurface.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 theme/dive_export.html |  32 +++++++-----
 theme/list_lib.js      | 135 +++++++++++++++++++++++++++++--------------------
 2 files changed, 100 insertions(+), 67 deletions(-)

diff --git a/theme/dive_export.html b/theme/dive_export.html
index 065a8a4..fd98ba4 100644
--- a/theme/dive_export.html
+++ b/theme/dive_export.html
@@ -39,6 +39,10 @@ function load_scripts()
 	document.getElementsByTagName("head")[0].appendChild(fileref);
 
 	fileref=document.createElement('script');
+	fileref.setAttribute("src", location.pathname + "_files/translation.json");
+	document.getElementsByTagName("head")[0].appendChild(fileref);
+
+	fileref=document.createElement('script');
 	fileref.setAttribute("src", location.pathname + "_files/settings.json");
 	document.getElementsByTagName("head")[0].appendChild(fileref);
 
@@ -127,6 +131,9 @@ window.onload=function(){
 	document.body.style.visibility='visible';
 
 	document.onkeydown = switchDives;
+
+	//translate Page
+	translate_page();
 }
 
 function changeAdvSearch(e){
@@ -145,7 +152,8 @@ function changeAdvSearch(e){
 	</center>
 	<div id="diveListPanel">
 	<div id="controlbox">
-		<input id="search_input" oninput="SearchModules(this.value, null)" placeholder="search"/><a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a>
+		<input id="search_input" oninput="SearchModules(this.value, null)" placeholder="search"/>
+		<a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a>
 		<div id="advanced_search">
 		<input type="checkbox" onchange="changeAdvSearch(this)" value="location" checked>Location<br>
 		<input type="checkbox" onchange="changeAdvSearch(this)" value="divemaster" checked>Divemaster<br>
@@ -160,19 +168,19 @@ function changeAdvSearch(e){
 			<option>50</option>
 			<option>100</option>
 		</select>
-		<button onClick="expandAll()"> Expand All </button>
-		<button onClick="collapseAll()"> Collapse All </button>
+		<button id="expnd_all_btn" onClick="expandAll()"> Expand All </button>
+		<button id="claps_all_btn" onClick="collapseAll()"> Collapse All </button>
 		<button id="trip_button" onclick="toggleTrips();">trips</button>
 		<button id="stats_button" onclick="toggleStats();">Stats</button>
 		</div>
 	</div>
 		<div id="header">
-		<div onClick="change_sort_col('1')" class="item">Number</div>
-		<div onClick="change_sort_col('2')" class="item">Date</div>
-		<div onClick="change_sort_col('3')" class="item">Time</div>
-		<div onClick="change_sort_col('6')" class="item_large">Location</div>
-		<div onClick="change_sort_col('4')" class="item">Air Temp</div>
-		<div onClick="change_sort_col('5')" class="item">Water Temp</div>
+		<div id="number_header" onClick="change_sort_col('1')" class="item">Number</div>
+		<div id="date_header" onClick="change_sort_col('2')" class="item">Date</div>
+		<div id="time_header" onClick="change_sort_col('3')" class="item">Time</div>
+		<div id="location_header" onClick="change_sort_col('6')" class="item_large">Location</div>
+		<div id="air_temp_header" onClick="change_sort_col('4')" class="item">Air Temp</div>
+		<div id="water_temp_header" onClick="change_sort_col('5')" class="item">Water Temp</div>
 	</div>
 	<div id="diveslist">
 	</div>
@@ -188,7 +196,7 @@ function changeAdvSearch(e){
 	<center>
 	<div id="but">
 		<button onClick="prevDetailedDive()">&lt;-</button>
-		<button onClick="unshowDiveDetails()">Back to List</button>
+		<button id="bk_to_ls_lbl" onClick="unshowDiveDetails()">Back to List</button>
 		<button onClick="nextDetailedDive()">-&gt;</button>
 	</div>
 	</center>
@@ -197,7 +205,7 @@ function changeAdvSearch(e){
 		<h2 id="dive_no"></h2>
 		<h3 id="dive_location"></h3>
 		</center>
-		<h2 class="det_hed">Dive profile</h2>
+		<h2 id="div_profil_lbl" class="det_hed">Dive profile</h2>
 		<div style="width:100%" id="chart1"></div>
 		</div>
 		<div id="diveinfo">
@@ -224,7 +232,7 @@ function changeAdvSearch(e){
 	</div>
 	<div id="diveStat">
 	<center>
-	<button onClick="toggleStats()">Back to List</button>
+	<button id="bk_to_ls_lbl2" onClick="toggleStats()">Back to List</button>
 	</center>
 		<div id="diveStatsData">
 		</div>
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 089f8bf..8c2faca 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -126,7 +126,7 @@ function next_page()
 function view_pagging(start, end)
 {
 	var page = document.getElementById("pagging");
-	page.innerHTML = (start + 1) + ' to ' + (end + 1) + ' of ' + (itemsToShow.length) + ' dives';
+	page.innerHTML = (start + 1) + ' to ' + (end + 1) + ' of ' + (itemsToShow.length) + '' + translate.dives;
 }
 
 /**
@@ -134,12 +134,14 @@ function view_pagging(start, end)
 */
 function expandAll()
 {
+	console.time('expnadAll');
 	for (var i = start; i < start + sizeofpage; i++) {
 		if (i >= itemsToShow.length)
 			break;
 		unexpand(document.getElementById(itemsToShow[i]));
 		items[itemsToShow[i]].expanded = false;
 	}
+	console.timeEnd('expnadAll');
 }
 
 /**
@@ -204,22 +206,22 @@ function getlimited(dive)
 
 function getExpanded(dive)
 {
-	var res = '<table><tr><td class="words">Date: </td><td>' + dive.date +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time: </td><td>' + dive.time +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
-		  '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;Visibilty:</td><td>' + putRating(dive.visibility) +
+	var res = '<table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
+		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
 		  '</td></tr></table>' +
-		  '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
-		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-		  '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
-		  '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
-		  '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
-		  '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
-		  '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
-		  '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>';
+		  '<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Water_Temp + ': </td><td>' + dive.temperature.water +
+		  '</td></tr></table><table><tr><td class="words">' + translate.Duration + ': </td><td>' + dive.dive_duration +
+		  '</td></tr><tr><td class="words">' + translate.DiveMaster + ': </td><td>' + dive.divemaster +
+		  '</td></tr><tr><td class="words"><p>' + translate.Buddy + ': </p></td><td>' + dive.buddy +
+		  '</td></tr><tr><td class="words">' + translate.Suit + ': </td><td>' + dive.suit +
+		  '</td></tr><tr><td class="words">' + translate.Tags + ': </td><td>' + putTags(dive.tags) +
+		  '</td></tr></table><div style="margin:10px;"><p class="words">' + translate.Notes + ': </p>' + dive.notes + '</div>';
 	if (settings.listOnly === '0') {
-		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">Show more details</a></center>';
+		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">' + translate.Show_more_details + '</a></center>';
 	}
 	return res;
 };
@@ -660,11 +662,11 @@ function toggleStats()
 	if (statsShows) {
 		statsShows = false;
 		stats_button.style.backgroundColor = "#dfdfdf";
-		document.getElementById('diveListPanel').style.display='block';
-		document.getElementById('diveStat').style.display='none';
+		document.getElementById('diveListPanel').style.display = 'block';
+		document.getElementById('diveStat').style.display = 'none';
 	} else {
-		document.getElementById('diveListPanel').style.display='none';
-		document.getElementById('diveStat').style.display='block';
+		document.getElementById('diveListPanel').style.display = 'none';
+		document.getElementById('diveStat').style.display = 'block';
 		stats_button.style.backgroundColor = "#5f7f8f";
 		statsShows = true;
 		showStats();
@@ -677,29 +679,33 @@ function showStats()
 	document.getElementById('diveStatsData').innerHTML += getDiveStats();
 }
 
-function getDiveStats(){
+function getDiveStats()
+{
 	var res = "";
 	res += '<table><tr id="stats_header">';
-	res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Average Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Average Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>';
+	res += '<td class="statscell">' + translate.Year + '</td><td class="statscell">#</td><td class="statscell">' + translate.Total_Time + '</td><td class="statscell">' + translate.Average_Time + '</td><td class="statscell">' + translate.Shortest_Time + '</td><td class="statscell">' + translate.Longest_Time + '</td><td class="statscell">' + translate.Average_Depth + '</td><td class="statscell">' + translate.Min_Depth + '</td><td class="statscell">' + translate.Max_Depth + '</td><td class="statscell">' + translate.Average_SAC + '</td><td class="statscell">' + translate.Min_SAC + '</td><td class="statscell">' + translate.Max_SAC + '</td><td class="statscell">' + translate.Average_Temp + '</td><td class="statscell">' + translate.Min_Temp + '</td><td class="statscell">' + translate.Max_Temp + '</td>';
 	res += '</tr>';
 	res += getStatsRows();
 	res += '</table>';
 	return res;
 }
 
-function getStatsRows(){
+function getStatsRows()
+{
 	var res = "";
-	for(var i = 0; i < divestat.length ; i++) {
-	res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>';
+	for (var i = 0; i < divestat.length; i++) {
+		res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">' + divestat[i].YEAR + '</td><td class="statscell">' + divestat[i].DIVES + '</td><td class="statscell">' + divestat[i].TOTAL_TIME + '</td><td class="statscell">' + divestat[i].AVERAGE_TIME + '</td><td class="statscell">' + divestat[i].SHORTEST_TIME + '</td><td class="statscell">' + divestat[i].LONGEST_TIME + '</td><td class="statscell">' + divestat[i].AVG_DEPTH + '</td><td class="statscell">' + divestat[i].MIN_DEPTH + '</td><td class="statscell">' + divestat[i].MAX_DEPTH + '</td><td class="statscell">' + divestat[i].AVG_SAC + '</td><td class="statscell">' + divestat[i].MIN_SAC + '</td><td class="statscell">' + divestat[i].MAX_SAC + '</td><td class="statscell">' + divestat[i].AVG_TEMP + '</td><td class="statscell">' + divestat[i].MIN_TEMP + '</td><td class="statscell">' + divestat[i].MAX_TEMP + '</td></tr>';
 	}
 	return res;
 }
 
-function stats_row_highlight(row){
+function stats_row_highlight(row)
+{
 	row.style.backgroundColor = "rgba(125,125,125,0.7)";
 }
 
-function stats_row_unhighlight(row){
+function stats_row_unhighlight(row)
+{
 	row.style.backgroundColor = "rgba(125,125,125,0.3)";
 }
 
@@ -806,7 +812,7 @@ function get_weight_HTML(weight)
 function get_weights_HTML(dive)
 {
 	var result = "";
-	result += '<table><tr><td class="words">Weight</td><td class="words">Type</td></tr>';
+	result += '<table><tr><td class="words">' + translate.Weight + '</td><td class="words">' + translate.Type + '</td></tr>';
 	for (var i in dive.Weights) {
 		result += get_weight_HTML(dive.Weights[i]);
 	}
@@ -840,7 +846,7 @@ function get_cylinder_HTML(cylinder)
 function get_cylinders_HTML(dive)
 {
 	var result = "";
-	result += '<h2 class="det_hed">Dive equipments</h2><table><tr><td class="words">Type</td><td class="words">Size</td><td class="words">Work Pressure</td><td class="words">Start Pressure</td><td class="words">End Pressure</td><td class="words">O2</td></tr>';
+	result += '<h2 class="det_hed">' + translate.Dive_equipments + '</h2><table><tr><td class="words">' + translate.Type + '</td><td class="words">' + translate.Size + '</td><td class="words">' + translate.Work_Pressure + '</td><td class="words">' + translate.Start_Pressure + '</td><td class="words">' + translate.End_Pressure + '</td><td class="words">O2</td></tr>';
 	for (var i in dive.Cylinders) {
 		result += get_cylinder_HTML(dive.Cylinders[i]);
 	}
@@ -877,7 +883,7 @@ function get_bookmarks_HTML(dive)
 	if (dive.events <= 0)
 		return "";
 	var result = "";
-	result += '<h2 class="det_hed">Events</h2><table><tr><td class="words">Name</td><td class="words">Time</td><td class="words">Value</td></tr>';
+	result += '<h2 class="det_hed">' + translate.Events + '</h2><table><tr><td class="words">' + translate.Name + '</td><td class="words">' + translate.Time + '</td><td class="words">' + translate.Value + '</td></tr>';
 	for (var i in dive.events) {
 		result += get_bookmark_HTML(dive.events[i]);
 	}
@@ -890,21 +896,21 @@ function get_bookmarks_HTML(dive)
 */
 function get_dive_HTML(dive)
 {
-	return '<h2 class="det_hed">Dive Information</h2><table><tr><td class="words">Date: </td><td>' + dive.date +
-	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time: </td><td>' + dive.time +
-	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Location: </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' +
-	       dive.location + '</a>' +
-	       '</td></tr></table><table><tr><td class="words">Rating:</td><td>' + putRating(dive.rating) +
-	       '</td><td class="words">&nbsp;&nbsp;&nbsp;Visibilty:</td><td>' + putRating(dive.visibility) +
-	       '</td></tr></table>' +
-	       '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
-	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-	       '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
-	       '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
-	       '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
-	       '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
-	       '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
-	       '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>';
+	var res = '<h2 class="det_hed">' + translate.Dive_information + '</h2><table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Time + ': </td><td>' + dive.time +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Locaiton + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' +
+		  '</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
+		  '</td></tr></table>' +
+		  '<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air +
+		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;' + translate.Water_Temp + ': </td><td>' + dive.temperature.water +
+		  '</td></tr></table><table><tr><td class="words">' + translate.Duration + ': </td><td>' + dive.dive_duration +
+		  '</td></tr><tr><td class="words">' + translate.DiveMaster + ': </td><td>' + dive.divemaster +
+		  '</td></tr><tr><td class="words"><p>' + translate.Buddy + ': </p></td><td>' + dive.buddy +
+		  '</td></tr><tr><td class="words">' + translate.Suit + ': </td><td>' + dive.suit +
+		  '</td></tr><tr><td class="words">' + translate.Tags + ': </td><td>' + putTags(dive.tags) +
+		  '</td></tr></table><div style="margin:10px;"><p class="words">' + translate.Notes + ': </p>' + dive.notes + '</div>';
+	return res;
 };
 
 /**
@@ -912,10 +918,9 @@ function get_dive_HTML(dive)
 */
 function get_status_HTML(dive)
 {
-	return '<h2 class="det_hed">Dive Status</h2><table><tr><td class="words">Sac: </td><td>' + ml_to_litre(dive.sac) +
+	return '<h2 class="det_hed">' + translate.Dive_Status + '</h2><table><tr><td class="words">Sac: </td><td>' + ml_to_litre(dive.sac) +
 	       ' l/min' + '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Otu: </td><td>' + dive.otu +
-	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cns: </td><td>' + dive.cns +
-	       '</td></tr></table>';
+	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cns: </td><td>' + dive.cns + '</td></tr></table>';
 };
 
 function get_dive_photos(dive)
@@ -927,8 +932,8 @@ function get_dive_photos(dive)
 	var slider = "";
 	document.getElementById("divephotos").style.display = 'block';
 	for (var i = 0; i < dive.photos.length; i++) {
-		slider += '<img src="'+location.pathname +
-			'_files/photos/'+dive.photos[i].filename+'" alt="" height="240" width="240">';
+		slider += '<img src="' + location.pathname +
+			  '_files/photos/' + dive.photos[i].filename + '" alt="" height="240" width="240">';
 	}
 	return slider;
 }
@@ -1034,8 +1039,7 @@ function canvas_draw()
 			0
 		]);
 	}
-	if (plot1)
-	{
+	if (plot1) {
 		$('chart1').unbind();
 		plot1.destroy();
 	}
@@ -1166,7 +1170,7 @@ function showDiveDetails(dive)
 
 function setDiveTitle(dive)
 {
-	document.getElementById("dive_no").innerHTML = "Dive No. " + (settings.subsurfaceNumbers === '0' ?
+	document.getElementById("dive_no").innerHTML = translate.Dive_No + (settings.subsurfaceNumbers === '0' ?
 		dive.number + 1 : dive.subsurface_number);
 	document.getElementById("dive_location").innerHTML = dive.location;
 }
@@ -1214,7 +1218,28 @@ function switchDives(e)
 	}
 }
 
-window.onresize = function(event) {
-      if (plot1)
-	      plot1.replot( { resetAxes: true } );
+window.onresize = function(event)
+{
+	if (plot1)
+		plot1.replot({
+			resetAxes : true
+		});
 };
+
+function translate_page()
+{
+	document.getElementById("number_header").innerHTML = translate.Number;
+	document.getElementById("date_header").innerHTML = translate.Date;
+	document.getElementById("time_header").innerHTML = translate.Time;
+	document.getElementById("location_header").innerHTML = translate.Locaiton;
+	document.getElementById("air_temp_header").innerHTML = translate.Air_Temp;
+	document.getElementById("water_temp_header").innerHTML = translate.Water_Temp;
+	document.getElementById("adv_srch_sp").innerHTML = translate.Advanced_Search;
+	document.getElementById("expnd_all_btn").innerHTML = translate.Expand_All;
+	document.getElementById("claps_all_btn").innerHTML = translate.Collapse_All;
+	document.getElementById("trip_button").innerHTML = translate.trips;
+	document.getElementById("stats_button").innerHTML = translate.Statistics;
+	document.getElementById("div_profil_lbl").innerHTML = translate.Dive_profile;
+	document.getElementById("bk_to_ls_lbl").innerHTML = translate.Back_to_List;
+	document.getElementById("bk_to_ls_lbl2").innerHTML = translate.Back_to_List;
+}
-- 
1.9.1

From c948a3fdba449ff1d93b5dbe7629138fc5ec95a2 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Sun, 10 Aug 2014 10:12:29 +0300
Subject: [PATCH 08/10] HTML: export Translated strings to JSON files.

First step towards multilingual export. Use the existing translation API
to translate and save words to JSON file.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp |  2 ++
 save-html.c                   | 81 +++++++++++++++++++++++++++++++++++++++++++
 save-html.h                   |  1 +
 3 files changed, 84 insertions(+)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 9ea2030..99669d6 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -95,6 +95,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
 
 	QString json_dive_data = exportFiles + QDir::separator() + "file.json";
 	QString json_settings = exportFiles + QDir::separator() + "settings.json";
+	QString translation = exportFiles + QDir::separator() + "translation.json";
 	QString stat_file = exportFiles + QDir::separator() + "stat.json";
 	QString photos_directory = exportFiles + QDir::separator() + "photos" + QDir::separator();
 	mainDir.mkdir(photos_directory);
@@ -102,6 +103,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
 
 	exportHTMLsettings(json_settings);
 	exportHTMLstatistics(stat_file);
+	export_translation(translation.toUtf8().data());
 
 	export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());
 
diff --git a/save-html.c b/save-html.c
index 6190c36..150ee3c 100644
--- a/save-html.c
+++ b/save-html.c
@@ -324,3 +324,84 @@ void export_HTML(const char *file_name, const char *photos_dir, const bool selec
 	free_buffer(&buf);
 	fclose(f);
 }
+
+void export_translation(const char *file_name){
+	FILE *f;
+
+	struct membuffer buf = { 0 };
+	struct membuffer *b = &buf;
+
+	//export translated words here
+	put_format(b, "translate={");
+
+	//Dive list view
+	write_attribute(b, "Number", translate("gettextFromC", "Number"));
+	write_attribute(b, "Date", translate("gettextFromC", "Date"));
+	write_attribute(b, "Time", translate("gettextFromC", "Time"));
+	write_attribute(b, "Locaiton", translate("gettextFromC", "Locaiton"));
+	write_attribute(b, "Air_Temp", translate("gettextFromC", "Air Temp"));
+	write_attribute(b, "Water_Temp", translate("gettextFromC", "Water Temp"));
+	write_attribute(b, "dives", translate("gettextFromC", "dives"));
+	write_attribute(b, "Expand_All", translate("gettextFromC", "Expand All"));
+	write_attribute(b, "Collapse_All", translate("gettextFromC", "Collapse All"));
+	write_attribute(b, "trips", translate("gettextFromC", "trips"));
+	write_attribute(b, "Statistics", translate("gettextFromC", "Statistics"));
+	write_attribute(b, "Advanced_Search", translate("gettextFromC", "Advanced Search"));
+
+	//Dive expanded view
+	write_attribute(b, "Rating", translate("gettextFromC", "Rating"));
+	write_attribute(b, "Visibility", translate("gettextFromC", "Visibility"));
+	write_attribute(b, "Duration", translate("gettextFromC", "Duration"));
+	write_attribute(b, "DiveMaster", translate("gettextFromC", "DiveMaster"));
+	write_attribute(b, "Buddy", translate("gettextFromC", "Buddy"));
+	write_attribute(b, "Suit", translate("gettextFromC", "Suit"));
+	write_attribute(b, "Tags", translate("gettextFromC", "Tags"));
+	write_attribute(b, "Notes", translate("gettextFromC", "Notes"));
+	write_attribute(b, "Show_more_details", translate("gettextFromC", "Show more details"));
+
+	//Yearly statistics view
+	write_attribute(b, "Yearly_statistics", translate("gettextFromC", "Yearly statistics"));
+	write_attribute(b, "Year", translate("gettextFromC", "Year"));
+	write_attribute(b, "Total_Time", translate("gettextFromC", "Total Time"));
+	write_attribute(b, "Average_Time", translate("gettextFromC", "Average Time"));
+	write_attribute(b, "Shortest_Time", translate("gettextFromC", "Shortest Time"));
+	write_attribute(b, "Longest_Time", translate("gettextFromC", "Longest Time"));
+	write_attribute(b, "Average_Depth", translate("gettextFromC", "Average Depth"));
+	write_attribute(b, "Min_Depth", translate("gettextFromC", "Min Depth"));
+	write_attribute(b, "Max_Depth", translate("gettextFromC", "Max Depth"));
+	write_attribute(b, "Average_SAC", translate("gettextFromC", "Average SAC"));
+	write_attribute(b, "Min_SAC", translate("gettextFromC", "Min SAC"));
+	write_attribute(b, "Max_SAC", translate("gettextFromC", "Max SAC"));
+	write_attribute(b, "Average_Temp", translate("gettextFromC", "Average Temp"));
+	write_attribute(b, "Min_Temp", translate("gettextFromC", "Min Temp"));
+	write_attribute(b, "Max_Temp", translate("gettextFromC", "Max Temp"));
+	write_attribute(b, "Back_to_List", translate("gettextFromC", "Back to List"));
+
+	//dive detailed view
+	write_attribute(b, "Dive_No", translate("gettextFromC", "Dive No."));
+	write_attribute(b, "Dive_profile", translate("gettextFromC", "Dive profile"));
+	write_attribute(b, "Dive_information", translate("gettextFromC", "Dive information"));
+	write_attribute(b, "Dive_equipments", translate("gettextFromC", "Dive equipments"));
+	write_attribute(b, "Type", translate("gettextFromC", "Type"));
+	write_attribute(b, "Size", translate("gettextFromC", "Size"));
+	write_attribute(b, "Work_Pressure", translate("gettextFromC", "Work Pressure"));
+	write_attribute(b, "Start_Pressure", translate("gettextFromC", "Start Pressure"));
+	write_attribute(b, "End_Pressure", translate("gettextFromC", "End Pressure"));
+	write_attribute(b, "Weight", translate("gettextFromC", "Weight"));
+	write_attribute(b, "Type", translate("gettextFromC", "Type"));
+	write_attribute(b, "Events", translate("gettextFromC", "Events"));
+	write_attribute(b, "Name", translate("gettextFromC", "Name"));
+	write_attribute(b, "Value", translate("gettextFromC", "Value"));
+
+	write_attribute(b, "Dive_Status", translate("gettextFromC", "Dive Status"));
+
+	put_format(b, "}");
+
+	f = subsurface_fopen(file_name, "w+");
+	if (!f)
+		report_error(translate("gettextFromC", "Can't open file %s"), file_name);
+
+	flush_buffer(&buf, f); /*check for writing errors? */
+	free_buffer(&buf);
+	fclose(f);
+}
diff --git a/save-html.h b/save-html.h
index 2981961..bcf69d5 100644
--- a/save-html.h
+++ b/save-html.h
@@ -16,6 +16,7 @@ void put_HTML_notes(struct membuffer *b, struct dive *dive, const char *pre, con
 void put_HTML_quoted(struct membuffer *b, const char *text);
 
 void export_HTML(const char *file_name, const char *photos_dir, const bool selected_only, const bool list_only);
+void export_translation(const char *file_name);
 
 extern void copy_image_and_overwrite(const char *cfileName, const char *cnewName);
 extern const char* get_file_name(const char *fileName);
-- 
1.9.1

From b05f6c2ed15e715c4efdbb14e61b9790c7bf806c Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Sun, 10 Aug 2014 07:10:41 +0300
Subject: [PATCH 07/10] HTML: Don't export total statistics value if not chosen

Don't export total row in yearly statistics unless exporting the
statistics is checked

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index f3f3294..9ea2030 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -182,8 +182,8 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 			total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
 			i++;
 		}
+		exportHTMLstatisticsTotal(out, &total_stats);
 	}
-	exportHTMLstatisticsTotal(out, &total_stats);
 	out << "]";
 	file.close();
 }
-- 
1.9.1

From 34ccf4fdc7a019fbb41405f5c67762034318bdaa Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Sun, 10 Aug 2014 07:10:19 +0300
Subject: [PATCH 06/10] HTML: Remember General Export Settings.

Set Default values and remember user selected general HTML export
settings.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 12 ++++++++++++
 qt-ui/divelogexportdialog.ui  |  6 ++++++
 2 files changed, 18 insertions(+)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 9156f17..f3f3294 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -45,6 +45,15 @@ DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent),
 	if (settings.contains("themeSelection")) {
 		ui->themeSelection->setCurrentIndex(settings.value("themeSelection").toInt());
 	}
+	if (settings.contains("subsurfaceNumbers")) {
+		ui->exportSubsurfaceNumber->setChecked(settings.value("subsurfaceNumbers").toBool());
+	}
+	if (settings.contains("yearlyStatistics")) {
+		ui->exportStatistics->setChecked(settings.value("yearlyStatistics").toBool());
+	}
+	if (settings.contains("listOnly")) {
+		ui->exportListOnly->setChecked(settings.value("listOnly").toBool());
+	}
 	settings.endGroup();
 }
 
@@ -122,6 +131,9 @@ void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
 	settings.setValue("fontSelection", ui->fontSelection->currentIndex());
 	settings.setValue("fontSizeSelection", ui->fontSizeSelection->currentIndex());
 	settings.setValue("themeSelection", ui->themeSelection->currentIndex());
+	settings.setValue("subsurfaceNumbers", ui->exportSubsurfaceNumber->isChecked());
+	settings.setValue("yearlyStatistics", ui->exportStatistics->isChecked());
+	settings.setValue("listOnly", ui->exportListOnly->isChecked());
 	settings.endGroup();
 
 	QString fontSize = ui->fontSizeSelection->currentText();
diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui
index 0e8ef4a..ce1513e 100644
--- a/qt-ui/divelogexportdialog.ui
+++ b/qt-ui/divelogexportdialog.ui
@@ -194,6 +194,9 @@
             <property name="text">
              <string>Subsurface numbers</string>
             </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
            </widget>
           </item>
           <item row="0" column="1">
@@ -220,6 +223,9 @@
             <property name="text">
              <string>Export Yearly Statistics</string>
             </property>
+            <property name="checked">
+             <bool>true</bool>
+            </property>
            </widget>
           </item>
           <item row="1" column="1">
-- 
1.9.1

From b4df7c55946f9f5f08918fe2d50d2dd0b2e1aa72 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Fri, 8 Aug 2014 17:18:09 +0300
Subject: [PATCH 05/10] HTML: Enhance Yearly statistics table.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 theme/light.css   |  9 +++++++--
 theme/list_lib.js | 10 +++++++++-
 theme/sand.css    | 15 ++++++++++++---
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/theme/light.css b/theme/light.css
index a1acbfa..baa04b6 100644
--- a/theme/light.css
+++ b/theme/light.css
@@ -129,7 +129,6 @@ input[type=checkbox]{
 	font-weight:bold;
 }
 
-
 #controller{
 	min-width:200px;
 	padding:10px;
@@ -159,8 +158,14 @@ input[type=checkbox]{
 }
 
 .statscell{
-	min-width:100px;
+	min-width:120px;
+	height: 25px;
 	margin:0px;
+	text-align:center;
+}
+
+.stats_row{
+	background-color:rgba(125,125,125,0.3);
 }
 
 #stats_header{
diff --git a/theme/list_lib.js b/theme/list_lib.js
index 2c915ad..089f8bf 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -690,11 +690,19 @@ function getDiveStats(){
 function getStatsRows(){
 	var res = "";
 	for(var i = 0; i < divestat.length ; i++) {
-	res += '<tr><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>';
+	res += '<tr onmouseout="stats_row_unhighlight(this)" onmouseover="stats_row_highlight(this)" class="stats_row"><td class="statscell">'+divestat[i].YEAR+'</td><td class="statscell">'+divestat[i].DIVES+'</td><td class="statscell">'+divestat[i].TOTAL_TIME+'</td><td class="statscell">'+divestat[i].AVERAGE_TIME+'</td><td class="statscell">'+divestat[i].SHORTEST_TIME+'</td><td class="statscell">'+divestat[i].LONGEST_TIME+'</td><td class="statscell">'+divestat[i].AVG_DEPTH+'</td><td class="statscell">'+divestat[i].MIN_DEPTH+'</td><td class="statscell">'+divestat[i].MAX_DEPTH+'</td><td class="statscell">'+divestat[i].AVG_SAC+'</td><td class="statscell">'+divestat[i].MIN_SAC+'</td><td class="statscell">'+divestat[i].MAX_SAC+'</td><td class="statscell">'+divestat[i].AVG_TEMP+'</td><td class="statscell">'+divestat[i].MIN_TEMP+'</td><td class="statscell">'+divestat[i].MAX_TEMP+'</td></tr>';
 	}
 	return res;
 }
 
+function stats_row_highlight(row){
+	row.style.backgroundColor = "rgba(125,125,125,0.7)";
+}
+
+function stats_row_unhighlight(row){
+	row.style.backgroundColor = "rgba(125,125,125,0.3)";
+}
+
 //trips
 
 var tripsShown;
diff --git a/theme/sand.css b/theme/sand.css
index befa861..b2f35bb 100644
--- a/theme/sand.css
+++ b/theme/sand.css
@@ -147,7 +147,7 @@ input[type=checkbox]{
 	width:90%;
 	margin:0% 5% 0% 5%;
 	margin-bottom:50px;
-	background-color: rgba(88,121,139,0.3);
+	background-color: rgba(253, 195, 141,0.3);
 	box-shadow: 10px 10px 5px #888888;
 }
 
@@ -156,9 +156,18 @@ input[type=checkbox]{
 	overflow-y:hidden;
 }
 .statscell{
-	border-style:solid;
-	padding-right:100px;
+	min-width:120px;
+	height: 25px;
 	margin:0px;
+	text-align:center;
+}
+
+.stats_row{
+	background-color:rgba(125,125,125,0.3);
+}
+
+#stats_header{
+	background-color:#EFC15F;
 }
 
 button,#no_dives_selector{
-- 
1.9.1

From 109e1520f7e280896bb031544f887fc15f202da4 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 17:11:42 +0300
Subject: [PATCH 04/10] HTML: export dive duration value to the detailed view.

Dive duration value is missing in the dive exports

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 save-html.c       | 2 ++
 theme/list_lib.js | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/save-html.c b/save-html.c
index 652ffb4..6190c36 100644
--- a/save-html.c
+++ b/save-html.c
@@ -209,6 +209,8 @@ void write_one_dive(struct membuffer *b, struct dive *dive, const char *photos_d
 	write_attribute(b, "location", dive->location);
 	put_format(b, "\"rating\":%d,", dive->rating);
 	put_format(b, "\"visibility\":%d,", dive->visibility);
+	put_format(b, "\"dive_duration\":\"%u:%02u min\",",
+		   FRACTION(dive->duration.seconds, 60));
 	put_string(b, "\"temperature\":{");
 	put_HTML_airtemp(b, dive, "\"air\":\"", "\",");
 	put_HTML_watertemp(b, dive, "\"water\":\"", "\",");
diff --git a/theme/list_lib.js b/theme/list_lib.js
index ade54c8..2c915ad 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -212,7 +212,8 @@ function getExpanded(dive)
 		  '</td></tr></table>' +
 		  '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
 		  '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-		  '</td></tr></table><table><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
+		  '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
+		  '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
 		  '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
 		  '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
 		  '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
@@ -890,7 +891,8 @@ function get_dive_HTML(dive)
 	       '</td></tr></table>' +
 	       '<table><tr><td class="words">Air temp: </td><td>' + dive.temperature.air +
 	       '</td><td class="words">&nbsp;&nbsp;&nbsp;&nbsp;Water temp: </td><td>' + dive.temperature.water +
-	       '</td></tr></table><table><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
+	       '</td></tr></table><table><tr><td class="words">Duration: </td><td>' + dive.dive_duration +
+	       '</td></tr><tr><td class="words">DiveMaster: </td><td>' + dive.divemaster +
 	       '</td></tr><tr><td class="words"><p>Buddy: </p></td><td>' + dive.buddy +
 	       '</td></tr><tr><td class="words">Suit: </td><td>' + dive.suit +
 	       '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
-- 
1.9.1

From 4f1e94941952e434a634ecae75623cef09b87c2f Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 16:11:23 +0300
Subject: [PATCH 03/10] HTML: Add total row to yearly statistics table.

Add new row to the yearly statistics table containing the total. Total
values are calculated to some columns only, it doesn't make any sense to
add the total value to other columns (Temperature cols for example).

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 30 ++++++++++++++++++++++++++++++
 qt-ui/divelogexportdialog.h   |  6 ++++++
 2 files changed, 36 insertions(+)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 0b6ab73..9156f17 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -139,6 +139,12 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 	QFile file(filename);
 	file.open(QIODevice::WriteOnly | QIODevice::Text);
 	QTextStream out(&file);
+
+	stats_t total_stats;
+
+	total_stats.selection_size = 0;
+	total_stats.total_time.seconds = 0;
+
 	int i = 0;
 	out << "divestat=[";
 	if (ui->exportStatistics->isChecked()) {
@@ -160,13 +166,37 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 			out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
 			out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
 			out << "},";
+			total_stats.selection_size += stats_yearly[i].selection_size;
+			total_stats.total_time.seconds += stats_yearly[i].total_time.seconds;
 			i++;
 		}
 	}
+	exportHTMLstatisticsTotal(out, &total_stats);
 	out << "]";
 	file.close();
 }
 
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
+{
+	out << "{";
+	out << "\"YEAR\":\"Total\",";
+	out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
+	out << "\"TOTAL_TIME\":\"" << get_time_string(total_stats->total_time.seconds, 0) << "\",";
+	out << "\"AVERAGE_TIME\":\"--\",";
+	out << "\"SHORTEST_TIME\":\"--\",";
+	out << "\"LONGEST_TIME\":\"--\",";
+	out << "\"AVG_DEPTH\":\"--\",";
+	out << "\"MIN_DEPTH\":\"--\",";
+	out << "\"MAX_DEPTH\":\"--\",";
+	out << "\"AVG_SAC\":\"--\",";
+	out << "\"MIN_SAC\":\"--\",";
+	out << "\"MAX_SAC\":\"--\",";
+	out << "\"AVG_TEMP\":\"--\",";
+	out << "\"MIN_TEMP\":\"--\",";
+	out << "\"MAX_TEMP\":\"--\",";
+	out << "},";
+}
+
 void DiveLogExportDialog::on_exportGroup_buttonClicked(QAbstractButton *button)
 {
 	showExplanation();
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index e398a5a..8472f80 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -2,12 +2,18 @@
 #define DIVELOGEXPORTDIALOG_H
 
 #include <QDialog>
+#include <QTextStream>
+#include "helpers.h"
+#include "statistics.h"
+
 class QAbstractButton;
 
 namespace Ui {
 	class DiveLogExportDialog;
 }
 
+void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats);
+
 class DiveLogExportDialog : public QDialog {
 	Q_OBJECT
 
-- 
1.9.1

From 3cb177015b32808aece290c8681a62cc056aca7e Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Thu, 7 Aug 2014 11:10:59 +0300
Subject: [PATCH 02/10] HTML: Search results must be sorted by default.

-Fix search results to be sorted by default.
-Fix two typos.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 theme/list_lib.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/theme/list_lib.js b/theme/list_lib.js
index 684d92e..ade54c8 100644
--- a/theme/list_lib.js
+++ b/theme/list_lib.js
@@ -218,7 +218,7 @@ function getExpanded(dive)
 		  '</td></tr><tr><td class="words">Tags: </td><td>' + putTags(dive.tags) +
 		  '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes + '</div>';
 	if (settings.listOnly === '0') {
-		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">show more details</a></center>';
+		res += '<center><a onclick="showDiveDetails(' + dive.number + ')">Show more details</a></center>';
 	}
 	return res;
 };
@@ -271,7 +271,7 @@ var locat = true;
 This variable keep the state of the col.
 which is sorted upon it.
 */
-var sort_based_on = 1; // sorting is based on number by default.
+var sort_based_on = '1'; // sorting is based on number by default.
 
 function change_sort_col(sortOn)
 {
@@ -679,7 +679,7 @@ function showStats()
 function getDiveStats(){
 	var res = "";
 	res += '<table><tr id="stats_header">';
-	res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Avarage Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Avarage Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>';
+	res += '<td class="statscell">Year</td><td class="statscell">#</td><td class="statscell">Total Time</td><td class="statscell">Average Time</td><td class="statscell">Shortest Time</td><td class="statscell">Longest Time</td><td class="statscell">Average Depth</td><td class="statscell">Min Depth</td><td class="statscell">Max Depth</td><td class="statscell">Average SAC</td><td class="statscell">Min SAC</td><td class="statscell">Max SAC</td><td class="statscell">Average Temp</td><td class="statscell">Min Temp</td><td class="statscell">Max Temp</td>';
 	res += '</tr>';
 	res += getStatsRows();
 	res += '</table>';
-- 
1.9.1

From 722ffde268e6cff9eda4a912cff4de4334a993c2 Mon Sep 17 00:00:00 2001
From: Gehad elrobey <gehadelro...@gmail.com>
Date: Mon, 4 Aug 2014 14:02:16 +0300
Subject: [PATCH 01/10] HTML: Make export statistics optional.

Make exporting statistics to the HTML page optional.

Signed-off-by: Gehad elrobey <gehadelro...@gmail.com>
Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 qt-ui/divelogexportdialog.cpp | 41 ++++++++++++++++++++++-------------------
 qt-ui/divelogexportdialog.ui  |  4 ++--
 theme/dive_export.html        |  3 +++
 3 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 03bdaf9..0b6ab73 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -93,6 +93,7 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
 
 	exportHTMLsettings(json_settings);
 	exportHTMLstatistics(stat_file);
+
 	export_HTML(json_dive_data.toUtf8().data(), photos_directory.toUtf8().data(), ui->exportSelectedDives->isChecked(), ui->exportListOnly->isChecked());
 
 	QString searchPath = getSubsurfaceDataPath("theme");
@@ -140,25 +141,27 @@ void DiveLogExportDialog::exportHTMLstatistics(const QString &filename)
 	QTextStream out(&file);
 	int i = 0;
 	out << "divestat=[";
-	while (stats_yearly != NULL && stats_yearly[i].period) {
-		out << "{";
-		out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
-		out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
-		out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
-		out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
-		out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
-		out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
-		out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
-		out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
-		out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
-		out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
-		out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
-		out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
-		out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
-		out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
-		out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
-		out << "},";
-		i++;
+	if (ui->exportStatistics->isChecked()) {
+		while (stats_yearly != NULL && stats_yearly[i].period) {
+			out << "{";
+			out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
+			out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
+			out << "\"TOTAL_TIME\":\"" << get_time_string(stats_yearly[i].total_time.seconds, 0) << "\",";
+			out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
+			out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
+			out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
+			out << "\"AVG_DEPTH\":\"" << get_depth_string(stats_yearly[i].avg_depth) << "\",";
+			out << "\"MIN_DEPTH\":\"" << get_depth_string(stats_yearly[i].min_depth) << "\",";
+			out << "\"MAX_DEPTH\":\"" << get_depth_string(stats_yearly[i].max_depth) << "\",";
+			out << "\"AVG_SAC\":\"" << get_volume_string(stats_yearly[i].avg_sac) << "\",";
+			out << "\"MIN_SAC\":\"" << get_volume_string(stats_yearly[i].min_sac) << "\",";
+			out << "\"MAX_SAC\":\"" << get_volume_string(stats_yearly[i].max_sac) << "\",";
+			out << "\"AVG_TEMP\":\"" << QString::number(stats_yearly[i].combined_temp / stats_yearly[i].combined_count, 'f', 1) << "\",";
+			out << "\"MIN_TEMP\":\"" << get_temp_units(stats_yearly[i].min_temp, NULL) << "\",";
+			out << "\"MAX_TEMP\":\"" << get_temp_units(stats_yearly[i].max_temp, NULL) << "\",";
+			out << "},";
+			i++;
+		}
 	}
 	out << "]";
 	file.close();
diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui
index aeed088..0e8ef4a 100644
--- a/qt-ui/divelogexportdialog.ui
+++ b/qt-ui/divelogexportdialog.ui
@@ -216,9 +216,9 @@
            </widget>
           </item>
           <item row="1" column="0">
-           <widget class="QCheckBox" name="checkBox_2">
+           <widget class="QCheckBox" name="exportStatistics">
             <property name="text">
-             <string>Minimum Javascript</string>
+             <string>Export Yearly Statistics</string>
             </property>
            </widget>
           </item>
diff --git a/theme/dive_export.html b/theme/dive_export.html
index 91b0ef7..065a8a4 100644
--- a/theme/dive_export.html
+++ b/theme/dive_export.html
@@ -121,6 +121,9 @@ window.onload=function(){
 	showAllDives();
 	document.getElementById("divePanel").style.display='none';
 	document.getElementById("diveStat").style.display='none';
+	if (divestat.length <= 0)
+		document.getElementById("stats_button").style.display='none';
+
 	document.body.style.visibility='visible';
 
 	document.onkeydown = switchDives;
-- 
1.9.1

From a828a6c659e3370f05444502ed22fa546b53a3a6 Mon Sep 17 00:00:00 2001
From: Miika Turkia <miika.tur...@gmail.com>
Date: Sun, 10 Aug 2014 18:29:25 +0300
Subject: [PATCH 11/11] White space fix

Signed-off-by: Miika Turkia <miika.tur...@gmail.com>
---
 save-html.c | 3 ++-
 save-html.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/save-html.c b/save-html.c
index 02d131e..695221e 100644
--- a/save-html.c
+++ b/save-html.c
@@ -325,7 +325,8 @@ void export_HTML(const char *file_name, const char *photos_dir, const bool selec
 	fclose(f);
 }
 
-void export_translation(const char *file_name){
+void export_translation(const char *file_name)
+{
 	FILE *f;
 
 	struct membuffer buf = { 0 };
diff --git a/save-html.h b/save-html.h
index bcf69d5..6d31e4f 100644
--- a/save-html.h
+++ b/save-html.h
@@ -19,7 +19,7 @@ void export_HTML(const char *file_name, const char *photos_dir, const bool selec
 void export_translation(const char *file_name);
 
 extern void copy_image_and_overwrite(const char *cfileName, const char *cnewName);
-extern const char* get_file_name(const char *fileName);
+extern const char *get_file_name(const char *fileName);
 #ifdef __cplusplus
 }
 #endif
-- 
1.9.1

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to