--- a/src/main/resources/scripts/map.js Fri Aug 26 13:22:13 2011 -0400
+++ b/src/main/resources/scripts/map.js Fri Aug 26 13:36:42 2011 -0400
@@ -98,17 +98,27 @@
var list = document.getElementById('stats').getElementsByTagName('ul')[0];
list.getElementsByClassName('date')[0].getElementsByTagName('span')[0].innerHTML = Util.formatDate(workout.date);
list.getElementsByClassName('start')[0].getElementsByTagName('span')[0].innerHTML = Util.formatTime2(workout.date);
- list.getElementsByClassName('duration')[0].getElementsByTagName('span')[0].innerHTML = workout.duration;
+ list.getElementsByClassName('duration')[0].getElementsByTagName('span')[0].innerHTML = Util.formatTime(workout.duration);
list.getElementsByClassName('distance')[0].getElementsByTagName('span')[0].innerHTML = Util.formatDistance(workout.distance);
- list.getElementsByClassName('pace')[0].getElementsByTagName('span')[0].innerHTML = parseInt(workout.duration)/parseInt(workout.distance);
- list.getElementsByClassName('speed')[0].getElementsByTagName('span')[0].innerHTML = workout.distance / workout.duration;
- list.getElementsByClassName('climb')[0].getElementsByTagName('span')[0].innerHTML = getAscent(workout.events);
+ list.getElementsByClassName('pace')[0].getElementsByTagName('span')[0].innerHTML = computePace(workout.distance, workout.duration) + ' min/km';
+ list.getElementsByClassName('speed')[0].getElementsByTagName('span')[0].innerHTML = computeSpeed(workout.distance, workout.duration) + ' km/h';
+ list.getElementsByClassName('climb')[0].getElementsByTagName('span')[0].innerHTML = getAscent(workout.events) + ' meters';
}
function getAscent(events) {
return events[events.length - 1].c[2] - events[0].c[2];
}
+// returns min/km
+function computePace(distance, duration) {
+ return Util.formatTime((Math.round((duration/60)/(distance/1000)*100)/100)*60);
+}
+
+// returns km/h
+function computeSpeed(distance, duration) {
+ return Math.round((distance/1000)/(duration/3600)*100)/100;
+}
+
function showResult(workout) {
// update the map
OLMap.clearMap();