pierremtb / easy-fit

Parse your .FIT files easily, directly from JS
Other
70 stars 51 forks source link

Load the fit file clientside #4

Closed corand closed 8 years ago

corand commented 8 years ago

Is it possible to load the .fit file clientside? as an array buffer or something like that.

http://www.javascripture.com/FileReader

pierremtb commented 8 years ago

Hi! I think that it is technically possible. Though I tried to make it work with the FileReader api, but I failed, and I didn't have much time to investigate. It would be an awesome feature.

corand commented 8 years ago

Thanks, I will also have a look at it. Nice job!

brvier commented 8 years ago

I made it https://github.com/khertan/ForRunners/commit/b323bf787c658cb94f538402cb5723df60693e05 But readAsArrayBuffer return an array buffer so i changed getArrayBuffer(buffer) in binary.js to return buffer ... ;p

But some changes was required .... first using browserify : $ browserify easy-fit.js --standalone easy-fit > easy-fit.bundle.js

corand commented 8 years ago

Looking good!

corand commented 8 years ago

Here is a working example of the simplified version of @khertan

`

Easy FIT ```


</html>`
pierremtb commented 8 years ago

@khertan @corand Awesome! Thanks for your investigation :)

gfmoore commented 3 years ago

Hi, late to the show I guess,

I had a look at this, but browserify doesn't work with ES6 module import and export. I understand that I could transpile it to ES5 with babel (though I don't know how to do that). Just wondering if there was any other solution?

I suppose I could manually copy and paste the modules into the main js file, but that seems a bit counter-productive. (Though I'll probably have a go for now.)

Gordon

pierremtb commented 3 years ago

Hi @gfmoore, thanks for the interest! I’ll try my best to answer this but it’s been a while (we will have a TypeScript version coming up some day with @jimmykane). What stack are you using on the front end?

gfmoore commented 3 years ago

Hey, thanks for the response. Don't worry about it as now I've simply grabbed all four js files, removed imports, exports, wrote a function to replace the Buffer usage (only the one that makes a string from the array of int (bytes) and it works client side. Not perhaps elegant, not perhaps very modular, but it's a hack and allows me to do what I want. I posted the code in a comment on the backfit site https://github.com/backfit/backfit/issues/6

It's a hack! (I'm just using JS, jQuery, jStat and D3 for developing some personal apps (cycling, Karoo v1) and just wanted to grab my data quickly. For some strange reason the Karoo dashboard does not do anything with the data it grabs, but does allow download of data in a FIT file. I'm not paying Strava for the analysis...

Ta.

pierremtb commented 3 years ago

@gfmoore Cool! Glad this way works for you. Never had to transpile stuff outside of pipelines like Grunt which make it easy.