subscriber.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <!-- Polls the check_subscribers route every three seconds. When a new subscriber is found,
  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>New Subscriber 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 textBox */
  19. }
  20. #alertImg {
  21. display: none;
  22. max-height: 100px;
  23. position: absolute; /* Allow positioning */
  24. z-index: 1; /* Ensure it's below textBox */
  25. }
  26. #textBox {
  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="textBox"></div>
  52. <script>
  53. setInterval(function() {
  54. fetch('/checkSubscribers')
  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 textBox = document.getElementById('textBox');
  61. const subscriberName = data.name;
  62. const subscriberTier = data.tiername;
  63. textBox.innerHTML = `
  64. ${subscriberName}<br>
  65. ${subscriberTier} subscriber
  66. `;
  67. textBox.style.display = 'block';
  68. alertVid.style.display = 'block';
  69. alertImg.style.display = 'block';
  70. setTimeout(() => {
  71. alertVid.style.display = 'none';
  72. alertImg.style.display = 'none';
  73. textBox.style.display = 'none';
  74. }, 10000); // Visible for 10 seconds
  75. }
  76. });
  77. }, 3000); // Check for new subscribers every 3 seconds
  78. </script>
  79. </body>
  80. </html>