-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 952 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { createNewTodo, newTodo } from "./modules/newTodo.js";
import { filterTodos } from "./modules/filterTodos.js";
import { folders } from "./modules/folders.js";
import { footer } from "./modules/footer.js";
import { dragAndDropTodos } from "./modules/dragAndDrop.js";
import { viewOptions } from "./modules/viewOptions.js";
let todoArray = JSON.parse(localStorage.getItem('todoFolders')) || [];
export function addTodos(array) {
const itemsLeft = document.querySelector('.todo__footer-left');
const list = document.querySelector('.todo__list');
list.innerHTML = '';
array.forEach(el => newTodo(el, list, todoArray));
itemsLeft.textContent = `${array.filter(item => item.completed === false).length} items left`;
}
footer();
viewOptions();
addTodos(todoArray.filter(folder => folder.active)[0]?.todos || []); // Render todos from active folder
createNewTodo(todoArray);
filterTodos(todoArray);
dragAndDropTodos(todoArray);
folders();