Commit 181bcf6a authored by Clouard Regis's avatar Clouard Regis
Browse files

Revised track statistics

parent 47d06f97
......@@ -12,7 +12,7 @@ function removeTimeSheet(event, pseudo) {
showTimeSheet();
}
function clearTimeSheet(){
function clearTimeSheet() {
timeSheetData = [];
showTimeSheet();
}
......@@ -36,25 +36,25 @@ function convertTimeToString(time) {
}
}
function deltaDistanceCalculator(idealDistance,realDistance){
let distanceString = idealDistance.toString() + " m";
(idealDistance >+ realDistance) ? distanceString += " (+" : distanceString += " (";
distanceString += Math.round(((idealDistance/realDistance)-1)*100) + "%)";
function deltaDistanceCalculator(idealDistance, realDistance) {
let distanceString = idealDistance.toString();
(idealDistance > +realDistance) ? distanceString += " (+" : distanceString += " (";
distanceString += Math.round(((idealDistance / realDistance) - 1) * 100) + "%)";
return distanceString;
}
function RKCalculator(timeInMilliseconds,distanceInMeter){
function RKCalculator(timeInMilliseconds, distanceInMeter) {
let timeInS = timeInMilliseconds / 1000.0;
let mins = timeInS / 60;
let distInKm = distanceInMeter / 1000.0;
return (Math.round(mins / distInKm * 10)/10).toFixed(1);
return (Math.round(mins / distInKm * 10) / 10).toFixed(1);
}
function speedCalculator(timeInMilliseconds,distanceInMeter){
function speedCalculator(timeInMilliseconds, distanceInMeter) {
let timeInS = timeInMilliseconds / 1000.0;
let hrs = timeInS / 3600;
let distInKm = distanceInMeter / 1000.0;
return (Math.round(distInKm / hrs * 10)/10).toFixed(1);
return (Math.round(distInKm / hrs * 10) / 10).toFixed(1);
}
function renderTimeSheet(distances) {
......@@ -73,7 +73,6 @@ function renderTimeSheet(distances) {
cell.setAttribute("scope", "col");
headRow1.appendChild(cell);
let headRow2 = document.createElement("tr");
cell = document.createElement("th");
cell.setAttribute("scope", "col");
......@@ -83,7 +82,7 @@ function renderTimeSheet(distances) {
cell = document.createElement("th");
cell.setAttribute("scope", "col");
cell.className = "align-middle";
cell.innerHTML = translations.length + " (m)";
cell.innerHTML = translations.length + " (m)";
headRow2.appendChild(cell);
let head = document.createElement("thead");
......@@ -104,11 +103,11 @@ function renderTimeSheet(distances) {
controlCell.innerHTML = translations.start;
} else if (index === timeSheetData[0][1].length - 1) {
controlCell.innerHTML = translations.finish;
lengthCell.innerHTML = distances[i] + " m";
lengthCell.innerHTML = distances[i];
totalDistance += distances[i];
} else {
controlCell.innerHTML = index;
lengthCell.innerHTML = distances[i] + " m";
lengthCell.innerHTML = distances[i];
totalDistance += distances[i];
}
let row = document.createElement("tr");
......@@ -118,9 +117,9 @@ function renderTimeSheet(distances) {
rows.push(row);
}
let totalTitleCell = document.createElement("th");
totalTitleCell.innerHTML = translations.totals;
totalTitleCell.innerHTML = translations.total;
let totalLengthCell = document.createElement("th");
totalLengthCell.innerHTML = totalDistance.toString() + " m";
totalLengthCell.innerHTML = totalDistance.toString();
let totalsRow = document.createElement("tr");
totalsRow.appendChild(totalTitleCell);
totalsRow.appendChild(totalLengthCell);
......@@ -142,7 +141,7 @@ function renderTimeSheet(distances) {
cell = document.createElement("th");
cell.setAttribute("scope", "col");
cell.className = "align-middle";
cell.innerHTML = translations.distance+ " (m)";
cell.innerHTML = translations.distance + " (m)";
headRow2.appendChild(cell);
cell = document.createElement("th");
cell.setAttribute("scope", "col");
......@@ -168,8 +167,8 @@ function renderTimeSheet(distances) {
if (time > 0) {
orienteerDistance = orienteerData[3][i]
timeCell.innerHTML = convertTimeToString(time);
distanceCell.innerHTML = deltaDistanceCalculator(orienteerDistance,distances[i]);
paceCell.innerHTML = RKCalculator(time,distances[i]) + " / " + speedCalculator(time,orienteerDistance);
distanceCell.innerHTML = deltaDistanceCalculator(orienteerDistance, distances[i]);
paceCell.innerHTML = RKCalculator(time, distances[i]) + " / " + speedCalculator(time, orienteerDistance);
orienteerTotalDistance += orienteerDistance;
orienteerTotalTime += time;
} else {
......@@ -181,7 +180,6 @@ function renderTimeSheet(distances) {
rows[index].appendChild(timeCell);
rows[index].appendChild(distanceCell);
rows[index].appendChild(paceCell);
}
let totalTimeCell = document.createElement("th");
......@@ -193,10 +191,10 @@ function renderTimeSheet(distances) {
speedMeanCell.setAttribute("scope", "col");
totalTimeCell.innerHTML = convertTimeToString(orienteerTotalTime);
totalDistanceCell.innerHTML = deltaDistanceCalculator(orienteerTotalDistance,totalDistance);
speedMeanCell.innerHTML = RKCalculator(orienteerTotalTime,totalDistance).toString() + " min/km"
+ "<br>"
+ speedCalculator(orienteerTotalTime,orienteerTotalDistance).toString() + " km/h";
totalDistanceCell.innerHTML = deltaDistanceCalculator(orienteerTotalDistance, totalDistance);
speedMeanCell.innerHTML = RKCalculator(orienteerTotalTime, totalDistance).toString()
+ " / "
+ speedCalculator(orienteerTotalTime, orienteerTotalDistance).toString();
totalsRow.appendChild(totalTimeCell);
totalsRow.appendChild(totalDistanceCell);
......
......@@ -56,7 +56,7 @@
'controlPoint' : '{{ 'timeSheet.control.point' | trans | escape('js') }}',
'length' : '{{ 'timeSheet.length' | trans | escape('js') }}',
'RK' : '{{ 'timeSheet.RK' | trans | escape('js') }}',
'totals' : '{{ 'timeSheet.totals' | trans | escape('js') }}',
'total' : '{{ 'timeSheet.total' | trans | escape('js') }}',
'mean' : '{{ 'timeSheet.mean' | trans | escape('js') }}',
'speed' : '{{ 'timeSheet.speed' | trans | escape('js') }}',
}
......
......@@ -1125,9 +1125,9 @@ such as orienteering, multisport orienteering, trails...</target>
<source>timeSheet.RK</source>
<target>RK</target>
</trans-unit>
<trans-unit id="fHxCRLv" resname="timeSheet.totals">
<source>timeSheet.totals</source>
<target>Totals</target>
<trans-unit id="fHxCRLv" resname="timeSheet.total">
<source>timeSheet.total</source>
<target>Total</target>
</trans-unit>
<trans-unit id="_lItc_M" resname="timeSheet.mean">
<source>timeSheet.mean</source>
......
......@@ -1237,9 +1237,9 @@ de l’Informatique.</target>
<source>timeSheet.RK</source>
<target>RK</target>
</trans-unit>
<trans-unit id="fHxCRLv" resname="timeSheet.totals">
<source>timeSheet.totals</source>
<target>Totaux</target>
<trans-unit id="fHxCRLv" resname="timeSheet.total">
<source>timeSheet.total</source>
<target>Total</target>
</trans-unit>
<trans-unit id="_lItc_M" resname="timeSheet.mean">
<source>timeSheet.mean</source>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment