~ merge
authorPhilippe Le Hegaret <plh@w3.org>
Thu, 25 Aug 2011 14:11:48 -0400
changeset 80 399b81b86b08
parent 79 87f930f95eb5 (current diff)
parent 78 895fee8d36f2 (diff)
child 83 cba0ea819312
~ merge
--- a/src/main/resources/scripts/map.js	Thu Aug 25 14:10:40 2011 -0400
+++ b/src/main/resources/scripts/map.js	Thu Aug 25 14:11:48 2011 -0400
@@ -95,11 +95,31 @@
 
 function updateStats(workout) {
 	var list = document.getElementById('stats').getElementsByTagName('ul')[0];
-	list.getElementsByClassName('date').getElementsByTagName('span').innerHTML = workout.date;
-	list.getElementsByClassName('start').getElementsByTagName('span').innerHTML = workout.date;
-	list.getElementsByClassName('duration').getElementsByTagName('span').innerHTML = workout.duration;
-	list.getElementsByClassName('distance').getElementsByTagName('span').innerHTML = workout.distance;
-	list.getElementsByClassName('pace').getElementsByTagName('span').innerHTML = workout.distance;
-	list.getElementsByClassName('speed').getElementsByTagName('span').innerHTML = workout.distance;
-	list.getElementsByClassName('climb').getElementsByTagName('span').innerHTML = workout.climb;
-}
\ No newline at end of file
+	list.getElementsByClassName('date')[0].getElementsByTagName('span')[0].innerHTML = workout.date;
+	list.getElementsByClassName('start')[0].getElementsByTagName('span')[0].innerHTML = workout.date;
+	list.getElementsByClassName('duration')[0].getElementsByTagName('span')[0].innerHTML = workout.duration;
+	list.getElementsByClassName('distance')[0].getElementsByTagName('span')[0].innerHTML = workout.distance;
+	list.getElementsByClassName('pace')[0].getElementsByTagName('span')[0].innerHTML = workout.distance;
+	list.getElementsByClassName('speed')[0].getElementsByTagName('span')[0].innerHTML = workout.distance;
+	list.getElementsByClassName('climb')[0].getElementsByTagName('span')[0].innerHTML = workout.climb;
+}
+
+function showResult(workout) {
+	// update the map
+	OLMap.clearMap();
+	//OLMap.addTrail(workout.gpx, "red");
+	OLMap.addTrail("Jun-26-11.gpx", "red");
+	// fetch the json data containing the events
+	workout = getWorkout(workout.json);
+	// center the map on the events
+	OLMap.centerMap(workout.events);
+	//TODO: store
+	// update the stats section
+	updateStats(workout);
+	
+	// draw the speed graph
+	var graph = new Graph();
+	graph.init();
+	graph.drawSpeedGraph(workout);
+	
+}
--- a/src/main/resources/templates/index.html	Thu Aug 25 14:10:40 2011 -0400
+++ b/src/main/resources/templates/index.html	Thu Aug 25 14:11:48 2011 -0400
@@ -18,36 +18,12 @@
 		function init() {
 			// get list of workouts
 			var workouts = getWorkouts();
-			// reorder ??
-			
 			// update History section
 			updateHistory(workouts);
-			
 			// create map
 			OLMap.createMap();
-			
 			// show results for last workout
-				// add gpx layer
-				// recenter (based on json events)
-				// update stats
-			
-			
-			var workoutJson = Util.requestJSON('Jun-26-11.json');
-			
-			
-			// testing purposes
-			OLMap.addTrail("Jun-26-11.gpx","blue");
-			OLMap.addTrail("Aug-10-11.gpx","red");
-			
-			//console.log(OLMap.map.layers);
-			
-			OLMap.centerMap(workoutJson.events);
-			
-			//OLMap.clearMap();
-			
-			var graph = new Graph();
-			graph.init();
-			graph.drawSpeedGraph(workoutJson);
+			showResult(workouts[0]);
 		}
 		
 	</script>