Hello dkeipp,
Thank you for posting your question.
If we understand it correctly, your goal is to persist some data (the speed and the user power). Unfortunately, it is not possible to write directly to a file using HTML5 technologies. Your options would be the following:
Saving the data to local storage and then displaying it when off-ride
Sending the data to a database through an API
The easiest solution to get started probably is #1. As you probably now, localStorage is a piece of memory in your browser, in which the stored data is saved across browser sessions.
You would probably implement something as follows:
function SaveDataToLocalStorage(currentSpeed, currentUserPower)
{
var speedValues = [];
var userPowerValues = []:
// Parse the serialized data back into an aray of objects
speedValues = JSON.parse(localStorage.getItem('speedData')) || [];
userPowerValues = JSON.parse(localStorage.getItem('userPowerData')) || [];
// Push the new data (whether it be an object or anything else) onto the array
speedValues.push(currentSpeed);
userPowerData.push(currentUserPower);
// Re-serialize the array back into a string and store it in localStorage
localStorage.setItem('speedData', JSON.stringify(speedValues));
localStorage.setItem('userPowerData', JSON.stringify(userPowerValues));
}
... View more