-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreakView.js
52 lines (48 loc) · 1.1 KB
/
streakView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const dailyTasksData = [
{
id: "exercise-streak",
color: "#FFFF00",
streakData: []
},
{
id: "abstinence-streak",
color: "#EE82EE",
streakData: []
},
{
id: "programming-streak",
color: "#39FF14",
streakData: []
},
{
id: "checking-emails-streak",
color: "#00FFFF",
streakData: []
},
{
id: "future-idealization-streak",
color: "#FFA500",
streakData: []
}
];
function renderStreakView(task) {
const streakView = document.getElementById(task.id);
streakView.innerHTML = '';
task.streakData.forEach(() => {
const streakItem = document.createElement('div');
streakItem.classList.add('streak-item');
streakView.appendChild(streakItem);
});
}
function addStreak(task) {
task.streakData.push(true);
renderStreakView(task);
}
function resetStreak(task) {
task.streakData = [];
renderStreakView(task);
}
// Initial rendering of the streak views
dailyTasksData.forEach((task) => {
renderStreakView(task);
});