Personal intranet/start page where I can view the weather, links, fitbit data, and the news.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.1 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  5. <script src="lib/moment.min.js"></script>
  6. <link href="vis/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  7. <script src="vis/vis.js"></script>
  8. <!-- jQuery library -->
  9. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  10. </head>
  11. <div id="heartRateGraph"></div>
  12. <body>
  13. <div class="container">
  14. <div class="row">
  15. <div class="col-4 shadow-lg p-3 bg-white rounded">
  16. <input type="file" id="files" name="files[]" multiple />
  17. <output id="list"></output>
  18. </div>
  19. </div>
  20. <div class="row">
  21. </div>
  22. </div>
  23. </body>
  24. <footer>
  25. <script>
  26. function generateHeartRateGraph(jsonFiles)
  27. {
  28. var items = [];
  29. for(var i = 0; i < jsonFiles.length; i++)
  30. {
  31. console.log(jsonFiles[i].length);
  32. for(var j = 0; j < jsonFiles[i].length; j++)
  33. {
  34. var localTime = new Date(jsonFiles[i][j].dateTime);
  35. items.push({y:jsonFiles[i][j].value.bpm, x:localTime.setHours(localTime.getHours() - 4)});
  36. }
  37. }
  38. console.log("Finished Loading Heart Rate Data Into Graph");
  39. var dataset = new vis.DataSet(items);
  40. var options = {
  41. dataAxis: {
  42. showMinorLabels: true,
  43. left: {
  44. title: {
  45. text: "Heart Rate"
  46. }
  47. }
  48. }
  49. };
  50. var container = document.getElementById("heartRateGraph");
  51. var graph2d = new vis.Graph2d(container, dataset, options);
  52. }
  53. function handleFileSelect(evt)
  54. {
  55. var files = evt.target.files; // FileList object
  56. var promises = [];
  57. for (var i = 0, f; f = files[i]; i++)
  58. {
  59. promises.push(new Promise((resolve, reject)=>
  60. {
  61. var reader = new FileReader();
  62. reader.onload = function(e)
  63. {
  64. resolve(JSON.parse(reader.result));
  65. };
  66. reader.onerror= function(e)
  67. {
  68. reject(e);
  69. };
  70. reader.readAsBinaryString(files[i]);
  71. }));
  72. }
  73. Promise.all(promises).then((data)=>
  74. {
  75. generateHeartRateGraph(data);
  76. }).catch((error)=>
  77. {
  78. console.log(error);
  79. console.log("Unable to Load Data");
  80. })
  81. }
  82. document.getElementById('files').addEventListener('change', handleFileSelect, false);
  83. </script>
  84. </footer>
  85. </html>