rgoal.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <!-- Polls the check_goals route every three seconds. When a goal is reached,
  4. the alert is displayed for ten seconds. -->
  5. <head>
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>Goal Reached Alert</title>
  9. <style>
  10. body {
  11. background-color: transparent;
  12. position: relative; /* Ensure relative positioning for absolute children */
  13. }
  14. #alertVid {
  15. display: none;
  16. max-height: 100px;
  17. position: absolute; /* Allow positioning with top, left, etc. */
  18. z-index: 1; /* Ensure it's below nameBox */
  19. }
  20. #alertImg {
  21. display: none;
  22. max-height: 100px;
  23. position: absolute; /* Allow positioning */
  24. z-index: 1; /* Ensure it's below nameBox */
  25. }
  26. #nameBox {
  27. display: none;
  28. position: absolute;
  29. top: 20%; /* Adjust as needed */
  30. left: 50%; /* Center horizontally */
  31. transform: translateX(-50%); /* Center */
  32. color: black;
  33. z-index: 2; /* Ensure it appears above alertImg and alertVid */
  34. font-size: 20px; /* Adjust as needed */
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. {% if not alert_name %}
  40. <div id="alertVid"></div>
  41. <div id="alertImg"></div>
  42. {% elif "webm" in alert_name %}
  43. <video id="alertVid" autoplay>
  44. <source src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}" type="video/webm">
  45. </video>
  46. <div id="alertImg"></div>
  47. {% else %}
  48. <div id="alertVid"></div>
  49. <img id="alertImg" src="{{ url_for('web_panels.alerts', alert_name=alert_name) }}">
  50. {% endif %}
  51. <div id="nameBox"></div>
  52. <script>
  53. setInterval(function() {
  54. fetch('/checkGoals')
  55. .then(response => response.json())
  56. .then(data => {
  57. if (data) {
  58. const alertVid = document.getElementById('alertVid');
  59. const alertImg = document.getElementById('alertImg');
  60. const nameBox = document.getElementById('nameBox');
  61. const alertName = data.name;
  62. nameBox.innerHTML = `
  63. ${alertName}
  64. `;
  65. nameBox.style.display = 'block';
  66. alertVid.style.display = 'block';
  67. alertImg.style.display = 'block';
  68. setTimeout(() => {
  69. alertVid.style.display = 'none';
  70. alertImg.style.display = 'none';
  71. nameBox.style.display = 'none';
  72. }, 10000); // Visible for 10 seconds
  73. }
  74. });
  75. }, 3000); // Check for new followers every 3 seconds
  76. </script>
  77. </body>
  78. </html>