--- a/src/main/resources/scripts/Utils.js Thu Aug 25 12:07:06 2011 -0400
+++ b/src/main/resources/scripts/Utils.js Thu Aug 25 12:07:34 2011 -0400
@@ -175,6 +175,10 @@
http.send(body);
if (async == false)
return http.responseText;
+ },
+
+ requestJSON : function (uri, body, callback, async) {
+ return JSON.parse(Util.request(uri, body, callback, async));
}
};
--- a/src/main/resources/templates/index.html Thu Aug 25 12:07:06 2011 -0400
+++ b/src/main/resources/templates/index.html Thu Aug 25 12:07:34 2011 -0400
@@ -8,11 +8,11 @@
#stats li h2 { display: inline }
</style>
- <script src="../scripts/Utils.js" type="text/javascript"></script>
- <script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
- <!--<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js" type="text/javascript"></script>-->
- <script src="../scripts/Utils.js" type="text/javascript"></script>
- <script src="../scripts/graph.js" type="text/javascript"></script>
+ <script src="../scripts/Utils.js"></script>
+ <script src="../scripts/json2.js"></script>
+ <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
+ <!--<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>-->
+ <script src="../scripts/graph.js"></script>
<script type="text/javascript">
var OLMap = {
@@ -34,7 +34,9 @@
//displayProjection: new OpenLayers.Projection("EPSG:4326"),
//baseLayer: new OpenLayers.Layer.OSM()
});
- OLMap.map.addLayer(new OpenLayers.Layer.OSM());
+ var baseLayer = new OpenLayers.Layer.OSM();
+ OLMap.map.addLayer(baseLayer);
+ OLMap.map.setBaseLayer(baseLayer);
},
addTrail : function(uri, color) {
var layer = new OpenLayers.Layer.GML(uri, uri, {
@@ -73,28 +75,64 @@
bounds.extend(new OpenLayers.LonLat(minLong,minLat));
bounds.extend(new OpenLayers.LonLat(maxLong,maxLat));
return bounds;
- }
+ },
+ clearMap : function() {
+ var gmlLayers = OLMap.map.getLayersByClass('OpenLayers.Layer.GML');
+ for (var i=0; i < gmlLayers.length; i++) {
+ gmlLayers[i].destroy();
+ };
+ },
+
}
function getWorkouts() {
-
-
+ return [{date: "", activity: "running", json: "json_uri", gpx: "gpx_uri", distance: "76", duration: "10"},
+ {date: "", activity: "running", json: "json_uri", gpx: "gpx_uri", distance: "75", duration: "10"}];
}
function getWorkout(uri) {
}
-
+ function toggleLoader() {
+
+ }
+
+ function updateHistory(workouts) {
+
+ }
function init() {
- var workoutJson = eval('(' + Util.request('Jun-26-11.json') + ')');
- console.log(workoutJson);
+ // 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 = eval('(' + Util.request('Jun-26-11.json') + ')');
+ 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);