Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Sanja969/revert-3-add-Edit-Remove
Revert "Milestone 2: Add, Edit and Remove functionalities"
- Loading branch information
Showing
16 changed files
with
60 additions
and
1,014 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
import './style.css'; | ||
import moveSrc from './move.png'; | ||
import refreshSrc from './refresh.png'; | ||
import returnSrc from './return.png'; | ||
import { | ||
addTask, | ||
list, | ||
} from './add.js'; | ||
import clearTask from './remove.js'; | ||
import appendTask from './addTaskUI.js'; | ||
import Task from './tasks.js'; | ||
|
||
const storage = JSON.parse(localStorage.getItem('tasks')) || []; | ||
const addUI = document.querySelector('.add'); | ||
const deleteUI = document.querySelector('.clear'); | ||
const returnImg = document.querySelector('.imgSubmit'); | ||
returnImg.src = returnSrc; | ||
|
||
const refreshImg = document.querySelector('.imgRefresh'); | ||
refreshImg.src = refreshSrc; | ||
|
||
storage.forEach((item) => { | ||
const task = new Task(item.description, item.completed, item.index); | ||
list.push(task); | ||
appendTask(task, list); | ||
}); | ||
const toDoListUI = document.querySelector('.to-do-list'); | ||
|
||
returnImg.src = returnSrc; | ||
refreshImg.src = refreshSrc; | ||
class Task { | ||
constructor(description, completed, index) { | ||
this.description = description; | ||
this.completed = completed; | ||
this.index = index; | ||
} | ||
} | ||
|
||
addUI.addEventListener('change', () => { | ||
addTask(addUI.value, false, list.length + 1); | ||
}); | ||
const list = [new Task('Finsh the project', false, 0), new Task('Wash the dishes', false, 1), new Task('Go on zoom meeting', false, 2)]; | ||
|
||
refreshImg.addEventListener('click', () => { | ||
document.location.href = './index.html'; | ||
}); | ||
const appendTask = (item) => { | ||
const taskUI = document.createElement('li'); | ||
taskUI.innerHTML = `<label><input type='checkbox' id = task-${item.index} class = 'check' value=${item.index}>${item.description}</label>`; | ||
const moveImg = new Image(); | ||
moveImg.src = moveSrc; | ||
taskUI.appendChild(moveImg); | ||
toDoListUI.appendChild(taskUI); | ||
}; | ||
|
||
deleteUI.addEventListener('click', () => { | ||
const checks = document.querySelectorAll('.check'); | ||
for (let i = 0; i < checks.length; i += 1) { | ||
if (checks[i].checked) { | ||
clearTask(checks[i].value, list); | ||
} | ||
} | ||
localStorage.setItem('tasks', JSON.stringify(list)); | ||
}); | ||
for (let i = 0; i < list.length; i += 1) { | ||
appendTask(list[i]); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.