votes.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.0">
  6. <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
  7. <title>Active votes</title>
  8. <style>
  9. body {
  10. background-color: transparent;
  11. color: white;
  12. width: 400px;
  13. position: absolute;
  14. bottom: 0; left: 0;
  15. font-weight: bold;
  16. }
  17. </style>
  18. <script>
  19. function checkForUpdates() {
  20. fetch('/updateVotes')
  21. .then(response => response.json())
  22. .then(data => {
  23. if (data.updated) {
  24. console.log('Votes have changed, refreshing the page...');
  25. window.location.reload(); // Refresh if votes have changed
  26. } else {
  27. console.log('No changes detected.'); // Log if no changes
  28. }
  29. })
  30. .catch(error => console.error('Error fetching updated votes:', error));
  31. }
  32. setInterval(checkForUpdates, 15 * 1000); // Check every 15 seconds
  33. </script>
  34. </head>
  35. <body>
  36. {% if votes %}
  37. <table>
  38. <thead>
  39. <tr>
  40. <th></th>
  41. <th></th>
  42. <th></th>
  43. </tr>
  44. </thead>
  45. <tbody>
  46. {% for vote in votes %}
  47. <tr>
  48. <td>{{ vote[2] }}</td>
  49. {% if vote[1] == 1 %}
  50. <td>{{ vote[1] }} vote</td>
  51. {% else %}
  52. <td>{{ vote[1] }} votes</td>
  53. {% endif %}
  54. </tr>
  55. {% endfor %}
  56. </tbody>
  57. </table>
  58. {% endif %}
  59. </body>
  60. </html>