Here is the latest set of Gehad's patches with my singed-off included. I have also some comments here.
- You delete the theme.css but not the other template files when copying? If any other of the template files has changed in Subsurface, they are not updated. - The detailed view does not work for manually added dives. There is also one whitespace issue, but it seems to be someone else's doing. (It seems that the whitespace checker scrips works reasonably well on JS files. And it really should be run against those as well, as there is quite a bit of inconsistent spacing in there. When running it we'll just need to be extra careful to make sure it is only "cosmetic" changes that occur.) miika On Sat, Jun 14, 2014 at 7:35 PM, Gehad Elrobey <[email protected]> wrote: > Here is a list of updated patches. > > I am also having good progress with Highcharts, I will send it as soon as > I finish so you can compare Highcharts work that requires JQuery with the > Native plots in this list of patches. > > > On Fri, Jun 13, 2014 at 7:06 PM, Dirk Hohndel <[email protected]> wrote: > >> On Fri, Jun 13, 2014 at 06:54:59PM +0300, Miika Turkia wrote: >> > if the license allows us to bundle the stuff on our build and the needed >> > stuff is reasonably sized, then that might be fine by me. Dirk, your >> > opinion? >> >> It has to be under a GPL compatible license. And can't be more than a few >> hundred kB. Then yes. >> >> > I am not keen on adding too much of external stuff, but wasting time on >> > something that others have already done (better?) does not make sense >> > either. >> >> Correct. I've done some JS development for another open source project I >> was involved in for a while. You really want to at least have JQuery to >> work with... >> >> jquery 2.1.1 min is about 84k >> >> /D >> >> > > On 13 Jun 2014, at 17:15, Gehad Elrobey <[email protected]> >> wrote: >> > > >> > > So I had a look about Highcharts which Poltsi has suggested, >> > > which looks much better and neater than the native sketched curves. >> > > >> > > Anyway this will require us to add JQuery files plus the library >> files to the exports. >> > > I am not sure if this will meet the requirements, I think it was >> required not to use any 3rd party framework. >> > > >> > > what do you think about that Miika? >> > >
From d4fa6a2e5e941a1cf185b9fe1e7b82403d8746cd Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Sun, 15 Jun 2014 07:46:26 +0300 Subject: [PATCH 10/10] Fix whitespace to satisfy our checker script Signed-off-by: Miika Turkia <[email protected]> --- 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 b4bac0f..84f74f2 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -16,7 +16,7 @@ #include "helpers.h" DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::DiveLogExportDialog) + ui(new Ui::DiveLogExportDialog) { ui->setupUi(this); showExplanation(); -- 1.9.1
From 485c314000aba09929d7aee31bf67044b146525d Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Sat, 14 Jun 2014 19:20:37 +0300 Subject: [PATCH 09/10] HTML: move between dives in detailed view. Move between next/prev dives in detailed view, and be able to go back to the list. Also fix the initial state of the sorting by number. (its already exported in ascending order) Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- theme/dive_export.html | 7 +++++++ theme/list_lib.js | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/theme/dive_export.html b/theme/dive_export.html index 2374c07..e1b3189 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -156,6 +156,13 @@ function changeAdvSearch(e){ </center> </div> <div id="divePanel"> + <center> + <div id="but"> + <button onClick="prevDetailedDive()"><-</button> + <button onClick="unshowDiveDetails()">Back to List</button> + <button onClick="nextDetailedDive()">-></button> + </div> + </center> <div id="diveprofile"> <h2>Dive profile</h2> <canvas id="profileCanvas"></canvas> diff --git a/theme/list_lib.js b/theme/list_lib.js index ff51e29..b19c2ea 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -227,7 +227,7 @@ function putRating(rating){ this variables keep the state of each col. sorted asc or des */ -var number = true; +var number = false; var time = true; var date = true; var air = true; @@ -813,3 +813,15 @@ function unshowDiveDetails(dive){ document.getElementById("diveListPanel").style.display='block'; document.getElementById("divePanel").style.display='none'; } + +function nextDetailedDive(){ + if(dive_id<items.length){ + showDiveDetails(++dive_id); + } +} + +function prevDetailedDive(){ + if(dive_id>0){ + showDiveDetails(--dive_id); + } +} -- 1.9.1
From 3b5c08b69935397744ac22da64aadbb946758a9c Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Fri, 13 Jun 2014 14:16:58 +0300 Subject: [PATCH 08/10] HTML: remove theme file if already exist in the export directory as QFile:copy doesn't overwrite files by default, we must check before copying if file exist and remove it. We must be able to overwrite files here, user is already notified and choosed to replace them. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- qt-ui/divelogexportdialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index 3e07e70..b4bac0f 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -90,6 +90,12 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename) QFile::copy(searchPath + "dive_export.html", filename); QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js"); QFile::copy(searchPath + "poster.png", exportFiles + "poster.png"); + + // Remove theme file if already exist in the export dir + QFile theme(exportFiles + "theme.css"); + if (theme.exists()) + theme.remove(); + QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"), exportFiles + "theme.css"); } -- 1.9.1
From cee5797f26069b0f60f2fb27382dd9c0a827c9ae Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Tue, 10 Jun 2014 18:55:07 +0300 Subject: [PATCH 07/10] HTML: fix the exporting dialog export HTML into the file name choosen and export additional files into a subdirectoy beside the html file, called htmlfilename_files This is to follow the convension and doesn't create additional directories to wrap the exports. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- qt-ui/divelogexportdialog.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp index 21768c7..3e07e70 100644 --- a/qt-ui/divelogexportdialog.cpp +++ b/qt-ui/divelogexportdialog.cpp @@ -69,13 +69,14 @@ void DiveLogExportDialog::showExplanation() void DiveLogExportDialog::exportHtmlInit(const QString &filename) { - QDir dir(filename); - if (!dir.exists()) { - dir.mkpath(filename); - } + QFile file(filename); + QFileInfo info(file); + QDir mainDir = info.absoluteDir(); + mainDir.mkdir(file.fileName() + "_files"); + QString exportFiles = file.fileName() + "_files/"; - QString json_dive_data = filename + QDir::separator() + "file.json"; - QString json_settings = filename + QDir::separator() + "settings.json"; + QString json_dive_data = exportFiles + QDir::separator() + "file.json"; + QString json_settings = exportFiles + QDir::separator() + "settings.json"; exportHTMLsettings(json_settings); export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked()); @@ -85,14 +86,12 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename) return; searchPath += QDir::separator(); - QString dirname = filename + QDir::separator(); - - QFile::copy(searchPath + "dive_export.html", dirname + "dive_export.html"); - QFile::copy(searchPath + "list_lib.js", dirname + "list_lib.js"); - QFile::copy(searchPath + "poster.png", dirname + "poster.png"); - QFile::copy(searchPath + "index.html", dirname + "index.html"); - QFile::copy(searchPath + ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css", - filename + "theme.css"); + + QFile::copy(searchPath + "dive_export.html", filename); + QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js"); + QFile::copy(searchPath + "poster.png", exportFiles + "poster.png"); + QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"), + exportFiles + "theme.css"); } void DiveLogExportDialog::exportHTMLsettings(const QString &filename) @@ -160,7 +159,8 @@ void DiveLogExportDialog::on_buttonBox_accepted() } break; case 1: - filename = QFileDialog::getExistingDirectory(this, tr("Export Subsurface"), lastDir); + filename = QFileDialog::getSaveFileName(this, tr("Export HTML files as"), lastDir, + tr("HTML files (*.html)")); if (!filename.isNull() && !filename.isEmpty()) exportHtmlInit(filename); break; -- 1.9.1
From b6b8d92209c4665f8a3c27eb18e1de8efe50a682 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Tue, 10 Jun 2014 18:40:56 +0300 Subject: [PATCH 06/10] HTML: Dynamically loading an external JavaScript or CSS file This enable the HTML template from linking JS and CSS files dynamically when starting. This helps to recognize the folder name where js and css where exported dynamically. The HTML template will succesfully find the attached files as long as they exist in a directory named as the HTML file. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- theme/dive_export.html | 27 +++++++++++++++++++++++---- theme/light.css | 1 + theme/sand.css | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/theme/dive_export.html b/theme/dive_export.html index 4d7efa2..2374c07 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -2,13 +2,31 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>dive log export</title> -<link rel="stylesheet" type="text/css" href="theme.css"> -<script src="file.json"></script> -<script src="settings.json"></script> -<script src="list_lib.js" type="text/javascript"></script> <script> ////////////////////////////////// //advance settings window// +load_scripts(); + +function load_scripts(){ + var fileref=document.createElement("link"); + fileref.setAttribute("rel", "stylesheet"); + fileref.setAttribute("type", "text/css"); + fileref.setAttribute("href", location.pathname+"_files/theme.css"); + document.getElementsByTagName("head")[0].appendChild(fileref); + + fileref=document.createElement('script'); + fileref.setAttribute("src", location.pathname+"_files/file.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); + + fileref=document.createElement('script'); + fileref.setAttribute("type","text/javascript"); + fileref.setAttribute("src", location.pathname+"_files/list_lib.js"); + document.getElementsByTagName("head")[0].appendChild(fileref); +} var advanced_shown=false; function showdiv(){ @@ -80,6 +98,7 @@ window.onload=function(){ sizeofpage=10; showAllDives(); document.getElementById("divePanel").style.display='none'; + document.body.style.visibility='visible'; } function changeAdvSearch(e){ diff --git a/theme/light.css b/theme/light.css index 77540ba..74aaa53 100644 --- a/theme/light.css +++ b/theme/light.css @@ -3,6 +3,7 @@ body{ background-color:#dfdfdf; font-size:12px; font-family: 'Lobster', helvetica, arial; + visibility: hidden; } h1 { diff --git a/theme/sand.css b/theme/sand.css index 61a918a..a5bbe45 100644 --- a/theme/sand.css +++ b/theme/sand.css @@ -3,6 +3,7 @@ body{ background-color:#F7F4DD; font-size:12px; font-family: 'Lobster', helvetica, arial; + visibility: hidden; } h1 { -- 1.9.1
From 4bc598f1ca8a1f879c6ebf99d638d3ea296dcecc Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Tue, 10 Jun 2014 04:45:31 +0300 Subject: [PATCH 05/10] HTML: Show dive profile embedded in HTML5 canvas Plot samples from dive computer (depth,time) with HTML5 canvas. Add very small API for curve drawing and coloring. Add the dive equipment to the detailed dive view. in the dive list when a dive is expanded you can show the dive profile,equipments and dive information by clicking on 'show more details'. Fixing the two themes to work well with the new div added that carry detailed dive information. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- theme/dive_export.html | 21 ++++- theme/light.css | 40 +++++++++ theme/list_lib.js | 240 ++++++++++++++++++++++++++++++++++++++++++++++++- theme/sand.css | 40 +++++++++ 4 files changed, 339 insertions(+), 2 deletions(-) diff --git a/theme/dive_export.html b/theme/dive_export.html index edee464..4d7efa2 100644 --- a/theme/dive_export.html +++ b/theme/dive_export.html @@ -79,6 +79,7 @@ window.onload=function(){ sizeofpage=10; showAllDives(); + document.getElementById("divePanel").style.display='none'; } function changeAdvSearch(e){ @@ -95,7 +96,7 @@ function changeAdvSearch(e){ <h1>Subsurface</h1> </div> </center> - <div id="divePanel"> + <div id="diveListPanel"> <div id="controlbox"> <input id="search_input" oninput="SearchModules(this.value)" placeholder="search"/><a id="adv_srch_sp" onClick="showdiv()" >Advanced Search</a> <div id="advanced_search"> @@ -135,5 +136,23 @@ function changeAdvSearch(e){ </div> </center> </div> + <div id="divePanel"> + <div id="diveprofile"> + <h2>Dive profile</h2> + <canvas id="profileCanvas"></canvas> + </div> + <div id="diveinfo"> + <h2>Dive Information</h2> + </div> + <div id="dive_equipments"> + <h2>Dive equipments</h2> + </div> + <div id="bookmarks"> + <h2>Bookmarks</h2> + </div> + <div id="divestats"> + <h2>Dive stats</h2> + </div> + </div> </body> </html> diff --git a/theme/light.css b/theme/light.css index 589bbdd..77540ba 100644 --- a/theme/light.css +++ b/theme/light.css @@ -192,6 +192,46 @@ ul:hover{ margin-bottom:10px; } +#profileCanvas{ + border:1px solid #d3d3d3; + width:98%; + margin:1%; + height:300px; +} + +#diveListPanel{ + padding:5px; + width:90%; + margin:0% 5% 0% 5%; + margin-bottom:50px; + background-color: rgba(88,121,139,0.3); + box-shadow: 10px 10px 5px #888888; +} + +.Cyl{ + padding-right:25px; +} + +#diveinfo{ + border-style:solid; +} + +#diveprofile{ + border-style:solid; +} + +#dive_equipments{ + border-style:solid; +} + +#divestats{ + border-style:solid; +} + +#bookmarks{ + border-style:solid; +} + @media (max-width: 768px) { #divePanel{ padding:4px; diff --git a/theme/list_lib.js b/theme/list_lib.js index d7a01c1..ff51e29 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -192,7 +192,8 @@ function getExpanded (dive) { '</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>'; + '</td></tr></table><div style="margin:10px;"><p class="words">Notes: </p>' + dive.notes +'</div>'+ + '<center><a onclick="showDiveDetails('+dive.number+')">show more details</a></center>'; }; function putTags(tags){ @@ -575,3 +576,240 @@ function getItems(){ } } } + +////////////////////////canvas/////////////////// + +/* +Canvas Colors Constants +*/ +var CAMARONE1 = rgb(0,0.4,0); +var LIMENADE1 = rgb(0.4,0.8,0); +var RIOGRANDE1 = rgb (0.8,0.8,0); +var PIRATEGOLD1= rgb(0.8,0.5,0); +var RED1 = rgb(1,0,0); + +/* +Some Global variables that hold the current shown dive data. +*/ +var dive_id;//current shown ID +var points;//reference to the samples array of the shown dive. +var MAX_HEIGHT;//Maximum depth, then its the maximum height for canvas +var MAX_WIDTH;//dive duration, then its the maximum width for canvas + +/** +*Return RGB css color string. +*/ +function rgb(r, g, b){ + r = Math.floor(r*255); + g = Math.floor(g*255); + b = Math.floor(b*255); + return ["rgb(",r,",",g,",",b,")"].join(""); +} + +/** +*This function returns the value scaled to the size of canvas +*new scale = (old scale * height of canvas) / max height in dive +*to ensure that the dive profile is filling the whole area available +*/ +function scaleHeight(vari){ + var height = document.getElementById("profileCanvas").height; + max = MAX_HEIGHT; + return (vari*height)/max; +} + +/** +*This function returns the value scaled to the size of canvas +*new scale = (old scale * width of canvas) / max width in dive +*to ensure that the dive profile is filling the whole area available +*/ +function scaleWidth(vari){ + var width = document.getElementById("profileCanvas").width; + max = MAX_WIDTH; + return (vari*width)/max; +} + +/** +*Show Axis information(Numbers on scale) +*put a Number every 300 second scaled to canvas width. +*/ +function canvas_showAxisInfo(){ + var c=document.getElementById("profileCanvas"); + var ctx=c.getContext("2d"); + ctx.font="27px Georgia";/*This is better be a variable scale*/ + for (var i=0;i<MAX_WIDTH/scaleWidth(5);i++) + ctx.fillText(""+i*5+"",scaleWidth(i*5*60),scaleHeight(MAX_HEIGHT-150)); +} + +/** +*Draw the grid +*with spacing = 5 * 60 = 300 +*draw line every 5 minutes +*/ +function canvas_showGrid() { + var cnv = document.getElementById("profileCanvas"); + var cnvWidth = cnv.width; + var cnvHeight = cnv.height; + var lineOptions= { + separation: scaleWidth(300), + color: '#AAAAAA' + }; + var ctx = cnv.getContext('2d'); + + ctx.strokeStyle = lineOptions.color; + ctx.strokeWidth = 0.5; + ctx.beginPath(); + + var iCount = null; + var i = null; + var x = null; + var y = null; + + //draw horizontal lines + iCount = Math.floor(cnvWidth / lineOptions.separation); + for (i = 1; i <= iCount; i++) { + x = (i * lineOptions.separation); + ctx.moveTo(x, 0); + ctx.lineTo(x, cnvHeight); + ctx.stroke(); + } + + //draw vertical lines + iCount = Math.floor(cnvHeight / lineOptions.separation); + for (i = 1; i <= iCount; i++) { + y = (i * lineOptions.separation); + ctx.moveTo(0, y); + ctx.lineTo(cnvWidth, y); + ctx.stroke(); + } + + ctx.closePath(); +} + +/** +*The Main function used for drawing canvas lines +*it automatically calcualte the slope of the line +*and choose its color. +*This is the function that should be used internally. +*/ +function canvas_drawline(ctx,begin,end){ + drawline(ctx,begin,end,getcolor(begin,end)); +} + +/** +*Draw a line in the canvas with the given +*starting point, ending point, and color. +*/ +function drawline(ctx,begin,end,col){ + ctx.strokeStyle = col; + ctx.beginPath(); + ctx.moveTo(scaleWidth(begin[0]),scaleHeight(begin[1])); + ctx.lineTo(scaleWidth(end[0]),scaleHeight(end[1])); + ctx.stroke(); +} + +/** +*Choose Color for different speeds. +*this need to be fixed to go with subsurface conversion. +*/ +function getcolor(begin,end){ + var slope = (end[1]-begin[1])/(end[0]-begin[0]); + if (Math.abs(slope) > 300 ) return RED1; + if (Math.abs(slope) > 180 ) return PIRATEGOLD1; + if (Math.abs(slope) > 110 ) return RIOGRANDE1; + if (Math.abs(slope) > 70 ) return LIMENADE1; + return CAMARONE1; +} + +/** +*Return the HTML string for a dive cylinder entry in the table. +*/ +function get_cylinder_HTML(cylinder){ + return '<tr><td class="Cyl">'+cylinder.Type+'</td><td class="Cyl">'+cylinder.Size+'</td><td class="Cyl">'+cylinder.WPressure+'</td>'+ + '<td class="Cyl">'+cylinder.SPressure+'</td><td class="Cyl">'+cylinder.EPressure+'</td><td class="Cyl">'+cylinder.O2+'</td></tr>'; +} + +/** +*Return HTML table of cylinders of a dive. +*/ +function get_cylinders_HTML(dive){ + var result=""; + result +='<h2>Dive equipments</h2><table><tr><td class="Cyl">Type</td><td class="Cyl">Size</td><td class="Cyl">Work Pressure</td><td class="Cyl">Start Pressure</td><td class="Cyl">End Pressure</td><td class="Cyl">O2</td></tr>'; + for (var i in dive.Cylinders){ + result+=get_cylinder_HTML(dive.Cylinders[i]); + } + result+='</table>'; + return result; +} + +/** +*Return HTML main data of a dive +*/ +function get_dive_HTML(dive) { + return '<h2>Dive Information</h2><table><tr><td class="words">Date: </td><td>'+dive.date+ + '</td><td class="words">     Time: </td><td>'+dive.time + + '</td><td class="words">     Location: </td><td>'+'<a onclick=\"Search_list_Modules(\''+dive.location+'\')\">'+ + dive.location +'</a>'+ + '</td></tr></table><table><tr><td class="words">Rating:</td><td>'+putRating(dive.rating)+ + '</td><td class="words">   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">    Water temp: </td><td>'+dive.temperature.water + + '</td></tr></table><table><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>'; +}; + +/** +*Main canvas draw function +*this calls the axis and grid initialization functions. +*/ +function canvas_draw(){ + var c=document.getElementById("profileCanvas"); + c.width = window.innerWidth; + c.height = window.innerHeight; + canvas_showGrid(); + canvas_showAxisInfo(); + var ctx=c.getContext("2d"); + ctx.lineWidth=4 //variable width + //draw starting line, draw all samples then draw the final line. + canvas_drawline(ctx,[0,0],points[0]); + for(var i=1;i<points.length;i++){ + canvas_drawline(ctx,points[i-1],points[i]); + } + canvas_drawline(ctx,points[points.length-1],[MAX_WIDTH,0]); +} + +/** +*Initialize the detailed view, +*set the global variables +*Fill the dive data +*Hide the list and show the canvas view. +*this is called to view the dive details. +*/ +function showDiveDetails(dive){ + //set global variables + dive_id = dive; + points = items[dive_id].samples; + MAX_HEIGHT = items[dive_id].maxdepth*1.1; + MAX_WIDTH = items[dive_id].duration; + + //draw the canvas and initialize the view + canvas_draw(); + document.getElementById("diveinfo").innerHTML=get_dive_HTML(items[dive_id]); + document.getElementById("dive_equipments").innerHTML=get_cylinders_HTML(items[dive_id]); + + //hide the list of dives and show the canvas. + document.getElementById("diveListPanel").style.display='none'; + document.getElementById("divePanel").style.display='block'; +} + +/** +*Show the list view and hide the detailed list view. +*this function have to clear any data saved by showDiveDetails +*/ +function unshowDiveDetails(dive){ + document.getElementById("diveListPanel").style.display='block'; + document.getElementById("divePanel").style.display='none'; +} diff --git a/theme/sand.css b/theme/sand.css index 0bfcf66..61a918a 100644 --- a/theme/sand.css +++ b/theme/sand.css @@ -194,6 +194,46 @@ ul:hover{ margin-bottom:10px; } +#profileCanvas{ + border:1px solid #d3d3d3; + width:98%; + margin:1%; + height:300px; +} + +#diveListPanel{ + padding:5px; + width:90%; + margin:0% 5% 0% 5%; + margin-bottom:50px; + background-color:rgba(253, 195, 141, 0.43); + box-shadow: 7px 7px 5px rgba(215, 107, 27, 0.43); +} + +.Cyl{ + padding-right:25px; +} + +#diveinfo{ + border-style:solid; +} + +#diveprofile{ + border-style:solid; +} + +#dive_equipments{ + border-style:solid; +} + +#divestats{ + border-style:solid; +} + +#bookmarks{ + border-style:solid; +} + @media (max-width: 768px) { #divePanel{ padding:4px; -- 1.9.1
From 47de1519f680d041a0404fe68afda29e1872b10c Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Tue, 10 Jun 2014 00:24:18 +0300 Subject: [PATCH 04/10] HTML: define the visited array type to boolean The boolean array must be defined explicitly, to prevent type casting. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- theme/list_lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme/list_lib.js b/theme/list_lib.js index bf1ef59..d7a01c1 100644 --- a/theme/list_lib.js +++ b/theme/list_lib.js @@ -341,7 +341,7 @@ function sort_it(sortOn,function_){ var res = new Array(); var visited = new Array(itemsToShow.length); for(var j=0;j<itemsToShow.length;j++){ - visited[j]=0; + visited[j]=false; } for(var i=0;i< itemsToShow.length ;i++){ for(var j=0;j<itemsToShow.length;j++) -- 1.9.1
From 8375b21fd5ee270a77d657182fb0d748b2fc15c8 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Sun, 8 Jun 2014 16:09:24 +0300 Subject: [PATCH 03/10] HTML: Write cylinder data to the JSON files. Iterate the cylinders in each dive and write cylinders data to the exported JSON files. Moving the write attribute function to the top of the file. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- save-html.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/save-html.c b/save-html.c index 61c453d..e77f79a 100644 --- a/save-html.c +++ b/save-html.c @@ -2,6 +2,48 @@ #include "gettext.h" #include "stdio.h" +void write_attribute(struct membuffer *b, const char *att_name, const char *value) +{ + if (!value) + value = "--"; + put_format(b, "\"%s\":\"", att_name); + put_HTML_quoted(b, value); + put_string(b, "\","); +} + +static void put_cylinder_HTML(struct membuffer *b, struct dive *dive) +{ + int i, nr; + + nr = nr_cylinders(dive); + + put_string(b, "\"Cylinders\":["); + + for (i = 0; i < nr; i++) { + cylinder_t *cylinder = dive->cylinder + i; + put_string(b, "{"); + write_attribute(b, "Type", cylinder->type.description); + if (cylinder->type.size.mliter) { + put_milli(b, "\"Size\":\"", cylinder->type.size.mliter, " l\","); + } else { + write_attribute(b, "Size", "--"); + } + put_pressure(b, cylinder->type.workingpressure, "\"WPressure\":\"", " bar\","); + put_pressure(b, cylinder->start, "\"SPressure\":\"", " bar\","); + put_pressure(b, cylinder->end, "\"EPressure\":\"", " bar\","); + + if (cylinder->gasmix.o2.permille) { + put_format(b, "\"O2\":\"%u.%u%%\",", FRACTION(cylinder->gasmix.o2.permille, 10)); + } else { + write_attribute(b, "O2", "--"); + } + put_string(b, "},"); + } + + put_string(b, "],"); +} + + void put_HTML_samples(struct membuffer *b, struct dive *dive) { int i; @@ -90,15 +132,6 @@ void put_HTML_tags(struct membuffer *b, struct dive *dive, const char *pre, cons put_string(b, post); } -void write_attribute(struct membuffer *b, const char *att_name, const char *value) -{ - if (!value) - value = "--"; - put_format(b, "\"%s\":\"", att_name); - put_HTML_quoted(b, value); - put_string(b, "\","); -} - void write_one_dive(struct membuffer *b, struct dive *dive, int *dive_no) { put_string(b, "{"); @@ -118,6 +151,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_cylinder_HTML(b, dive); put_HTML_samples(b, dive); put_string(b, "},\n"); (*dive_no)++; -- 1.9.1
From 4e948399a62401b2d7ca64f48636deb97742074c Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Sun, 8 Jun 2014 07:56:54 +0300 Subject: [PATCH 02/10] 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 <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- save-html.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/save-html.c b/save-html.c index 501bc21..61c453d 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)++; } -- 1.9.1
From 8a165be83bf422bd22ebe4621697e3075e7e4f97 Mon Sep 17 00:00:00 2001 From: Gehad elrobey <[email protected]> Date: Sun, 8 Jun 2014 07:35:20 +0300 Subject: [PATCH 01/10] HTML: Report saving to file errors. Use subsurface report_error function in save-html and worldmap-save instead of the ridiculous print to standard output. Also use subsurface_fopen for the sake of different platforms. Signed-off-by: Gehad elrobey <[email protected]> Signed-off-by: Miika Turkia <[email protected]> --- save-html.c | 4 ++-- worldmap-save.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/save-html.c b/save-html.c index 212cf24..501bc21 100644 --- a/save-html.c +++ b/save-html.c @@ -191,9 +191,9 @@ void export_HTML(const char *file_name, const bool selected_only) struct membuffer buf = { 0 }; export_list(&buf, selected_only); - f = fopen(file_name, "w+"); + f = subsurface_fopen(file_name, "w+"); if (!f) - printf("error"); /*report error*/ + report_error(translate("gettextFromC", "Can't open file %s"), file_name); flush_buffer(&buf, f); /*check for writing errors? */ free_buffer(&buf); diff --git a/worldmap-save.c b/worldmap-save.c index 0dbc479..35a6896 100644 --- a/worldmap-save.c +++ b/worldmap-save.c @@ -90,9 +90,9 @@ void export_worldmap_HTML(const char *file_name, const bool selected_only) struct membuffer buf = { 0 }; export(&buf, selected_only); - f = fopen(file_name, "w+"); + f = subsurface_fopen(file_name, "w+"); if (!f) - printf("error"); /*report error*/ + report_error(translate("gettextFromC", "Can't open file %s"), file_name); flush_buffer(&buf, f); /*check for writing errors? */ free_buffer(&buf); -- 1.9.1
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
