| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Active votes</title>
- <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
- <style>
- body {
- background-color: transparent;
- color: white;
- width: 400px;
- position: absolute;
- bottom: 0; left: 0;
- font-weight: bold;
- }
- </style>
- <script>
- function checkForVoteUpdates() {
- fetch('/updateVotes')
- .then(response => response.json())
- .then(data => {
- const newVotes = data.votes;
- const currentVotes = Array.from(document.querySelectorAll('tbody tr')).map(tr => {
- return {
- text: tr.children[0].textContent,
- count: parseInt(tr.children[1].textContent)
- };
- });
- if (JSON.stringify(newVotes) !== JSON.stringify(currentVotes)) {
- window.location.reload(); // Refresh if votes have changed
- }
- })
- .catch(error => console.error('Error fetching updated votes:', error));
- }
- setInterval(checkForVoteUpdates, 15 * 1000); // Check every 15 seconds
- </script>
- </head>
- <body>
- {% if votes %}
- <table>
- <thead>
- <tr>
- <th>Item</th>
- <th>Votes</th>
- </tr>
- </thead>
- <tbody>
- {% for vote in votes %}
- <tr>
- <td>{{ vote[2] }}</td>
- <td>{{ vote[1] }} vote{% if vote[1] != 1 %}s{% endif %}</td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% else %}
- <p>No active votes at the moment.</p>
- {% endif %}
- </body>
- </html>
|