list.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. <title>Today's to-do List</title>
  7. <style>
  8. body {
  9. background-color: transparent;
  10. width: 400px;
  11. }
  12. </style>
  13. <script>
  14. function checkForUpdates() {
  15. fetch('/updateTodo')
  16. .then(response => response.json())
  17. .then(data => {
  18. if (data.updated) {
  19. console.log('List has changed, refreshing the page...');
  20. window.location.reload(); // Refresh if votes have changed
  21. } else {
  22. console.log('No changes detected.'); // Log if no changes
  23. }
  24. })
  25. .catch(error => console.error('Error fetching updated list:', error));
  26. }
  27. setInterval(checkForUpdates, 15 * 1000); // Check every 15 seconds
  28. </script>
  29. </head>
  30. <body>
  31. {% if items %}
  32. <h4>Today's to-do List</h4>
  33. <ul id="todo-list">
  34. {% for item in items %}
  35. <li style="text-decoration: {{ 'line-through' if item.crossed == 'yes' else 'none' }};">
  36. {{ item.name }}
  37. </li>
  38. {% endfor %}
  39. </ul>
  40. {% else %}
  41. <h4>Nothing on the to-do list yet</h4>
  42. {% endif %}
  43. </body>
  44. </html>