2014-06-24 13:01:51 +00:00
|
|
|
var itemsToShow = new Array(); //list of indexes to all dives to view
|
2014-06-01 04:44:35 +00:00
|
|
|
var items = new Array();
|
2014-06-24 13:01:51 +00:00
|
|
|
var start; //index of first element viewed in itemsToShow
|
|
|
|
var sizeofpage; //size of viewed page
|
|
|
|
var numberofwords = 0; //just for stats
|
|
|
|
var olditemstoshow; //to reference the indexes to all dives if changed
|
2014-06-01 04:44:35 +00:00
|
|
|
//////////////////////////////////
|
|
|
|
// //
|
|
|
|
// View Model //
|
|
|
|
// //
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
*This Method view all items
|
|
|
|
*View N pages each of sizeofpage size items.
|
|
|
|
*starting from zero
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function showAllDives()
|
|
|
|
{
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
2014-06-01 04:44:35 +00:00
|
|
|
itemsToShow.push(i);
|
|
|
|
}
|
|
|
|
olditemstoshow = itemsToShow;
|
2014-06-24 13:01:51 +00:00
|
|
|
start = 0;
|
2014-06-01 04:44:35 +00:00
|
|
|
viewInPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*This function view the 'itemstoshow' in pages.
|
|
|
|
*It start from 'start' variable.
|
|
|
|
*It showes N pages each of sizeofpage size.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function viewInPage()
|
|
|
|
{
|
|
|
|
var end = start + sizeofpage - 1;
|
|
|
|
if (end >= itemsToShow.length)
|
|
|
|
end = itemsToShow.length - 1;
|
|
|
|
updateView(start, end);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*addHTML this Method puts the HTML of items of given indexes
|
|
|
|
*@param {array} indexes array of indexes to put in HTML
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function updateView(start, end)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var divelist = document.getElementById('diveslist');
|
2014-06-24 13:01:51 +00:00
|
|
|
divelist.innerHTML = "";
|
|
|
|
for (var i = start; i <= end; i++) {
|
|
|
|
divelist.innerHTML += '<ul id="' + itemsToShow[i] + '" onclick="toggleExpantion(this)"</ul>';
|
2014-06-01 04:44:35 +00:00
|
|
|
expand(document.getElementById(itemsToShow[i]));
|
|
|
|
items[itemsToShow[i]].expanded = true;
|
|
|
|
};
|
2014-06-24 13:01:51 +00:00
|
|
|
view_pagging(start, end);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*addHTML this Method puts the HTML of items of given indexes
|
|
|
|
*@param {array} indexes array of indexes to put in HTML
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function addHTML(indexes)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var divelist = document.getElementById('diveslist');
|
2014-06-24 13:01:51 +00:00
|
|
|
divelist.innerHTML = "";
|
|
|
|
for (var i = 0; i < indexes.length; i++) {
|
|
|
|
divelist.innerHTML += '<ul id="' + indexes[i] + '" onclick="toggleExpantion(this)"</ul>';
|
2014-06-01 04:44:35 +00:00
|
|
|
expand(document.getElementById(indexes[i]));
|
|
|
|
itemsToShow[indexes[i]].expanded = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*This Method shows items in a range [start,end]
|
|
|
|
*@param {integer} start start from this index
|
|
|
|
*@param {integer} finish at this index.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function view_in_range(start, end)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var ind = new Array();
|
2014-06-24 13:01:51 +00:00
|
|
|
if (end >= itemsToShow.length)
|
|
|
|
end = itemsToShow.length - 1;
|
|
|
|
for (var i = start; i <= end; i++) {
|
2014-06-01 04:44:35 +00:00
|
|
|
ind.push(i);
|
|
|
|
}
|
|
|
|
addHTML(ind);
|
2014-06-24 13:01:51 +00:00
|
|
|
view_pagging(start, end);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*Show the previous page, Will do nothing if no previous pages
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function prev_page()
|
|
|
|
{
|
|
|
|
var end = start + sizeofpage - 1;
|
|
|
|
if (start - sizeofpage > 0) {
|
|
|
|
start -= sizeofpage;
|
|
|
|
} else {
|
|
|
|
start = 0;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
if (end - sizeofpage > 0) {
|
|
|
|
end -= sizeofpage;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
if (end >= itemsToShow.length) {
|
|
|
|
end = itemsToShow.length - 1;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
updateView(start, end)
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*Show the next page, Will do nothing if no next pages
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function next_page()
|
|
|
|
{
|
|
|
|
var end = start + sizeofpage - 1;
|
|
|
|
if (end + sizeofpage < itemsToShow.length) {
|
|
|
|
end += sizeofpage;
|
|
|
|
} else {
|
|
|
|
end = itemsToShow.length - 1;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
if (start + sizeofpage < itemsToShow.length) {
|
|
|
|
start += sizeofpage;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
updateView(start, end)
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function view_pagging(start, end)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var page = document.getElementById("pagging");
|
2014-08-10 09:25:03 +00:00
|
|
|
page.innerHTML = (start + 1) + ' to ' + (end + 1) + ' of ' + (itemsToShow.length) + '' + translate.dives;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*Expand all dives in the view.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function expandAll()
|
|
|
|
{
|
2014-08-10 09:25:03 +00:00
|
|
|
console.time('expnadAll');
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i = start; i < start + sizeofpage; i++) {
|
|
|
|
if (i >= itemsToShow.length)
|
|
|
|
break;
|
2014-06-01 04:44:35 +00:00
|
|
|
unexpand(document.getElementById(itemsToShow[i]));
|
|
|
|
items[itemsToShow[i]].expanded = false;
|
|
|
|
}
|
2014-08-10 09:25:03 +00:00
|
|
|
console.timeEnd('expnadAll');
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*Collapse all dives in the view.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function collapseAll()
|
|
|
|
{
|
|
|
|
for (var i = start; i < start + sizeofpage; i++) {
|
|
|
|
if (i >= itemsToShow.length)
|
|
|
|
break;
|
2014-06-01 04:44:35 +00:00
|
|
|
expand(document.getElementById(itemsToShow[i]));
|
|
|
|
items[itemsToShow[i]].expanded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function setNumberOfDives(e)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var value = e.options[e.selectedIndex].value;
|
2014-06-24 13:01:51 +00:00
|
|
|
sizeofpage = parseInt(value, 10);
|
|
|
|
var end = start + sizeofpage - 1;
|
2014-07-21 05:02:31 +00:00
|
|
|
viewInPage();
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function toggleExpantion(ul)
|
|
|
|
{
|
|
|
|
if (!items[ul.id].expanded) {
|
2014-06-01 04:44:35 +00:00
|
|
|
expand(ul);
|
|
|
|
items[ul.id].expanded = true;
|
2014-06-24 13:01:51 +00:00
|
|
|
} else {
|
2014-06-01 04:44:35 +00:00
|
|
|
unexpand(ul);
|
|
|
|
items[ul.id].expanded = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function expand(ul)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
ul.innerHTML = getlimited(items[ul.id]);
|
2014-06-24 13:01:51 +00:00
|
|
|
ul.style.padding = '2px 10px 2px 10px';
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function unexpand(ul)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
ul.innerHTML = getExpanded(items[ul.id]);
|
2014-06-24 13:01:51 +00:00
|
|
|
ul.style.padding = '3px 10px 3px 10px';
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Dive Model
|
|
|
|
//
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function getlimited(dive)
|
|
|
|
{
|
2014-07-04 11:37:09 +00:00
|
|
|
return '<div style="height:20px"><div class="item">' + (settings.subsurfaceNumbers === '0' ? dive.number + 1 : dive.subsurface_number) + '</div>' +
|
2014-06-24 13:01:51 +00:00
|
|
|
'<div class="item">' + dive.date + '</div>' +
|
|
|
|
'<div class="item">' + dive.time + '</div>' +
|
|
|
|
'<div class="item_large">' + dive.location + '</div>' +
|
|
|
|
'<div class="item">' + dive.temperature.air + '</div>' +
|
|
|
|
'<div class="item">' + dive.temperature.water + '</div></div>';
|
2014-06-01 04:44:35 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function getExpanded(dive)
|
|
|
|
{
|
2014-08-10 09:25:03 +00:00
|
|
|
var res = '<table><tr><td class="words">' + translate.Date + ': </td><td>' + dive.date +
|
|
|
|
'</td><td class="words"> ' + translate.Time + ': </td><td>' + dive.time +
|
2014-08-14 16:28:24 +00:00
|
|
|
'</td><td class="words"> ' + translate.Location + ': </td><td>' + '<a onclick=\"Search_list_Modules(\'' + dive.location + '\', {location:true, divemaster:false, buddy:false, notes:false, tags:false,})\">' + dive.location + '</a>' + getDiveCoor(dive) +
|
2014-08-10 09:25:03 +00:00
|
|
|
'</td></tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
|
|
|
|
'</td><td class="words"> ' + translate.Visibility + ':</td><td>' + putRating(dive.visibility) +
|
2014-06-24 13:01:51 +00:00
|
|
|
'</td></tr></table>' +
|
2014-08-10 09:25:03 +00:00
|
|
|
'<table><tr><td class="words">' + translate.Air_Temp + ': </td><td>' + dive.temperature.air +
|
|
|
|
'</td><td class="words"> ' + 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>';
|
2014-06-24 13:01:51 +00:00
|
|
|
if (settings.listOnly === '0') {
|
2014-08-10 09:25:03 +00:00
|
|
|
res += '<center><a onclick="showDiveDetails(' + dive.number + ')">' + translate.Show_more_details + '</a></center>';
|
2014-06-24 13:01:49 +00:00
|
|
|
}
|
|
|
|
return res;
|
2014-06-01 04:44:35 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function putTags(tags)
|
|
|
|
{
|
|
|
|
var result = "";
|
|
|
|
for (var i in tags) {
|
2014-07-18 14:55:16 +00:00
|
|
|
result += '<a onclick=\"Search_list_Modules(\'' + tags[i] + '\', {location:false, divemaster:false, buddy:false, notes:false, tags:true,})\">' + tags[i] + '</a>';
|
2014-06-24 13:01:51 +00:00
|
|
|
if (i < tags.length - 1)
|
|
|
|
result += ', ';
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*@param {integer} rate out of 5
|
|
|
|
*return HTML string of stars
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function putRating(rating)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var result;
|
2014-06-24 13:01:51 +00:00
|
|
|
result = '<div>';
|
|
|
|
for (var i = 0; i < rating; i++)
|
|
|
|
result += ' ★ ';
|
|
|
|
for (var i = rating; i < 5; i++)
|
|
|
|
result += ' ☆ ';
|
|
|
|
result += '</div>';
|
2014-06-01 04:44:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Sorting
|
|
|
|
//
|
|
|
|
/////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
this variables keep the state of
|
|
|
|
each col. sorted asc or des
|
|
|
|
*/
|
2014-07-23 03:12:25 +00:00
|
|
|
var number = true;
|
2014-06-01 04:44:35 +00:00
|
|
|
var time = true;
|
|
|
|
var date = true;
|
|
|
|
var air = true;
|
|
|
|
var water = true;
|
|
|
|
var locat = true;
|
|
|
|
|
2014-07-23 03:12:25 +00:00
|
|
|
/*
|
|
|
|
This variable keep the state of the col.
|
|
|
|
which is sorted upon it.
|
|
|
|
*/
|
2014-08-07 08:10:59 +00:00
|
|
|
var sort_based_on = '1'; // sorting is based on number by default.
|
2014-07-23 03:12:25 +00:00
|
|
|
|
|
|
|
function change_sort_col(sortOn)
|
|
|
|
{
|
|
|
|
sort_based_on = sortOn;
|
|
|
|
toggle_sort_state(sortOn);
|
|
|
|
list_sort(sortOn);
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function list_sort(sortOn)
|
|
|
|
{
|
|
|
|
switch (sortOn) {
|
|
|
|
case '1': //number
|
|
|
|
if (number) {
|
|
|
|
sort_it(sortOn, cmpNumAsc);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpNumDes);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
2014-06-24 13:01:51 +00:00
|
|
|
case '2': //date
|
|
|
|
if (date) {
|
|
|
|
sort_it(sortOn, cmpDateAsc);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpDateDes);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
2014-06-24 13:01:51 +00:00
|
|
|
case '3': //time
|
|
|
|
if (time) {
|
|
|
|
sort_it(sortOn, cmpTimeDes);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpTimeAsc);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
2014-06-24 13:01:51 +00:00
|
|
|
case '4': //Air temp
|
|
|
|
if (air) {
|
|
|
|
sort_it(sortOn, cmpAtempDes);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpAtempAsc);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
2014-06-24 13:01:51 +00:00
|
|
|
case '5': //Water temp
|
|
|
|
if (water) {
|
|
|
|
sort_it(sortOn, cmpWtempDes);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpWtempAsc);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
2014-07-23 03:12:25 +00:00
|
|
|
case '6': //Location
|
2014-06-24 13:01:51 +00:00
|
|
|
if (locat) {
|
|
|
|
sort_it(sortOn, cmpLocationDes);
|
|
|
|
} else {
|
|
|
|
sort_it(sortOn, cmpLocationAsc);
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-23 03:12:25 +00:00
|
|
|
function toggle_sort_state(sortOn)
|
|
|
|
{
|
|
|
|
switch (sortOn) {
|
|
|
|
case '1': //number
|
|
|
|
number = 1 - number;
|
|
|
|
break;
|
|
|
|
case '2': //date
|
|
|
|
date = 1 - date;
|
|
|
|
break;
|
|
|
|
case '3': //time
|
|
|
|
time = 1 - time;
|
|
|
|
break;
|
|
|
|
case '4': //Air temp
|
|
|
|
air = 1 - air;
|
|
|
|
break;
|
|
|
|
case '5': //Water temp
|
|
|
|
water = 1 - water;
|
|
|
|
break;
|
|
|
|
case '6': //Location
|
|
|
|
locat = 1 - locat;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/*
|
|
|
|
*sorting interface for different coloumns
|
|
|
|
*/
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function cmpLocationAsc(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].location < items[iSmaller].location;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function cmpLocationDes(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].location > items[iSmaller].location;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function cmpNumAsc(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].subsurface_number < items[iSmaller].subsurface_number;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
2014-08-14 02:38:40 +00:00
|
|
|
function cmpNumAsc(j, iSmaller)
|
|
|
|
{
|
|
|
|
return settings.subsurfaceNumbers === '0' ? items[j].number < items[iSmaller].number : items[j].subsurface_number < items[iSmaller].subsurface_number;
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function cmpNumDes(j, iSmaller)
|
|
|
|
{
|
2014-08-14 02:38:40 +00:00
|
|
|
return settings.subsurfaceNumbers === '0' ? items[j].number > items[iSmaller].number : items[j].subsurface_number > items[iSmaller].subsurface_number;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpTimeAsc(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].time < items[iSmaller].time;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpTimeDes(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].time > items[iSmaller].time;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpDateAsc(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].date < items[iSmaller].date;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpDateDes(j, iSmaller)
|
|
|
|
{
|
|
|
|
return items[j].date > items[iSmaller].date;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpAtempAsc(j, iSmaller)
|
|
|
|
{
|
2014-08-11 14:20:34 +00:00
|
|
|
return parseFloat(items[j].temperature.air, 10) < parseFloat(items[iSmaller].temperature.air, 10);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpAtempDes(j, iSmaller)
|
|
|
|
{
|
2014-08-11 14:20:34 +00:00
|
|
|
return parseFloat(items[j].temperature.air, 10) > parseFloat(items[iSmaller].temperature.air, 10);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpWtempAsc(j, iSmaller)
|
|
|
|
{
|
2014-08-11 14:20:34 +00:00
|
|
|
return parseFloat(items[j].temperature.water, 10) < parseFloat(items[iSmaller].temperature.water, 10);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
|
|
|
|
function cmpWtempDes(j, iSmaller)
|
|
|
|
{
|
2014-08-11 14:20:34 +00:00
|
|
|
return parseFloat(items[j].temperature.water, 10) > parseFloat(items[iSmaller].temperature.water, 10);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function sort_it(sortOn, function_)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var res = new Array();
|
|
|
|
var visited = new Array(itemsToShow.length);
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var j = 0; j < itemsToShow.length; j++) {
|
|
|
|
visited[j] = false;
|
|
|
|
}
|
|
|
|
for (var i = 0; i < itemsToShow.length; i++) {
|
|
|
|
for (var j = 0; j < itemsToShow.length; j++)
|
|
|
|
if (visited[j] === false)
|
|
|
|
var iSmaller = j;
|
|
|
|
for (var j = 0; j < itemsToShow.length; j++) {
|
|
|
|
if (function_(itemsToShow[j], itemsToShow[iSmaller])) {
|
|
|
|
if (visited[j] === false) {
|
2014-06-01 04:44:35 +00:00
|
|
|
iSmaller = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
visited[iSmaller] = true;
|
|
|
|
res.push(itemsToShow[iSmaller]);
|
|
|
|
}
|
|
|
|
itemsToShow = res;
|
2014-06-24 13:01:51 +00:00
|
|
|
start = 0;
|
2014-06-01 04:44:35 +00:00
|
|
|
viewInPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Searching
|
|
|
|
//
|
|
|
|
//////////////////////////////////////
|
2014-07-04 11:37:11 +00:00
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function Set()
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
this.keys = new Array();
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
Set.prototype.contains = function(key)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
return (this.keys.indexOf(key) >= 0) ? true : false;
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
Set.prototype.push = function(key)
|
|
|
|
{
|
|
|
|
if (!this.contains(key)) {
|
2014-06-01 04:44:35 +00:00
|
|
|
this.keys.push(key);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
Set.prototype.isEmpty = function()
|
|
|
|
{
|
|
|
|
return this.keys.length <= 0 ? true : false;
|
2014-06-01 04:44:35 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
Set.prototype.forEach = function(do_) {
|
|
|
|
this.keys.forEach (do_);
|
2014-06-01 04:44:35 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
Set.prototype.Union = function(another_set)
|
|
|
|
{
|
2014-06-06 16:48:39 +00:00
|
|
|
if (another_set === null) {
|
2014-06-01 04:44:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i = 0; i < another_set.keys.length; i++) {
|
2014-06-01 04:44:35 +00:00
|
|
|
this.push(another_set.keys[i]);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-07-17 03:15:28 +00:00
|
|
|
Set.prototype.intersect = function(another_set)
|
|
|
|
{
|
|
|
|
if (another_set === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var result = new Array();
|
|
|
|
for (var i = 0; i < another_set.keys.length; i++) {
|
2014-08-14 03:32:47 +00:00
|
|
|
if (this.contains(another_set.keys[i])) {
|
2014-07-17 03:15:28 +00:00
|
|
|
result.push(another_set.keys[i]);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this.keys = result;
|
|
|
|
};
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function Node(value)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
this.children = new Array();
|
2014-06-24 13:01:51 +00:00
|
|
|
this.value = value;
|
|
|
|
this.key = new Set();
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
2014-07-04 11:37:11 +00:00
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
function Search_list_Modules(searchfor, searchOptions)
|
2014-06-24 13:01:51 +00:00
|
|
|
{
|
|
|
|
document.getElementById("search_input").value = searchfor;
|
2014-07-18 14:55:16 +00:00
|
|
|
SearchModules(searchfor, searchOptions);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
function SearchModules(searchfor, searchOptions)
|
2014-06-24 13:01:51 +00:00
|
|
|
{
|
2014-07-18 14:55:16 +00:00
|
|
|
unshowDiveDetails(dive_id);
|
2014-06-24 13:01:51 +00:00
|
|
|
var resultKeys = new Set(); //set
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
if (searchfor.length <= 0) {
|
|
|
|
//exit searching mode
|
|
|
|
document.getElementById("search_input").style.borderColor = "initial";
|
|
|
|
start = 0;
|
|
|
|
itemsToShow = olditemstoshow;
|
2014-07-23 03:12:25 +00:00
|
|
|
list_sort(sort_based_on);
|
2014-06-24 13:01:51 +00:00
|
|
|
viewInPage();
|
2014-06-01 04:44:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-17 03:15:28 +00:00
|
|
|
var keywords = searchfor.split(" ");
|
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions === null) {
|
|
|
|
searchOptions = {};
|
|
|
|
searchOptions.location = searchingModules["location"].enabled;
|
|
|
|
searchOptions.divemaster = searchingModules["divemaster"].enabled;
|
|
|
|
searchOptions.buddy = searchingModules["buddy"].enabled;
|
|
|
|
searchOptions.notes = searchingModules["notes"].enabled;
|
|
|
|
searchOptions.tags = searchingModules["tags"].enabled;
|
|
|
|
}
|
|
|
|
|
2014-07-17 03:15:28 +00:00
|
|
|
for (var i = 0; i < keywords.length; i++) {
|
|
|
|
var keywordResult = new Set();
|
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions.location === true)
|
2014-07-17 03:15:28 +00:00
|
|
|
keywordResult.Union(searchingModules["location"].search(keywords[i]));
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions.divemaster === true)
|
2014-07-17 03:15:28 +00:00
|
|
|
keywordResult.Union(searchingModules["divemaster"].search(keywords[i]));
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions.buddy === true)
|
2014-07-17 03:15:28 +00:00
|
|
|
keywordResult.Union(searchingModules["buddy"].search(keywords[i]));
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions.notes === true)
|
2014-07-17 03:15:28 +00:00
|
|
|
keywordResult.Union(searchingModules["notes"].search(keywords[i]));
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-07-18 14:55:16 +00:00
|
|
|
if (searchOptions.tags === true)
|
2014-07-17 03:15:28 +00:00
|
|
|
keywordResult.Union(searchingModules["tags"].search(keywords[i]));
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-07-17 03:15:28 +00:00
|
|
|
if (resultKeys.isEmpty()) {
|
|
|
|
resultKeys.Union(keywordResult);
|
|
|
|
} else {
|
|
|
|
resultKeys.intersect(keywordResult);
|
|
|
|
}
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
if (resultKeys.isEmpty()) {
|
|
|
|
//didn't find keys
|
|
|
|
document.getElementById("search_input").style.borderColor = "red";
|
|
|
|
itemsToShow = [];
|
|
|
|
viewInPage();
|
2014-06-01 04:44:35 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2014-06-24 13:01:51 +00:00
|
|
|
//found keys
|
|
|
|
document.getElementById("search_input").style.borderColor = "initial";
|
|
|
|
itemsToShow = resultKeys.keys;
|
|
|
|
start = 0;
|
2014-07-23 03:12:25 +00:00
|
|
|
list_sort(sort_based_on);
|
2014-06-24 13:01:51 +00:00
|
|
|
viewInPage();
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
///////////////////////////////////////
|
2014-06-24 13:01:51 +00:00
|
|
|
function SearchModule(enabled)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
this.head = new Node();
|
2014-06-24 13:01:51 +00:00
|
|
|
this.enabled = enabled;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
SearchModule.prototype.Enter_search_string = function(str, diveno)
|
|
|
|
{
|
2014-07-14 17:39:42 +00:00
|
|
|
if (str === "" || !str)
|
2014-06-24 13:01:51 +00:00
|
|
|
return;
|
2014-06-01 04:44:35 +00:00
|
|
|
var res = str.toLowerCase().split(" ");
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i = 0; i < res.length; i++) {
|
|
|
|
insertIn(res[i], diveno, this.head);
|
2014-06-01 04:44:35 +00:00
|
|
|
numberofwords++;
|
2014-06-24 13:01:51 +00:00
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
SearchModule.prototype.Enter_search_tag = function(tags, diveno)
|
|
|
|
{
|
|
|
|
if (!tags)
|
|
|
|
return;
|
|
|
|
for (var i = 0; i < tags.length; i++) {
|
|
|
|
insertIn(tags[i], diveno, this.head);
|
2014-06-01 04:44:35 +00:00
|
|
|
numberofwords++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
SearchModule.prototype.search = function(x)
|
|
|
|
{
|
|
|
|
return searchin(x.toLowerCase(), this.head);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
////////////////////////////////////////
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function insertIn(value, key, node)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
node.key.push(key);
|
2014-06-24 13:01:51 +00:00
|
|
|
if (value.length <= 0)
|
|
|
|
return;
|
2014-06-01 04:44:35 +00:00
|
|
|
|
|
|
|
var this_char = value[0];
|
2014-06-24 13:01:51 +00:00
|
|
|
value = value.substring(1, value.length);
|
2014-06-01 04:44:35 +00:00
|
|
|
|
|
|
|
var i;
|
2014-06-24 13:01:51 +00:00
|
|
|
for (i = 0; i < node.children.length; i++) {
|
|
|
|
if (node.children[i].value == this_char) {
|
|
|
|
return insertIn(value, key, node.children[i]);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
node.children[i] = new Node(this_char);
|
2014-06-24 13:01:51 +00:00
|
|
|
insertIn(value, key, node.children[i]);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function searchin(value, node)
|
|
|
|
{
|
|
|
|
if (value.length <= 0 || node.children.length <= 0)
|
|
|
|
return node.key;
|
2014-06-01 04:44:35 +00:00
|
|
|
|
|
|
|
var this_char = value[0];
|
2014-06-24 13:01:51 +00:00
|
|
|
value = value.substring(1, value.length);
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i = 0; i < node.children.length; i++) {
|
|
|
|
if (node.children[i].value[0] == this_char) {
|
|
|
|
return searchin(value, node.children[i]);
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-08-04 09:36:08 +00:00
|
|
|
//stats
|
|
|
|
|
|
|
|
var statsShows;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*This is the main function called to show/hide trips
|
|
|
|
*/
|
|
|
|
function toggleStats()
|
|
|
|
{
|
|
|
|
var stats_button = document.getElementById('stats_button');
|
|
|
|
if (statsShows) {
|
|
|
|
statsShows = false;
|
2014-08-10 09:25:03 +00:00
|
|
|
document.getElementById('diveListPanel').style.display = 'block';
|
|
|
|
document.getElementById('diveStat').style.display = 'none';
|
2014-08-04 09:36:08 +00:00
|
|
|
} else {
|
2014-08-10 09:25:03 +00:00
|
|
|
document.getElementById('diveListPanel').style.display = 'none';
|
|
|
|
document.getElementById('diveStat').style.display = 'block';
|
2014-08-04 09:36:08 +00:00
|
|
|
statsShows = true;
|
|
|
|
showStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function showStats()
|
|
|
|
{
|
|
|
|
document.getElementById('diveStatsData').innerHTML = '';
|
|
|
|
document.getElementById('diveStatsData').innerHTML += getDiveStats();
|
|
|
|
}
|
|
|
|
|
2014-08-10 09:25:03 +00:00
|
|
|
function getDiveStats()
|
|
|
|
{
|
2014-08-04 09:36:08 +00:00
|
|
|
var res = "";
|
|
|
|
res += '<table><tr id="stats_header">';
|
2014-08-10 09:25:03 +00:00
|
|
|
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>';
|
2014-08-04 09:36:08 +00:00
|
|
|
res += '</tr>';
|
|
|
|
res += getStatsRows();
|
|
|
|
res += '</table>';
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-08-10 09:25:03 +00:00
|
|
|
function getStatsRows()
|
|
|
|
{
|
2014-08-04 09:36:08 +00:00
|
|
|
var res = "";
|
2014-08-10 09:25:03 +00:00
|
|
|
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>';
|
2014-08-04 09:36:08 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-08-10 09:25:03 +00:00
|
|
|
function stats_row_highlight(row)
|
|
|
|
{
|
2014-08-08 14:18:09 +00:00
|
|
|
row.style.backgroundColor = "rgba(125,125,125,0.7)";
|
|
|
|
}
|
|
|
|
|
2014-08-10 09:25:03 +00:00
|
|
|
function stats_row_unhighlight(row)
|
|
|
|
{
|
2014-08-08 14:18:09 +00:00
|
|
|
row.style.backgroundColor = "rgba(125,125,125,0.3)";
|
|
|
|
}
|
|
|
|
|
2014-06-01 04:44:35 +00:00
|
|
|
//trips
|
|
|
|
|
|
|
|
var tripsShown;
|
2014-08-16 14:19:39 +00:00
|
|
|
var HEADER_COLOR;
|
|
|
|
var BACKGROUND_COLOR;
|
2014-06-01 04:44:35 +00:00
|
|
|
|
2014-08-16 14:19:39 +00:00
|
|
|
function getDefaultColor(){
|
|
|
|
var header = document.getElementById('header');
|
|
|
|
var button = document.getElementById('no_dives_selector');
|
|
|
|
HEADER_COLOR = document.defaultView.getComputedStyle(header).getPropertyValue('background-color');
|
|
|
|
BACKGROUND_COLOR = document.defaultView.getComputedStyle(button).getPropertyValue('background-color');
|
|
|
|
}
|
2014-07-04 11:37:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*This is the main function called to show/hide trips
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function toggleTrips()
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var trip_button = document.getElementById('trip_button');
|
2014-06-24 13:01:51 +00:00
|
|
|
if (tripsShown) {
|
|
|
|
tripsShown = false;
|
2014-08-16 14:19:39 +00:00
|
|
|
trip_button.style.backgroundColor = BACKGROUND_COLOR;
|
2014-06-01 04:44:35 +00:00
|
|
|
viewInPage();
|
2014-06-24 13:01:51 +00:00
|
|
|
} else {
|
2014-06-01 04:44:35 +00:00
|
|
|
showtrips();
|
2014-08-16 14:19:39 +00:00
|
|
|
trip_button.style.backgroundColor = HEADER_COLOR;
|
2014-06-24 13:01:51 +00:00
|
|
|
tripsShown = true;
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function showtrips()
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var divelist = document.getElementById('diveslist');
|
2014-06-24 13:01:51 +00:00
|
|
|
divelist.innerHTML = "";
|
|
|
|
for (var i = 0; i < trips.length; i++) {
|
|
|
|
divelist.innerHTML += '<ul id="trip_' + i + '" class="trips" onclick="toggle_trip_expansion(' + i + ')">' +
|
|
|
|
trips[i].name + ' ( ' + trips[i].dives.length + ' dives)' + '</ul>' + '<div id="trip_dive_list_' + i + '"></div>';
|
2014-06-01 04:44:35 +00:00
|
|
|
};
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i = 0; i < trips.length; i++) {
|
2014-06-01 04:44:35 +00:00
|
|
|
unexpand_trip(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function toggle_trip_expansion(trip)
|
|
|
|
{
|
|
|
|
if (trips[trip].expanded === true) {
|
2014-06-01 04:44:35 +00:00
|
|
|
unexpand_trip(trip);
|
2014-06-24 13:01:51 +00:00
|
|
|
} else {
|
2014-06-01 04:44:35 +00:00
|
|
|
expand_trip(trip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function expand_trip(trip)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
trips[trip].expanded = true;
|
2014-06-24 13:01:51 +00:00
|
|
|
var d = document.getElementById("trip_dive_list_" + trip);
|
|
|
|
for (var j in trips[trip].dives) {
|
|
|
|
d.innerHTML += '<ul id="' + trips[trip].dives[j].number + '" onclick="toggleExpantion(this)" onmouseover="highlight(this)"' +
|
|
|
|
' onmouseout="unhighlight(this)">' + getlimited(trips[trip].dives[j]) + '</ul>';
|
|
|
|
}
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function unexpand_trip(trip)
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
trips[trip].expanded = false;
|
2014-06-24 13:01:51 +00:00
|
|
|
var d = document.getElementById("trip_dive_list_" + trip);
|
2014-06-29 11:08:40 +00:00
|
|
|
d.innerHTML = '';
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function getItems()
|
|
|
|
{
|
2014-06-01 04:44:35 +00:00
|
|
|
var count = 0;
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i in trips) {
|
|
|
|
for (var j in trips[i].dives) {
|
|
|
|
items[count++] = trips[i].dives[j];
|
2014-06-01 04:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-10 01:45:31 +00:00
|
|
|
|
|
|
|
////////////////////////canvas///////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
Some Global variables that hold the current shown dive data.
|
|
|
|
*/
|
2014-07-04 11:37:11 +00:00
|
|
|
var dive_id; //current shown ID
|
|
|
|
var points; //reference to the samples array of the shown dive.
|
|
|
|
var ZERO_C_IN_MKELVIN = 273150;
|
|
|
|
var plot1;
|
2014-06-10 01:45:31 +00:00
|
|
|
|
2014-07-08 15:59:56 +00:00
|
|
|
function lastNonZero()
|
|
|
|
{
|
|
|
|
for(var i = items[dive_id].samples.length-1; i >= 0; i--){
|
2014-07-14 17:39:42 +00:00
|
|
|
if(items[dive_id].samples[i][2] !== 0)
|
2014-07-08 15:59:56 +00:00
|
|
|
return items[dive_id].samples[i][2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-27 19:38:50 +00:00
|
|
|
/**
|
|
|
|
*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)
|
|
|
|
{
|
2014-08-15 06:50:05 +00:00
|
|
|
if (!dive.Weights.length)
|
|
|
|
return "";
|
|
|
|
|
2014-07-27 19:38:50 +00:00
|
|
|
var result = "";
|
2014-08-10 09:25:03 +00:00
|
|
|
result += '<table><tr><td class="words">' + translate.Weight + '</td><td class="words">' + translate.Type + '</td></tr>';
|
2014-07-27 19:38:50 +00:00
|
|
|
for (var i in dive.Weights) {
|
|
|
|
result += get_weight_HTML(dive.Weights[i]);
|
|
|
|
}
|
|
|
|
result += '</table>';
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-06-10 01:45:31 +00:00
|
|
|
/**
|
|
|
|
*Return the HTML string for a dive cylinder entry in the table.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function get_cylinder_HTML(cylinder)
|
|
|
|
{
|
2014-07-08 15:59:56 +00:00
|
|
|
var cSPressure = cylinder.SPressure;
|
|
|
|
var cEPressure = cylinder.EPressure;
|
|
|
|
|
|
|
|
if (cSPressure === "--") {
|
|
|
|
cSPressure = mbar_to_bar(items[dive_id].samples[0][2]) + " bar";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cEPressure === "--") {
|
|
|
|
var nonZeroCEPressure = lastNonZero();
|
|
|
|
cEPressure = mbar_to_bar(nonZeroCEPressure) + " bar";
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<tr><td class="Cyl">' + cylinder.Type + '</td><td class="Cyl">' + cylinder.Size + '</td><td class="Cyl">' + cylinder.WPressure + '</td>' + '<td class="Cyl">' + cSPressure + '</td><td class="Cyl">' + cEPressure + '</td><td class="Cyl">' + cylinder.O2 + '</td></tr>';
|
2014-06-10 01:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Return HTML table of cylinders of a dive.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function get_cylinders_HTML(dive)
|
|
|
|
{
|
2014-08-15 06:50:05 +00:00
|
|
|
if (!dive.Cylinders.length)
|
|
|
|
return "";
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
var result = "";
|
2014-08-16 14:23:34 +00:00
|
|
|
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">'+translate.Gas+'</td></tr>';
|
2014-06-24 13:01:51 +00:00
|
|
|
for (var i in dive.Cylinders) {
|
|
|
|
result += get_cylinder_HTML(dive.Cylinders[i]);
|
|
|
|
}
|
|
|
|
result += '</table>';
|
2014-06-10 01:45:31 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-26 14:29:16 +00:00
|
|
|
function get_event_value(event)
|
|
|
|
{
|
|
|
|
if (event.type == 11 || event.type == 25) { // gas change
|
|
|
|
var he = event.value >> 16;
|
|
|
|
var o2 = event.value & 0xffff;
|
|
|
|
return 'He: ' + he + ' - O2: ' + o2;
|
|
|
|
}
|
|
|
|
if (event.type == 23) { // heading
|
2014-07-28 13:55:37 +00:00
|
|
|
return event.value;
|
2014-07-26 14:29:16 +00:00
|
|
|
}
|
|
|
|
return '-';
|
|
|
|
}
|
|
|
|
|
2014-06-24 18:40:06 +00:00
|
|
|
/**
|
|
|
|
Return the HTML string for a bookmark entry in the table.
|
|
|
|
*/
|
|
|
|
function get_bookmark_HTML(event)
|
|
|
|
{
|
2014-07-26 14:29:16 +00:00
|
|
|
return '<tr><td class="Cyl">' + event.name + '</td><td class="Cyl">' + int_to_time(event.time) + '</td><td class="Cyl">' + get_event_value(event) + '</td></tr>';
|
2014-06-24 18:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Return HTML table of bookmarks of a dive.
|
|
|
|
*/
|
|
|
|
function get_bookmarks_HTML(dive)
|
|
|
|
{
|
2014-07-13 21:36:35 +00:00
|
|
|
if (dive.events <= 0)
|
|
|
|
return "";
|
2014-06-24 18:40:06 +00:00
|
|
|
var result = "";
|
2014-08-10 09:25:03 +00:00
|
|
|
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>';
|
2014-06-24 18:40:06 +00:00
|
|
|
for (var i in dive.events) {
|
|
|
|
result += get_bookmark_HTML(dive.events[i]);
|
|
|
|
}
|
|
|
|
result += '</table>';
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-08-14 03:32:47 +00:00
|
|
|
function getDiveCoorString(coordinates){
|
|
|
|
res = "";
|
|
|
|
lat = coordinates.lat;
|
|
|
|
lon = coordinates.lon;
|
|
|
|
res += float_to_deg(lat) + ' , ' + float_to_deg(lon);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDiveCoor(dive)
|
|
|
|
{
|
|
|
|
if (!dive.coordinates)
|
|
|
|
return "";
|
|
|
|
return '<td class="words"> ' + translate.Coordinates + ': </td><td>' + '<a href="http://www.google.com/maps/@' + dive.coordinates.lat + ',' + dive.coordinates.lon + ',13z" target="_blank">' + getDiveCoorString(dive.coordinates) + '</a></td>';
|
|
|
|
}
|
|
|
|
|
2014-06-10 01:45:31 +00:00
|
|
|
/**
|
|
|
|
*Return HTML main data of a dive
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function get_dive_HTML(dive)
|
|
|
|
{
|
2014-08-10 09:25:03 +00:00
|
|
|
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"> ' + translate.Time + ': </td><td>' + dive.time +
|
2014-08-14 16:28:24 +00:00
|
|
|
'</td><td class="words"> ' + 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>' + getDiveCoor(dive) +
|
2014-08-14 03:32:47 +00:00
|
|
|
'</tr></table><table><tr><td class="words">' + translate.Rating + ':</td><td>' + putRating(dive.rating) +
|
2014-08-10 09:25:03 +00:00
|
|
|
'</td><td class="words"> ' + 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"> ' + 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;
|
2014-06-10 01:45:31 +00:00
|
|
|
};
|
|
|
|
|
2014-07-11 01:26:21 +00:00
|
|
|
/**
|
|
|
|
*Return HTML dive status data
|
|
|
|
*/
|
|
|
|
function get_status_HTML(dive)
|
|
|
|
{
|
2014-08-15 08:55:44 +00:00
|
|
|
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"> OTU: </td><td>' + dive.otu +
|
|
|
|
'</td><td class="words"> CNS: </td><td>' + dive.cns + '</td></tr></table>';
|
2014-07-11 01:26:21 +00:00
|
|
|
};
|
|
|
|
|
2014-07-13 21:36:35 +00:00
|
|
|
function get_dive_photos(dive)
|
|
|
|
{
|
|
|
|
if (dive.photos.length <= 0) {
|
|
|
|
document.getElementById("divephotos").style.display = 'none';
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
var slider = "";
|
|
|
|
document.getElementById("divephotos").style.display = 'block';
|
|
|
|
for (var i = 0; i < dive.photos.length; i++) {
|
2014-08-10 09:25:03 +00:00
|
|
|
slider += '<img src="' + location.pathname +
|
|
|
|
'_files/photos/' + dive.photos[i].filename + '" alt="" height="240" width="240">';
|
2014-07-13 21:36:35 +00:00
|
|
|
}
|
|
|
|
return slider;
|
|
|
|
}
|
|
|
|
|
|
|
|
function prev_photo()
|
|
|
|
{
|
|
|
|
var temp = items[dive_id].photos[0];
|
|
|
|
var i;
|
|
|
|
for (i = 0; i < items[dive_id].photos.length - 1; i++) {
|
|
|
|
items[dive_id].photos[i] = items[dive_id].photos[i + 1]
|
|
|
|
}
|
|
|
|
items[dive_id].photos[i] = temp;
|
|
|
|
document.getElementById("slider").innerHTML = get_dive_photos(items[dive_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function next_photo()
|
|
|
|
{
|
|
|
|
var temp = items[dive_id].photos[items[dive_id].photos.length - 1];
|
|
|
|
var i;
|
|
|
|
for (i = items[dive_id].photos.length - 1; i > 0; i--) {
|
|
|
|
items[dive_id].photos[i] = items[dive_id].photos[i - 1]
|
|
|
|
}
|
|
|
|
items[dive_id].photos[0] = temp;
|
|
|
|
document.getElementById("slider").innerHTML = get_dive_photos(items[dive_id]);
|
|
|
|
}
|
|
|
|
|
2014-06-26 13:43:57 +00:00
|
|
|
function mkelvin_to_C(mkelvin)
|
|
|
|
{
|
|
|
|
return (mkelvin - ZERO_C_IN_MKELVIN) / 1000.0;
|
|
|
|
}
|
|
|
|
|
2014-06-27 20:31:03 +00:00
|
|
|
function mbar_to_bar(mbar)
|
|
|
|
{
|
|
|
|
return mbar / 1000;
|
2014-06-26 13:43:57 +00:00
|
|
|
}
|
|
|
|
|
2014-06-27 20:31:03 +00:00
|
|
|
function mm_to_meter(mm)
|
|
|
|
{
|
|
|
|
return mm / (1000);
|
2014-06-26 13:43:57 +00:00
|
|
|
}
|
|
|
|
|
2014-07-27 19:38:50 +00:00
|
|
|
function gram_to_km(gram)
|
|
|
|
{
|
|
|
|
return gram / 1000;
|
|
|
|
}
|
|
|
|
|
2014-07-19 03:26:07 +00:00
|
|
|
function ml_to_litre(ml)
|
|
|
|
{
|
|
|
|
return ml / (1000);
|
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
function format_two_digit(n)
|
|
|
|
{
|
|
|
|
return n > 9 ? "" + n : "0" + n;
|
2014-07-04 11:37:08 +00:00
|
|
|
}
|
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
function int_to_time(n)
|
|
|
|
{
|
|
|
|
return Math.floor((n) / 60) + ":" + format_two_digit((n) % (60)) + " min";
|
2014-07-04 11:37:08 +00:00
|
|
|
}
|
|
|
|
|
2014-08-14 03:32:47 +00:00
|
|
|
function float_to_deg(flt){
|
|
|
|
var deg = 0 | flt;
|
|
|
|
flt = (flt < 0 ? flt =- flt : flt);
|
|
|
|
var min = 0 | flt % 1 * 60;
|
|
|
|
var sec = (0 | flt * 60 % 1 * 6000) / 100;
|
|
|
|
return deg + "° " + min + "' " + sec + "\"";
|
|
|
|
}
|
|
|
|
|
2014-06-10 01:45:31 +00:00
|
|
|
/**
|
|
|
|
*Main canvas draw function
|
|
|
|
*this calls the axis and grid initialization functions.
|
|
|
|
*/
|
2014-06-27 20:31:03 +00:00
|
|
|
function canvas_draw()
|
|
|
|
{
|
|
|
|
document.getElementById("chart1").innerHTML = "";
|
2014-07-07 12:01:36 +00:00
|
|
|
var depthData = new Array();
|
|
|
|
var pressureData = new Array();
|
|
|
|
var eventsData = new Array();
|
|
|
|
var temperatureData = new Array();
|
2014-07-04 11:37:11 +00:00
|
|
|
var last = 0;
|
2014-06-27 20:31:03 +00:00
|
|
|
for (var i = 0; i < items[dive_id].samples.length; i++) {
|
2014-07-07 12:01:36 +00:00
|
|
|
depthData.push([
|
2014-06-27 20:31:03 +00:00
|
|
|
items[dive_id].samples[i][0] / 60,
|
|
|
|
-1 * mm_to_meter(items[dive_id].samples[i][1])
|
|
|
|
]);
|
2014-07-14 17:39:42 +00:00
|
|
|
if (items[dive_id].samples[i][2] !== 0) {
|
2014-07-07 12:01:36 +00:00
|
|
|
pressureData.push([
|
2014-06-27 20:31:03 +00:00
|
|
|
items[dive_id].samples[i][0] / 60,
|
|
|
|
mbar_to_bar(items[dive_id].samples[i][2])
|
|
|
|
]);
|
2014-06-26 13:43:57 +00:00
|
|
|
}
|
2014-07-14 17:39:42 +00:00
|
|
|
if (items[dive_id].samples[i][3] !== 0) {
|
2014-07-07 12:01:36 +00:00
|
|
|
temperatureData.push([
|
2014-07-04 11:37:10 +00:00
|
|
|
items[dive_id].samples[i][0] / 60,
|
2014-07-14 17:52:08 +00:00
|
|
|
mkelvin_to_C(items[dive_id].samples[i][3])
|
2014-07-04 11:37:10 +00:00
|
|
|
]);
|
|
|
|
last = items[dive_id].samples[i][3];
|
2014-07-04 11:37:11 +00:00
|
|
|
} else {
|
2014-07-14 17:39:42 +00:00
|
|
|
if (last !== 0) {
|
2014-07-07 12:01:36 +00:00
|
|
|
temperatureData.push([
|
2014-07-04 11:37:10 +00:00
|
|
|
items[dive_id].samples[i][0] / 60,
|
2014-07-14 17:52:08 +00:00
|
|
|
mkelvin_to_C(last)
|
2014-07-04 11:37:10 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2014-06-26 13:43:57 +00:00
|
|
|
}
|
2014-07-04 11:37:08 +00:00
|
|
|
for (var i = 0; i < items[dive_id].events.length; i++) {
|
2014-07-07 12:01:36 +00:00
|
|
|
eventsData.push([
|
2014-07-04 11:37:08 +00:00
|
|
|
items[dive_id].events[i].time / 60,
|
2014-07-14 17:52:08 +00:00
|
|
|
0
|
2014-07-04 11:37:11 +00:00
|
|
|
]);
|
2014-07-04 11:37:08 +00:00
|
|
|
}
|
2014-08-10 09:25:03 +00:00
|
|
|
if (plot1) {
|
2014-07-26 14:58:27 +00:00
|
|
|
$('chart1').unbind();
|
|
|
|
plot1.destroy();
|
|
|
|
}
|
2014-06-27 20:31:03 +00:00
|
|
|
plot1 = $.jqplot('chart1', [
|
2014-07-07 12:01:36 +00:00
|
|
|
depthData,
|
|
|
|
pressureData,
|
|
|
|
eventsData,
|
2014-07-14 17:52:08 +00:00
|
|
|
temperatureData
|
2014-06-27 20:31:03 +00:00
|
|
|
],
|
|
|
|
{
|
|
|
|
grid : {
|
|
|
|
drawBorder : true,
|
|
|
|
shadow : false,
|
|
|
|
background : 'rgba(0,0,0,0)'
|
|
|
|
},
|
|
|
|
highlighter : {
|
2014-07-04 11:37:08 +00:00
|
|
|
show : true,
|
|
|
|
tooltipContentEditor: function(str, seriesIndex, pointIndex, jqPlot) {
|
|
|
|
if(seriesIndex===2)
|
|
|
|
return items[dive_id].events[pointIndex].name;
|
|
|
|
else
|
2014-08-15 08:13:35 +00:00
|
|
|
return str.replace(",", " : ");
|
2014-07-04 11:37:08 +00:00
|
|
|
}
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
|
|
|
seriesDefaults : {
|
|
|
|
shadowAlpha : 0.1,
|
|
|
|
shadowDepth : 2,
|
|
|
|
fillToZero : true
|
|
|
|
},
|
|
|
|
series :[
|
|
|
|
{
|
|
|
|
color : 'rgba(35,58,58,.6)',
|
|
|
|
negativeColor : 'rgba(35,58,58,.6)',
|
|
|
|
showMarker : true,
|
|
|
|
showLine : true,
|
|
|
|
fill : true,
|
2014-07-14 17:52:08 +00:00
|
|
|
yaxis : 'yaxis'
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
color : 'rgba(44, 190, 160, 0.7)',
|
|
|
|
showMarker : false,
|
|
|
|
rendererOptions : {
|
2014-07-14 17:52:08 +00:00
|
|
|
smooth : true
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
2014-07-14 17:52:08 +00:00
|
|
|
yaxis : 'y2axis'
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
2014-07-04 11:37:08 +00:00
|
|
|
{
|
|
|
|
showLine:false,
|
|
|
|
markerOptions: { size: 10, style:"o" },
|
2014-07-14 17:52:08 +00:00
|
|
|
pointLabels: { show:false }
|
2014-07-04 11:37:08 +00:00
|
|
|
},
|
2014-07-04 11:37:10 +00:00
|
|
|
{
|
|
|
|
showLine:true,
|
|
|
|
showMarker : false,
|
2014-07-14 17:52:08 +00:00
|
|
|
pointLabels: { show:false },
|
|
|
|
yaxis : 'y3axis'
|
|
|
|
}
|
2014-06-27 20:31:03 +00:00
|
|
|
],
|
|
|
|
axes : {
|
|
|
|
xaxis : {
|
|
|
|
pad : 1.0,
|
|
|
|
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
|
|
|
|
tickOptions : {
|
|
|
|
showGridline : false,
|
2014-08-15 08:13:35 +00:00
|
|
|
formatString : '%is'
|
2014-07-07 12:01:36 +00:00
|
|
|
},
|
|
|
|
label:'Time (min)'
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
|
|
|
yaxis : {
|
|
|
|
max : 0,
|
|
|
|
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
|
|
|
|
tickOptions : {
|
2014-07-04 11:37:12 +00:00
|
|
|
formatter: function(format, value) { return -1 * value + "m"; },
|
|
|
|
formatString : '%.2fm'
|
2014-06-27 20:31:03 +00:00
|
|
|
},
|
|
|
|
pad : 2.05
|
|
|
|
},
|
|
|
|
y2axis : {
|
2014-07-18 21:04:14 +00:00
|
|
|
min : 0,
|
2014-06-27 20:31:03 +00:00
|
|
|
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
|
|
|
|
tickOptions : {
|
|
|
|
formatString : '%ibar'
|
|
|
|
},
|
|
|
|
pad : 3.05
|
|
|
|
},
|
2014-07-04 11:37:10 +00:00
|
|
|
y3axis : {
|
|
|
|
padMax : 3.05,
|
2014-07-26 14:59:49 +00:00
|
|
|
max : 50,
|
2014-07-04 11:37:10 +00:00
|
|
|
tickOptions: {
|
|
|
|
showGridline: false,
|
|
|
|
showMark: false,
|
|
|
|
showLabel: false,
|
|
|
|
shadow: false,
|
2014-07-14 17:52:08 +00:00
|
|
|
formatString : '%i C'
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 20:31:03 +00:00
|
|
|
}
|
|
|
|
});
|
2014-06-10 01:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*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.
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function showDiveDetails(dive)
|
|
|
|
{
|
2014-06-10 01:45:31 +00:00
|
|
|
//set global variables
|
|
|
|
dive_id = dive;
|
|
|
|
points = items[dive_id].samples;
|
|
|
|
|
|
|
|
//draw the canvas and initialize the view
|
2014-06-24 13:01:51 +00:00
|
|
|
document.getElementById("diveinfo").innerHTML = get_dive_HTML(items[dive_id]);
|
|
|
|
document.getElementById("dive_equipments").innerHTML = get_cylinders_HTML(items[dive_id]);
|
2014-07-27 19:38:50 +00:00
|
|
|
document.getElementById("dive_equipments").innerHTML += get_weights_HTML(items[dive_id]);
|
2014-06-27 20:31:03 +00:00
|
|
|
document.getElementById("bookmarks").innerHTML = get_bookmarks_HTML(items[dive_id]);
|
2014-07-11 01:26:21 +00:00
|
|
|
document.getElementById("divestats").innerHTML = get_status_HTML(items[dive_id]);
|
2014-07-13 21:36:35 +00:00
|
|
|
document.getElementById("slider").innerHTML = get_dive_photos(items[dive_id]);
|
2014-06-26 13:43:57 +00:00
|
|
|
setDiveTitle(items[dive_id]);
|
2014-06-10 01:45:31 +00:00
|
|
|
|
|
|
|
//hide the list of dives and show the canvas.
|
2014-06-24 13:01:51 +00:00
|
|
|
document.getElementById("diveListPanel").style.display = 'none';
|
|
|
|
document.getElementById("divePanel").style.display = 'block';
|
2014-06-26 13:43:57 +00:00
|
|
|
canvas_draw();
|
2014-08-12 10:30:18 +00:00
|
|
|
scrollToTheTop();
|
2014-06-26 13:43:57 +00:00
|
|
|
}
|
|
|
|
|
2014-06-27 20:31:03 +00:00
|
|
|
function setDiveTitle(dive)
|
|
|
|
{
|
2014-08-10 09:25:03 +00:00
|
|
|
document.getElementById("dive_no").innerHTML = translate.Dive_No + (settings.subsurfaceNumbers === '0' ?
|
2014-07-04 11:37:09 +00:00
|
|
|
dive.number + 1 : dive.subsurface_number);
|
2014-06-27 20:31:03 +00:00
|
|
|
document.getElementById("dive_location").innerHTML = dive.location;
|
2014-06-10 01:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Show the list view and hide the detailed list view.
|
|
|
|
*this function have to clear any data saved by showDiveDetails
|
|
|
|
*/
|
2014-06-24 13:01:51 +00:00
|
|
|
function unshowDiveDetails(dive)
|
|
|
|
{
|
2014-06-24 22:41:23 +00:00
|
|
|
viewInPage();
|
2014-06-26 13:43:57 +00:00
|
|
|
plot1 = null;
|
2014-06-24 13:01:51 +00:00
|
|
|
document.getElementById("diveListPanel").style.display = 'block';
|
|
|
|
document.getElementById("divePanel").style.display = 'none';
|
2014-06-10 01:45:31 +00:00
|
|
|
}
|
2014-06-14 16:20:37 +00:00
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function nextDetailedDive()
|
|
|
|
{
|
2014-07-20 14:48:10 +00:00
|
|
|
if (dive_id < items.length - 1) {
|
2014-06-14 16:20:37 +00:00
|
|
|
showDiveDetails(++dive_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:01:51 +00:00
|
|
|
function prevDetailedDive()
|
|
|
|
{
|
|
|
|
if (dive_id > 0) {
|
2014-06-14 16:20:37 +00:00
|
|
|
showDiveDetails(--dive_id);
|
|
|
|
}
|
|
|
|
}
|
2014-06-30 15:13:53 +00:00
|
|
|
|
2014-07-04 11:37:11 +00:00
|
|
|
/**
|
|
|
|
*This function handles keyboard events
|
|
|
|
*shift to next/prev dives by keyboard arrows.
|
|
|
|
*/
|
2014-06-30 15:13:53 +00:00
|
|
|
function switchDives(e)
|
|
|
|
{
|
2014-07-04 11:37:11 +00:00
|
|
|
if (document.getElementById("divePanel").style.display == 'block') {
|
2014-06-30 15:13:53 +00:00
|
|
|
e = e || window.event;
|
|
|
|
if (e.keyCode == '37') {
|
|
|
|
prevDetailedDive();
|
2014-07-04 11:37:11 +00:00
|
|
|
} else if (e.keyCode == '39') {
|
2014-06-30 15:13:53 +00:00
|
|
|
nextDetailedDive();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-20 20:42:18 +00:00
|
|
|
|
2014-08-12 10:30:18 +00:00
|
|
|
function scrollToTheTop()
|
|
|
|
{
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
}
|
|
|
|
|
2014-08-10 09:25:03 +00:00
|
|
|
window.onresize = function(event)
|
|
|
|
{
|
|
|
|
if (plot1)
|
|
|
|
plot1.replot({
|
2014-08-11 14:25:13 +00:00
|
|
|
resetAxes : false
|
2014-08-10 09:25:03 +00:00
|
|
|
});
|
2014-07-20 20:42:18 +00:00
|
|
|
};
|
2014-08-10 09:25:03 +00:00
|
|
|
|
|
|
|
function translate_page()
|
|
|
|
{
|
|
|
|
document.getElementById("number_header").innerHTML = translate.Number;
|
|
|
|
document.getElementById("date_header").innerHTML = translate.Date;
|
|
|
|
document.getElementById("time_header").innerHTML = translate.Time;
|
2014-08-10 15:10:07 +00:00
|
|
|
document.getElementById("location_header").innerHTML = translate.Location;
|
2014-08-10 09:25:03 +00:00
|
|
|
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;
|
|
|
|
}
|