דברים שרואים מכאן לא רואים בכלל
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

progbar.html 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Distance measurement</title>
  7. <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  8. <link href="/static/css/h-ticker.css" rel="stylesheet">
  9. <link rel="icon" href="/static/gfx/antenna.png">
  10. </head>
  11. <body data-bs-theme="dark">
  12. <div class="container-fluid text-center">
  13. <div class="row">
  14. <div class="col12">
  15. <h1>Distance measurement</h1>
  16. <div class="progress" role="progressbar" aria-label="Success striped example" style="height: 4rem">
  17. <div id="distance-bar" class="progress-bar h2 progress-bar-striped progress-bar-animated bg-success" style="width: 25%"></div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. <script src="/static/js/config.js"></script>
  23. <script src="/static/js/jquery-3.7.1.min.js"></script>
  24. <script>
  25. async function getDistance() {
  26. try {
  27. let response = await fetch("/d");
  28. let data = await response.json();
  29. return data.distance;
  30. } catch {
  31. return 0;
  32. }
  33. };
  34. async function updateDistance() {
  35. var dist = await getDistance();
  36. var bar = document.getElementById("distance-bar");
  37. var percentage = dist>MAX_DIST ? 100 : parseInt((100.0*dist)/MAX_DIST);
  38. bar.style.width=`${percentage}%`;
  39. bar.textContent = dist;
  40. }
  41. window.update_interval = setInterval(updateDistance, 200);
  42. </script>
  43. </body>
  44. </html>