|
|
@@ -13,41 +13,33 @@
|
|
|
text-align: left;
|
|
|
font-weight: bold;
|
|
|
}
|
|
|
- body { position: absolute; bottom: 0; left: 0; }
|
|
|
</style>
|
|
|
<script>
|
|
|
- function checkForGoalUpdates() {
|
|
|
- fetch('/updateGoals')
|
|
|
- .then(response => response.json())
|
|
|
- .then(data => {
|
|
|
- const newGoals = data.goals;
|
|
|
- const currentGoals = Array.from(document.querySelectorAll('tbody tr')).map(tr => {
|
|
|
- const goalData = {
|
|
|
- name: tr.children[0].textContent.trim(),
|
|
|
- current: parseInt(tr.children[2].textContent.split('/')[0].trim()),
|
|
|
- target: parseInt(tr.children[2].textContent.split('/')[1].trim())
|
|
|
- };
|
|
|
- return goalData;
|
|
|
- });
|
|
|
-
|
|
|
- if (JSON.stringify(newGoals) !== JSON.stringify(currentGoals)) {
|
|
|
- window.location.reload(); // Refresh if goals have changed
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => console.error('Error fetching updated goals:', error));
|
|
|
- }
|
|
|
+ function checkForUpdates() {
|
|
|
+ fetch('/updateGoals')
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(data => {
|
|
|
+ if (data.updated) {
|
|
|
+ console.log('Goals have changed, refreshing the page...');
|
|
|
+ window.location.reload(); // Refresh if goals have changed
|
|
|
+ } else {
|
|
|
+ console.log('No changes detected.'); // Log if no changes
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => console.error('Error fetching updated goals:', error));
|
|
|
+ }
|
|
|
|
|
|
- setInterval(checkForGoalUpdates, 15 * 1000); // Check every 15 seconds
|
|
|
+ setInterval(checkForUpdates, 15 * 1000); // Check every 15 seconds
|
|
|
</script>
|
|
|
</head>
|
|
|
-<body>
|
|
|
+<body style="position: absolute; bottom: 0; left: 0;">
|
|
|
{% if goals %}
|
|
|
<table>
|
|
|
<thead>
|
|
|
<tr>
|
|
|
- <th>Description</th>
|
|
|
+ <th></th>
|
|
|
<th style="width: 50%"></th>
|
|
|
- <th>Progress</th>
|
|
|
+ <th></th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
@@ -57,7 +49,7 @@
|
|
|
{% set progress = goal[1] / goal[2] * 100 %}
|
|
|
<td>
|
|
|
<div class="bar-light-grey bar-tiny bar-round" style="position: relative;">
|
|
|
- <div class="bar-round bar-blue" style="text-align: center; width:{{ progress }}%;">{{ '%0.0f' | format(progress | float) }}%
|
|
|
+ <div class="bar-round bar-blue" style="text-align: center; width:{{ progress }}%;">{{ '%0.0f'| format(progress| float) }}%
|
|
|
</div>
|
|
|
{% set milestones = rewards[goal[0]]["milestones"] %}
|
|
|
{% for milestone_key, milestone in milestones.items() %}
|
|
|
@@ -81,8 +73,6 @@
|
|
|
{% endfor %}
|
|
|
</tbody>
|
|
|
</table>
|
|
|
- {% else %}
|
|
|
- <p>No active goals at the moment.</p>
|
|
|
{% endif %}
|
|
|
</body>
|
|
|
</html>
|