odin-todo/src/modules/refreshDOM.js

34 lines
639 B
JavaScript

import projects from "../projects";
let idValue = {
value: 0,
get val() {
return this.value;
},
set val(value) {
this.value = value;
}
}
export default function refreshDOM() {
const projectsDiv = document.querySelector("#projects-div #list");
const tasksDiv = document.querySelector("#tasks-div #list");
[projectsDiv, tasksDiv].forEach(div => {
while (div.lastChild) {
div.lastChild.remove();
}
})
projectsDiv.innerHTML += `
name: ${projects[0].name},
<br>`;
idValue.val = 0;
projects[0].todos.forEach(task => {
tasksDiv.append(task.element);
});
}
export { idValue };