-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (29 loc) · 1.06 KB
/
Copy pathscript.js
File metadata and controls
36 lines (29 loc) · 1.06 KB
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
let topics = [
{ id: 1, title: "Functions", minutes: 25, done: false },
{ id: 2, title: "Array methods", minutes: 35, done: true }
];
let activeFilter = "all";
const form = document.querySelector("#topic-form");
const list = document.querySelector("#topic-list");
const summary = document.querySelector("#summary");
const filters = document.querySelector(".filters");
function getVisibleTopics() {
// TODO: Return all, open, or done topics based on activeFilter.
return topics;
}
function render() {
// TODO: Clear the list, create one safe DOM row per visible topic,
// and calculate the open-minute summary with reduce.
}
form.addEventListener("submit", (event) => {
event.preventDefault();
// TODO: Create a topic object, update topics, reset the form, and render.
});
list.addEventListener("click", (event) => {
// TODO: Read data-action and data-id from the nearest button.
// Update the matching object or remove it, then render.
});
filters.addEventListener("click", (event) => {
// TODO: Set activeFilter, update aria-pressed, and render.
});
render();