2024-04-06 02:57:04 +00:00
|
|
|
<html>
|
2024-04-06 03:24:47 +00:00
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
2024-04-16 19:18:19 +00:00
|
|
|
<div id="data"></div>
|
2024-04-17 14:57:45 +00:00
|
|
|
<button class="btn btn-default" id="btnSave">Save</button>
|
|
|
|
<button class="btn btn-default" id="btnDelete">Delete</button>
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-06 03:24:47 +00:00
|
|
|
<script src="../../core/lib/interface.js"></script>
|
|
|
|
<script>
|
2024-04-16 21:51:36 +00:00
|
|
|
var dataElement = document.getElementById("data");
|
2024-04-17 14:57:45 +00:00
|
|
|
var csvData = "";
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-17 14:57:45 +00:00
|
|
|
function getData() {
|
|
|
|
// show loading window
|
|
|
|
Util.showModal("Loading...");
|
|
|
|
// get the data
|
|
|
|
dataElement.innerHTML = "";
|
2024-04-22 19:48:43 +00:00
|
|
|
Util.readStorageFile(`phystrax_hrm.csv`,data=>{
|
2024-04-17 14:57:45 +00:00
|
|
|
csvData = data.trim();
|
|
|
|
// remove window
|
|
|
|
Util.hideModal();
|
|
|
|
// If no data, report it and exit
|
|
|
|
if (data.length==0) {
|
|
|
|
dataElement.innerHTML = "<b>No data found</b>";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Otherwise parse the data and output it as a table
|
|
|
|
dataElement.innerHTML = `<table>
|
|
|
|
<tr>
|
|
|
|
<th>Timestamp</th>
|
|
|
|
<th>Heart Rate (bpm)</th>
|
|
|
|
<th>HRV (ms)</th>
|
|
|
|
</tr>`+data.trim().split("\n").map(l=>{
|
|
|
|
l = l.split(",");
|
|
|
|
return `<tr>
|
|
|
|
<td>${l[0]}</td>
|
|
|
|
<td>${l[1]}</td>
|
|
|
|
<td>${l[2]}</td>
|
|
|
|
</tr>`
|
|
|
|
}).join("\n")+"</table>";
|
2024-04-16 21:51:36 +00:00
|
|
|
});
|
2024-04-16 21:34:26 +00:00
|
|
|
}
|
2024-04-16 21:27:44 +00:00
|
|
|
|
2024-04-17 14:57:45 +00:00
|
|
|
// You can call a utility function to save the data
|
|
|
|
document.getElementById("btnSave").addEventListener("click", function() {
|
2024-04-22 19:48:43 +00:00
|
|
|
Util.saveCSV("phystrax_hrm.csv", csvData);
|
2024-04-17 14:57:45 +00:00
|
|
|
});
|
|
|
|
// Or you can also delete the file
|
|
|
|
document.getElementById("btnDelete").addEventListener("click", function() {
|
|
|
|
Util.showModal("Deleting...");
|
2024-04-22 19:48:43 +00:00
|
|
|
Util.eraseStorageFile("phystrax_hrm.csv", function() {
|
2024-04-17 14:57:45 +00:00
|
|
|
Util.hideModal();
|
|
|
|
getData();
|
|
|
|
});
|
|
|
|
});
|
2024-04-16 21:51:36 +00:00
|
|
|
// Called when app starts
|
|
|
|
function onInit() {
|
2024-04-17 14:57:45 +00:00
|
|
|
getData();
|
2024-04-16 21:51:36 +00:00
|
|
|
}
|
2024-04-06 02:57:04 +00:00
|
|
|
|
2024-04-06 03:24:47 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
2024-04-06 02:57:04 +00:00
|
|
|
</html>
|