Skip to content

Conversation

@sauravkr818
Copy link

@sauravkr818 sauravkr818 commented Apr 2, 2021

This adds todo webpage
@deepakg202 deepakg202 added the submission Task submission label Apr 2, 2021
@deepakg202 deepakg202 changed the title [ADD]todo webpage sauravkr818 - Task 1 Apr 2, 2021
Copy link
Member

@Rohitrajak1807 Rohitrajak1807 left a comment

Choose a reason for hiding this comment

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

@sauravkr818 I have added some comments. Please have a look

@sauravkr818
Copy link
Author

Okay @Rohitrajak1807 @deepakgupta191199 bhaiya.

This updates the UI and removes the bug DevCANS#1
@sauravkr818
Copy link
Author

@Rohitrajak1807
Copy link
Member

@sauravkr818
Copy link
Author

@sauravkr818 the reload issue is fixed, but what happens if I check a to-do item and hit reload immediately?

Okay I will fix it soon.

This fixes the issue of marking checkbox and then reloading DevCANS#1
@sauravkr818 sauravkr818 requested a review from deepakg202 April 5, 2021 05:24
<strong>Please add any item</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>`;
$("#save-info").html(clearInfo);
Copy link
Member

Choose a reason for hiding this comment

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

You should avoid the use of JQuery or any other library for a simple task which can be easily done without it.

Copy link
Author

Choose a reason for hiding this comment

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

I used jQuery just to display confirmation messages to the user. Should I remove the display messages and keep it simple?

Copy link
Member

Choose a reason for hiding this comment

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

You can do it without jQuery

Copy link
Author

Choose a reason for hiding this comment

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

Okay bhaiya give me some time.

Comment on lines 117 to 122
todoList.length > 0 // if array length is null then do not show confirm msg.
? `${confirm("Are you sure you want to delete your all items")}
${localStorage.removeItem("todoList")}
${(todoList = [])} // array made empty
${renderList()}`
: "";
Copy link
Member

Choose a reason for hiding this comment

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

You should not do this. This is not at all readable and may not get properly formatted by eslint or other formatters.

Use a simple if condition.

Comment on lines +111 to +113
`${localStorage.removeItem("todoList")}
${(todoList = [])}
${renderList()}`
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to call functions inside template strings unless you are storing it in a variable.
And these statements do not return anything so it is of no use to call it in a template string

Copy link
Author

Choose a reason for hiding this comment

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

Okay got it.

Comment on lines +132 to +139
try {
if (localStorage.getItem("todoList")) {
todoList = JSON.parse(localStorage.getItem("todoList"));
renderList();
}
} catch (e) {
console.log(e);
}
Copy link
Member

Choose a reason for hiding this comment

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

You can use this code just after defining the todoList array.

}
};

document.getElementById("todo-form").addEventListener("submit", (event) => {
Copy link
Member

Choose a reason for hiding this comment

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

Define event listeners at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

submission Task submission

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants