goals.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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>Active goals</title>
  7. <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
  8. <style>
  9. body {
  10. background-color: transparent;
  11. color: white;
  12. width: 600px;
  13. text-align: left;
  14. font-weight: bold;
  15. }
  16. </style>
  17. <script>
  18. function checkForUpdates() {
  19. fetch('/updateGoals')
  20. .then(response => response.json())
  21. .then(data => {
  22. if (data.updated) {
  23. console.log('Goals have changed, refreshing the page...');
  24. window.location.reload(); // Refresh if goals have changed
  25. } else {
  26. console.log('No changes detected.'); // Log if no changes
  27. }
  28. })
  29. .catch(error => console.error('Error fetching updated goals:', error));
  30. }
  31. setInterval(checkForUpdates, 15 * 1000); // Check every 15 seconds
  32. </script>
  33. </head>
  34. <body style="position: absolute; bottom: 0; left: 0;">
  35. {% if goals %}
  36. <table>
  37. <thead>
  38. <tr>
  39. <th></th>
  40. <th style="width: 50%"></th>
  41. <th></th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. {% for goal in goals %}
  46. <tr>
  47. <td style="text-align: left;">{{ goal[3] }}</td>
  48. {% set progress = goal[1] / goal[2] * 100 %}
  49. <td>
  50. <div class="bar-light-grey bar-tiny bar-round" style="position: relative;">
  51. <div class="bar-round bar-blue" style="text-align: center; width:{{ progress }}%;">{{ '%0.0f'| format(progress| float) }}%
  52. </div>
  53. {% set milestones = rewards[goal[0]]["milestones"] %}
  54. {% for milestone_key, milestone in milestones.items() %}
  55. {% if milestones[milestone_key][0] and milestones[milestone_key][1] %}
  56. {% if milestones[milestone_key][1] < goal[2] %}
  57. {% set milestone_progress = milestones[milestone_key][1] / goal[2] * 100 %}
  58. <div class="milestone-marker" style="position: absolute; left: {{ milestone_progress }}%; transform: translateX(-50%);">
  59. <img src="/static/img/milestone.png" style="width: 16px; height: 16px;" title="{{ milestones[milestone_key][1] }} points. {{ milestones[milestone_key][0] }}">
  60. </div>
  61. {% endif %}
  62. {% endif %}
  63. {% endfor %}
  64. </div>
  65. </td>
  66. {% if goal[1] == goal[2] %}
  67. <td style="text-align: right;">{{ goal[1] }} / {{ goal[2] }} <img src="/static/img/tada.png" style="width: 24px; height: 24px;"></td>
  68. {% else %}
  69. <td style="text-align: right;">{{ goal[1] }} / {{ goal[2] }}</td>
  70. {% endif %}
  71. </tr>
  72. {% endfor %}
  73. </tbody>
  74. </table>
  75. {% endif %}
  76. </body>
  77. </html>