Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6fe2b67
missing bracket closure on line 57
AngelaMcLeary Apr 9, 2026
b647506
fix syntax error on line 92 update variable
AngelaMcLeary Apr 9, 2026
dc2969c
add title to html file
AngelaMcLeary Apr 9, 2026
6146e7f
update variable name to myLibrary on Line 41
AngelaMcLeary Apr 9, 2026
731ac4c
return of author value on line 40 to allow correct output
AngelaMcLeary Apr 9, 2026
377bd24
fix typo change click to clicks on line 92
AngelaMcLeary Apr 9, 2026
200d98c
fix result of input status of book when read is selected to YES line …
AngelaMcLeary Apr 9, 2026
6d570e5
update validation requiremtns on lines 36-41
AngelaMcLeary Apr 9, 2026
ff6b347
fix formatting issues in submit and render functions
AngelaMcLeary Apr 9, 2026
376af2f
update input type for title and author
AngelaMcLeary Apr 10, 2026
1d6d91b
update improper meta tag
AngelaMcLeary Apr 11, 2026
366d541
update html tag to include language
AngelaMcLeary Apr 11, 2026
957ce0b
update remove empty rows
AngelaMcLeary Apr 11, 2026
b6bb86f
update scripts to include defer
AngelaMcLeary Apr 11, 2026
c87d77d
update add form element for user data input
AngelaMcLeary Apr 12, 2026
89af4d0
update to remove onclick submit from html
AngelaMcLeary Apr 12, 2026
1a97cd5
update to fix remove form and onclick
AngelaMcLeary Apr 12, 2026
6822947
update to remove invalid css in form-group
AngelaMcLeary Apr 12, 2026
5350f6e
update code to clear fields after submission
AngelaMcLeary Apr 12, 2026
9228c2f
update main container in html
AngelaMcLeary Apr 12, 2026
5062215
update css to meet accessibility requirements
AngelaMcLeary Apr 12, 2026
10ae61f
update spacing for form
AngelaMcLeary Apr 12, 2026
ece0823
update css for h1, h2 and update changeBut and deleteBut to ..Btn
AngelaMcLeary Apr 12, 2026
6b1fb53
update let to const for myLibrary variable
AngelaMcLeary Apr 12, 2026
380c723
update variable delbut to deleteBtn
AngelaMcLeary Apr 12, 2026
820a4e1
update converted page number from string to number
AngelaMcLeary Apr 13, 2026
f170475
update submit function to handle page as numbers and fix validation c…
AngelaMcLeary Apr 13, 2026
94388ba
update if staement and use tenary operator
AngelaMcLeary Apr 13, 2026
eb6981c
update unneccessay code changeBtn.id and deleteBtn.id
AngelaMcLeary Apr 13, 2026
adfb8c0
update remove index parameter from deleteBtn.addEventListener
AngelaMcLeary Apr 13, 2026
d53e21d
update change order of operation for delete alert
AngelaMcLeary Apr 13, 2026
e4c4826
update html to at toast div
AngelaMcLeary Apr 13, 2026
e29da34
update function for toast when item is deleted
AngelaMcLeary Apr 13, 2026
d89ea46
update alert message with function call
AngelaMcLeary Apr 13, 2026
6fff30c
update toast css and change show to visible
AngelaMcLeary Apr 13, 2026
eab8a1f
update toast style in css, remove inline style in jumbotron
AngelaMcLeary Apr 13, 2026
851e2ce
update style text in alert
AngelaMcLeary Apr 13, 2026
4e49d1d
update toast style
AngelaMcLeary Apr 13, 2026
c96752d
update formatting with prettier
AngelaMcLeary Apr 13, 2026
dc383b1
update validation and and trim inputs
AngelaMcLeary Apr 14, 2026
2474cd9
update to prevent HTML injection issues
AngelaMcLeary Apr 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debugging/book-library/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title> </title>
<title>Book Library</title>
<meta
charset="utf-8"
name="viewport"
Expand Down
22 changes: 13 additions & 9 deletions debugging/book-library/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ function submit() {
if (
title.value == null ||
title.value == "" ||
author.value == null ||
Comment thread
AngelaMcLeary marked this conversation as resolved.
Outdated
author.value == "" ||
pages.value == null ||
pages.value == ""
pages.value == "" ||
pages.value <= 0 ||
pages.value != parseInt()
) {
alert("Please fill all fields!");
alert("Please fill all fields with valid input!");
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Using raw input value without properly pre-processing them is dangerous.

Here are some input that can "mess up" the app:

 title.value = "                       ";
 page.value = "3e-2";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you address this comment? Currently some input values can still "mess up" the app.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @cjyuan, Thank you for your feed back. I’ve updated the validation. I now trim all input values before checking them, and I added a stricter regex (/^[1-9]\d*$/) for the pages field so it only accepts whole positive numbers without leading zeros. This prevents unsafe or misleading inputs like " " or "3e-2" from being treated as valid. Thanks for the heads‑up!

myLibrary.push(book);
render();
}
}
Expand All @@ -54,7 +58,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);
}
//insert updated row and cells
Expand All @@ -77,9 +81,9 @@ function render() {
wasReadCell.appendChild(changeBut);
let readStatus = "";
if (myLibrary[i].check == false) {
readStatus = "Yes";
} else {
readStatus = "No";
} else {
readStatus = "Yes";
}
changeBut.innerText = readStatus;

Expand All @@ -89,12 +93,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";
delBut.addEventListener("clicks", function () {
delBut.addEventListener("click", function (index) {
alert(`You've deleted title: ${myLibrary[i].title}`);
myLibrary.splice(i, 1);
render();
Comment thread
AngelaMcLeary marked this conversation as resolved.
Outdated
Expand Down
Loading