Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Commit

Permalink
Add .fit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Benoît HERVIER committed Jun 9, 2016
1 parent ef65f6c commit b323bf7
Show file tree
Hide file tree
Showing 4 changed files with 2,889 additions and 8 deletions.
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<script src="lib/ionic-modal-select/dist/ionic-modal-select.js"></script>

<!-- Easy-Fit -->
<script src="lib/easy-fit/dist/easy-fit.js"></script>
<script src="lib/easy-fit.bundle.js"></script>

<!-- Slow too much device -->
<!--<script src="lib/waves/dist/waves.min.js"></script>
Expand Down
27 changes: 22 additions & 5 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ angular.module('app.controllers', [])
var reader = new FileReader();

// Require the module
var EasyFit = require('../lib/easy-fit/dist/easy-fit.js').default;
//var EasyFit = require('easy-fit').default;
var EasyFit = window.easyFit.default;

reader.onloadend = function() {

Expand All @@ -987,13 +988,29 @@ angular.module('app.controllers', [])
if (error) {
console.log(error);
} else {
console.log(JSON.stringify(data));
}
});
console.log(JSON.stringify(data));

for (var sessions_idx in data.activity.sessions) {
$scope.session = {};
$scope.session.gpxData = [];

for (var lap_idx in data.activity.sessions[sessions_idx].laps) {
for (var record_idx in data.activity.sessions[sessions_idx].laps[lap_idx].records) {
var pnt = data.activity.sessions[sessions_idx].laps[lap_idx].records[record_idx];
$scope.session.gpxData.push([pnt.position_lat, pnt.position_long, pnt.timestamp, pnt.altitude, pnt.heart_rate, 0, pnt.cadence, pnt.power, pnt.vertical_oscillation]);
}
}

$scope.session.recclicked = new Date($scope.session.gpxData[0][2]).getTime();
//Save session already compute session
$scope.saveSession();
}

}
});
};

reader.readAsText(file);
reader.readAsArrayBuffer(file);
};


Expand Down
Loading

0 comments on commit b323bf7

Please sign in to comment.