data.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <html>
  2. <head>
  3. <style>
  4. html,
  5. body {
  6. height: 100%;
  7. margin: 2px;
  8. }
  9. .box {
  10. display: flex;
  11. flex-flow: column;
  12. height: 100%;
  13. }
  14. .box .row.header {
  15. flex: 0 1 auto;
  16. }
  17. .box .row.content {
  18. flex: 1 1 auto;
  19. }
  20. .box .row.footer {
  21. flex: 0 1 auto;
  22. }
  23. #data {
  24. font-family: 'Courier New', Courier, monospace;
  25. font-size: small;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div class="box">
  31. <div class="row header">
  32. <button onClick="reload();">Reload</button>
  33. <button onClick="window.open('datafileact');">Show full data</button>
  34. <button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
  35. <a href="graph.html" target="_self">Show graph</a>
  36. </div>
  37. <div class="row content" id="data"><br><br><br><b>Loading Data file, please wait...</b></div>
  38. <div class="row footer">
  39. <button onClick="reload();">Reload</button>
  40. <button onClick="window.open('datafileact');">Show full data</button>
  41. <button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
  42. <a href="graph.html" target="_self">Show graph</a>
  43. </div>
  44. </div>
  45. </body>
  46. <script>
  47. function reload() {
  48. document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
  49. window.scrollBy(0,document.body.scrollHeight);
  50. funcRequest('data');
  51. }
  52. async function funcRequest(url){
  53. await fetch(url)
  54. .then((res) => {
  55. if (!res.ok) {
  56. document.getElementById("data").innerHTML = "HTTP error " + res.status;
  57. }
  58. return res.text();
  59. })
  60. .then((data) => {
  61. document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + "&nbsp;";
  62. window.scrollBy(0,document.body.scrollHeight);
  63. })
  64. .catch((err) => {
  65. document.getElementById("data").innerHTML = err;
  66. });
  67. }
  68. funcRequest('data');
  69. </script>
  70. </html>