Habit Streak Update++
This commit is contained in:
parent
fc570208bf
commit
a8a3382f15
1
app.py
1
app.py
@ -428,6 +428,7 @@ def check_habit():
|
||||
"habitId": habit_id,
|
||||
"unchecked": not delete_tracking,
|
||||
"percentage": habit.percentage,
|
||||
"streak": habit.streak
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Streak -->
|
||||
<div class="col-2" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||
<div class="col-2" id="streak-{{ habit.id }}" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
|
||||
{% if not habit.streak == 0 %}
|
||||
{{ habit.streak }} 🔥
|
||||
{% endif %}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
var progressBar = document.getElementById("progress-bar-" + habitId);
|
||||
var habitBlock = document.getElementById("habit-" + habitId);
|
||||
|
||||
if (percentage == 100) {
|
||||
if (percentage === 100) {
|
||||
progressBar.style.backgroundColor = "green";
|
||||
habitBlock.classList.add("animate-bounce");
|
||||
setTimeout(function () {
|
||||
@ -33,11 +33,16 @@
|
||||
// Handle the success response if needed
|
||||
console.log(response.data);
|
||||
|
||||
|
||||
// Set the percentage of the habit. percentage received as integer
|
||||
var percentage = response.data.percentage;
|
||||
var progressBar = document.getElementById("progress-bar-" + habitId);
|
||||
const percentage = response.data.percentage;
|
||||
const progressBar = document.getElementById("progress-bar-" + habitId);
|
||||
progressBar.style.width = percentage + "%";
|
||||
checkCompletionAndAnimate(habitId, percentage);
|
||||
|
||||
const streak = response.data.streak;
|
||||
const streakSymbol = document.getElementById("streak-" + habitId);
|
||||
streakSymbol.innerText = streak > 0 ? streak.toString() + " 🔥" : "";
|
||||
}).catch(function (error) {
|
||||
// Handle the error if needed
|
||||
console.error('Error:', error);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user