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.

138 lines
4.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. /*
  29. var container = document.getElementById('heartRateGraph');
  30. var items = [
  31. {x: '2014-06-11', y: 10},
  32. {x: '2014-06-12', y: 25},
  33. {x: '2014-06-13', y: 30},
  34. {x: '2014-06-14', y: 10},
  35. {x: '2014-06-15', y: 15},
  36. {x: '2014-06-16', y: 30}
  37. ];
  38. var dataset = new vis.DataSet(items);
  39. var options = {
  40. start: '2014-06-10',
  41. end: '2014-06-18'
  42. };
  43. var graph2d = new vis.Graph2d(container, dataset, options);
  44. */
  45. console.log(jsonFiles);
  46. var items = [];
  47. for(var i = 0; i < jsonFiles.length; i++)
  48. {
  49. console.log(jsonFiles[i].length);
  50. for(var j = 0; j < jsonFiles[i].length; j++)
  51. {
  52. //console.log(jsonFiles[i][j]);
  53. items.push({y:jsonFiles[i][j].value.bpm, x:jsonFiles[i][j].dateTime})
  54. }
  55. }
  56. var dataset = new vis.DataSet(items);
  57. var options = {
  58. dataAxis: {
  59. showMinorLabels: true,
  60. left: {
  61. title: {
  62. text: "Heart Rate"
  63. }
  64. }
  65. }
  66. };
  67. var container = document.getElementById("heartRateGraph");
  68. var graph2d = new vis.Graph2d(container, dataset, options);
  69. console.log(items);
  70. }
  71. function handleFileSelect(evt)
  72. {
  73. var files = evt.target.files; // FileList object
  74. // files is a FileList of File objects. List some properties.
  75. var output = [];
  76. var promises = [];
  77. for (var i = 0, f; f = files[i]; i++)
  78. {
  79. output.push('<li><strong>', escape(f.name), '</strong> (', f.type || 'n/a', ') - ',
  80. f.size, ' bytes, last modified: ',
  81. f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a',
  82. '</li>');
  83. promises.push(new Promise((resolve, reject)=>
  84. {
  85. var reader = new FileReader();
  86. reader.onload = function(e)
  87. {
  88. resolve(JSON.parse(reader.result));
  89. };
  90. reader.onerror= function(e)
  91. {
  92. reject(e);
  93. };
  94. reader.readAsBinaryString(files[i]);
  95. //console.log(f);
  96. }));
  97. }
  98. document.getElementById('list').innerHTML = '<ul>' + output.join('') + '</ul>';
  99. Promise.all(promises).then((data)=>
  100. {
  101. generateHeartRateGraph(data);
  102. }).catch((error)=>
  103. {
  104. console.log(error);
  105. console.log("Unable to Load Data");
  106. })
  107. }
  108. document.getElementById('files').addEventListener('change', handleFileSelect, false);
  109. </script>
  110. </footer>
  111. </html>