-
-
Notifications
You must be signed in to change notification settings - Fork 114
London | ITP-May-25 | Emiliano Uruena | Data-Flows Sprint-2 | Book-Library 📚 #253
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
base: main
Are you sure you want to change the base?
Conversation
debugging/book-library/index.html
Outdated
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.
According to https://validator.w3.org/, there are errors in your index.html
. Can you fix these errors?
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're right: Element title must not be empty. Duplicate ID title. Duplicate ID author.Duplicate ID check. Sorted!
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.
According to https://validator.w3.org/, there are still errors in your index.html.
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.
Apologies, I’ve reviewed and resolved it.
debugging/book-library/script.js
Outdated
if ( | ||
title.value == null || | ||
title.value == "" || | ||
author.value == null || | ||
author.value == "" || | ||
pages.value == null || | ||
pages.value == "" |
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.
In terms of input validation,
- Can
.value
benull
? (Do we need to checksomeInputElement.value == null
?) - Do you want to allow book title and author name to contain only space characters?
- What if a user enters an invalid page number in the "pages" input field?
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.
Mmm... I didn't think that. Now, I added trim() to check the spaces on title and author. Also, a validator for number of pages.
debugging/book-library/script.js
Outdated
alert(`You've deleted title: ${myLibrary[i].title}`); | ||
myLibrary.splice(i, 1); |
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.
The alert message is shown before the book is actually deleted; the deletion only occurs after the alert dialog is dismissed. This introduces a risk that the operation may not complete (e.g., if the user closes the browser before dismissing the alert).
In general, it’s better to display a confirmation message only after the associated operation has successfully completed.
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.
Thank you for the advice. Sorted.
- Using user input with validation. - Arguments are pre-processed/sanitize before calling the constructor; removing leading/trailing whitespace - rows are inserted inside the <tbody>, not the <thead>
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.
@cjyuan Thank you for the feedback on my JavaScript PR; it was very constructive.
Issues solved according to the advices:
- Using user input with validation.
- Arguments are pre-processed/sanitize before calling the constructor; removing leading/trailing whitespace
- rows are inserted inside the , not the
debugging/book-library/index.html
Outdated
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're right: Element title must not be empty. Duplicate ID title. Duplicate ID author.Duplicate ID check. Sorted!
debugging/book-library/script.js
Outdated
if ( | ||
title.value == null || | ||
title.value == "" || | ||
author.value == null || | ||
author.value == "" || | ||
pages.value == null || | ||
pages.value == "" |
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.
Mmm... I didn't think that. Now, I added trim() to check the spaces on title and author. Also, a validator for number of pages.
debugging/book-library/script.js
Outdated
alert(`You've deleted title: ${myLibrary[i].title}`); | ||
myLibrary.splice(i, 1); |
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.
Thank you for the advice. Sorted.
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.
Changes in script.js
look good.
index.html
still have errors (according to W3C validator).
debugging/book-library/index.html
Outdated
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.
According to https://validator.w3.org/, there are still errors in your index.html.
- Attribute type updated in input for author and title - Charset and name in separated tags. - Empty rows on tbody removed. - html tag with language attribute. On script: Variable to store name of book to show the name after it is deleted.
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.
It were reviewed and resolved.
debugging/book-library/index.html
Outdated
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.
Apologies, I’ve reviewed and resolved it.
Self checklist
Changelist
Bug Fixes Implemented in JavaScript and HTML Functionality:
The display function now correctly renders the full list of books stored in memory or local storage. Any updates to the list—such as adding or removing books—are reflected immediately in the user interface.
Users can now successfully add books they've read to the list. Each book entry includes:
All form inputs are now properly validated. If any required field is missing or left empty, the book will not be added, and the system will display an alert message prompting the user to complete all fields. This prevents empty or incomplete entries in the book list.
Each book in the list now includes a "Remove" button. When clicked, the corresponding book is deleted from the list both visually and from the underlying data. The removal process has been debugged to ensure that it consistently targets the correct entry without affecting others.