-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
59 lines (47 loc) · 1.57 KB
/
script.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
53
54
55
56
57
58
59
const tasks = {
"7": ["Complete frontend challenge", "Complete UI/UX challenge"],
"11": ["Start new project", "Meet with team"],
"16": ["Submit report", "Debug code"],
"21": ["Code review", "Write documentation"],
"29": ["Team building...", "Update website"]
};
const todaysTasks = document.getElementById("todays-tasks");
const datesContainer = document.querySelector(".dates");
const currentDateElement = document.getElementById('current-date');
updateDate(2);
for (let i = 1; i <= 30; i++) {
const dateItem = document.createElement("div");
dateItem.classList.add("date-item");
dateItem.textContent = i;
if (tasks[i]) {
dateItem.classList.add("orange");
}
if(i === 2) {
dateItem.classList.add("blue");
}
dateItem.addEventListener("click", () => {
document.querySelectorAll(".date-item").forEach(item => item.classList.remove("blue"));
dateItem.classList.add("blue");
updateTasks(i);
updateDate(i);
});
datesContainer.appendChild(dateItem);
}
function updateTasks(date) {
todaysTasks.innerHTML = "";
if (tasks[date]) {
tasks[date].forEach(task => {
const taskItem = document.createElement("li");
taskItem.textContent = task;
todaysTasks.appendChild(taskItem);
});
}
}
function updateDate(date) {
currentDateElement.textContent = `${date}`;
if (date < 10) {
document.querySelector('.date').textContent = `0${date}`;
} else {
document.querySelector('.date').textContent = `${date}`;
}
}