This repository was archived by the owner on Dec 18, 2024. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 41
NW6 | Sabella Fisseha | JS2 Module-To Do-List App | WEEK 4 #217
Open
Sabella-8
wants to merge
1
commit into
CodeYourFuture:main
Choose a base branch
from
Sabella-8:todolistweek4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,25 +1,128 @@ | ||
function populateTodoList(todos) { | ||
let list = document.getElementById("todo-list"); | ||
// Write your code to create todo list elements with completed and delete buttons here, all todos should display inside the "todo-list" element. | ||
} | ||
todos.forEach((element) => { | ||
const listing = document.createElement("li"); | ||
const rem = document.createElement("span"); | ||
const add = document.createElement("span"); | ||
const dateCale = document.createElement("span"); | ||
const dateInput = document.createElement("input"); | ||
dateInput.type = "date"; | ||
dateInput.classList.add("inputing"); | ||
dateInput.style.display = "none"; | ||
rem.textContent = "🗑"; | ||
add.textContent = "✅"; | ||
dateCale.textContent = "📅"; | ||
listing.appendChild(rem); | ||
listing.appendChild(add); | ||
listing.appendChild(dateCale); | ||
listing.appendChild(dateInput); | ||
const taskText = document.createTextNode(element.task); | ||
listing.appendChild(taskText); | ||
list.appendChild(listing); | ||
let clickCount = 0; | ||
dateCale.addEventListener("click", () => { | ||
if (dateInput.style.display === "none") { | ||
dateInput.style.display = "block"; | ||
} else { | ||
dateInput.style.display = "none"; | ||
} | ||
}); | ||
|
||
|
||
add.addEventListener("click", () => { | ||
clickCount++; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of using the number of counts to determine the status of the todo. you can make use of the |
||
let isEvenClick = clickCount % 2 === 0; | ||
|
||
|
||
if (isEvenClick) { | ||
listing.style.textDecoration = "none"; | ||
} else { | ||
listing.style.textDecoration = "line-through"; | ||
} | ||
}); | ||
|
||
|
||
rem.addEventListener("click", () => { | ||
listing.remove(); | ||
}); | ||
}); | ||
} | ||
|
||
// These are the same todos that currently display in the HTML | ||
// You will want to remove the ones in the current HTML after you have created them using JavaScript | ||
let todos = [ | ||
{ task: "Wash the dishes", completed: false }, | ||
{ task: "Do the shopping", completed: false }, | ||
]; | ||
|
||
|
||
populateTodoList(todos); | ||
|
||
// This function will take the value of the input field and add it as a new todo to the bottom of the todo list. These new todos will need the completed and delete buttons adding like normal. | ||
function addNewTodo(event) { | ||
// The code below prevents the page from refreshing when we click the 'Add Todo' button. | ||
event.preventDefault(); | ||
// Write your code here... and remember to reset the input field to be blank after creating a todo! | ||
} | ||
const inputTodo = document.getElementById("textboxinput"); | ||
const buttonTodo = document.querySelector("button"); | ||
buttonTodo.addEventListener("click", (event) => { | ||
event.preventDefault(); | ||
const newList = document.createElement("li"); | ||
let list = document.getElementById("todo-list"); | ||
const tex = document.createTextNode(inputTodo.value); | ||
inputTodo.value = ""; | ||
const rem = document.createElement("span"); | ||
const add = document.createElement("span"); | ||
const dateCale = document.createElement("span"); | ||
const dateInput = document.createElement("input"); | ||
dateInput.type = "date"; | ||
dateInput.classList.add("inputing"); | ||
dateInput.style.display = "none"; | ||
rem.textContent = "🗑"; | ||
add.textContent = "✅"; | ||
dateCale.textContent = "📅"; | ||
newList.appendChild(rem); | ||
newList.appendChild(add); | ||
newList.appendChild(dateCale); | ||
newList.appendChild(dateInput); | ||
newList.append(tex); | ||
list.appendChild(newList); | ||
|
||
|
||
let clickCount = 0; | ||
|
||
// Advanced challenge: Write a fucntion that checks the todos in the todo list and deletes the completed ones (we can check which ones are completed by seeing if they have the line-through styling applied or not). | ||
|
||
dateCale.addEventListener("click", () => { | ||
if (dateInput.style.display === "none") { | ||
dateInput.style.display = "block"; | ||
} else { | ||
dateInput.style.display = "none"; | ||
} | ||
}); | ||
add.addEventListener("click", () => { | ||
clickCount++; | ||
let isEvenClick = clickCount % 2 === 0; | ||
|
||
|
||
if (isEvenClick) { | ||
newList.style.textDecoration = "none"; | ||
} else { | ||
newList.style.textDecoration = "line-through"; | ||
} | ||
}); | ||
|
||
|
||
rem.addEventListener("click", () => { | ||
newList.remove(); | ||
}); | ||
}); | ||
|
||
|
||
} | ||
addNewTodo(); | ||
function deleteAllCompletedTodos() { | ||
// Write your code here... | ||
const del = document.getElementById("remove-all-completed"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function isnt implemented correctly, when clicked, it removes all todos on the board. You should rewrite this function to filter out todos that has their |
||
let list = document.getElementById("todo-list"); | ||
del.addEventListener("click", () => { | ||
list.textContent = ""; | ||
}); | ||
|
||
} | ||
deleteAllCompletedTodos(); | ||
|
||
|
||
|
This file contains hidden or 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 +1,59 @@ | ||
|
||
body { | ||
background-color: aquamarine; | ||
|
||
|
||
font-size: 2rem; | ||
} | ||
#todo-list li { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.inputing { | ||
position: fixed; | ||
left: 600px; | ||
} | ||
|
||
|
||
section { | ||
background-color: beige; | ||
width: 78%; | ||
margin-right: 10%; | ||
margin-top: 10%; | ||
margin-left: 20%; | ||
} | ||
h1 { | ||
text-align: center; | ||
} | ||
div { | ||
background-color: beige; | ||
} | ||
|
||
|
||
li { | ||
list-style-type: none; | ||
} | ||
span { | ||
position: relative; | ||
left: 350px; | ||
cursor: pointer; | ||
} | ||
input { | ||
padding: 0.5rem; | ||
margin-left: 20%; | ||
display: block; | ||
} | ||
button { | ||
padding: 0.5rem; | ||
border-radius: 10px; | ||
background-color: aquamarine; | ||
margin-top: 30px; | ||
margin-left: 15%; | ||
margin-bottom: 10%; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should have the deadline date right here, it should be set after the user enter the todo name