-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,14 +31,16 @@ function submit() { | |
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 commentThe reason will be displayed to describe this comment to others. Learn more. In terms of input validation,
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. 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. |
||
) { | ||
alert("Please fill all fields!"); | ||
return false; | ||
} else { | ||
let book = new Book(title.value, title.value, pages.value, check.checked); | ||
library.push(book); | ||
let book = new Book(title.value, author.value, pages.value, check.checked); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
myLibrary.push(book); | ||
render(); | ||
} | ||
} | ||
|
@@ -54,7 +56,7 @@ function render() { | |
let table = document.getElementById("display"); | ||
let rowsNumber = table.rows.length; | ||
//delete old table | ||
for (let n = rowsNumber - 1; n > 0; n-- { | ||
for (let n = rowsNumber - 1; n > 0; n--) { | ||
table.deleteRow(n); | ||
} | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//insert updated row and cells | ||
|
@@ -76,7 +78,7 @@ function render() { | |
changeBut.className = "btn btn-success"; | ||
wasReadCell.appendChild(changeBut); | ||
let readStatus = ""; | ||
if (myLibrary[i].check == false) { | ||
if (myLibrary[i].check === true) { | ||
readStatus = "Yes"; | ||
} else { | ||
readStatus = "No"; | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -89,12 +91,12 @@ function render() { | |
}); | ||
|
||
//add delete button to every row and render again | ||
let delButton = document.createElement("button"); | ||
let delBut = document.createElement("button"); | ||
delBut.id = i + 5; | ||
deleteCell.appendChild(delBut); | ||
delBut.className = "btn btn-warning"; | ||
delBut.innerHTML = "Delete"; | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
delBut.addEventListener("clicks", function () { | ||
delBut.addEventListener("click", function () { | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the advice. Sorted. |
||
render(); | ||
|
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.