Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to do list #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

to do list #8

wants to merge 5 commits into from

Conversation

vidushi260
Copy link

No description provided.

@suhanichawla
Copy link
Collaborator

Please add the project files for the assignment to your folder

@vidushi260 vidushi260 changed the title I have added my folder to do list Oct 28, 2020
@vidushi260
Copy link
Author

bg
bg
bg
bg1
bg2

@vidushi260
Copy link
Author

`const clear = document.querySelector(".clear");
const dateElement = document.getElementById("date");
const list = document.getElementById("list");
const input = document.getElementById("input");

const options = {weekday : "long" ,month: "short" , day: "numeric"}
const today = new Date();
console.log(today);
const CHECK = "fa-check-circle";
const UNCHECK = "fa-circle-thin";
const LINE_THROUGH = "lineThrough";
dateElement.innerHTML = today.toLocaleDateString("en-IN",options);

function addToDo(todo)
{
const item = <li class ="item"> <i class ="fa fa-circle-thin co" job="complete"></i> <p class="text">${todo}</p> <i class="fa fa-trash-o de" job="delete"></i> </li>
const position ="beforeend"
list.insertAdjacentHTML(position,item);

}

document.addEventListener("keyup", function(event){
if(event.key == "Enter"){
const todo = input.value;

    if(todo){
        addToDo(todo);
    }
}

});

list.addEventListener("click",function(event){
const element = event.target;
const elementJob = element.attributes.job.value;

if(elementJob == "complete"){
    completeToDo(element);
}
else if(elementJob == "delete"){
    removeToDo(element);
}

})

function completeToDo(element){
element.classList.toggle(UNCHECK);
element.classList.toggle(CHECK);
element.parentNode.querySelector(".text").classList.toggle(LINE_THROUGH);

}

function removeToDo(element){
element.parentNode.parentNode.removeChild(element.parentNode);
}

function clearall(){
const myNode = document.getElementById("list");
myNode.innerHTML = '';

}
`

Copy link
Collaborator

@pccoder-2000 pccoder-2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add your project files to your own folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants