From 3193f1ea99b8fb2a87f848194ef31c262590e644 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 11:32:54 +0100 Subject: [PATCH 1/9] Fix syntax error in render function for loop, missing parentheses --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 75ce6c1d..eed706fd 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -54,7 +54,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 From 7f89e337955cabececc793b87256dddb486039da Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 12:26:59 +0100 Subject: [PATCH 2/9] Fix book submission logic and correct delete button event listener --- debugging/book-library/script.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index eed706fd..b2a942be 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,8 +37,8 @@ function submit() { 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); + myLibrary.push(book); render(); } } @@ -90,11 +90,11 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); - delBut.id = i + 5; - deleteCell.appendChild(delBut); - delBut.className = "btn btn-warning"; - delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delButton.id = i + 5; + deleteCell.appendChild(delButton); + delButton.className = "btn btn-warning"; + delButton.innerHTML = "Delete"; + delButton.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From 16e23180b0c87284755929d2283b3bda3a3c9bf6 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 12:31:36 +0100 Subject: [PATCH 3/9] Fix book submission to correctly use checkbox value. Read Yes/No --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index b2a942be..1a1ad240 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,7 +37,7 @@ function submit() { alert("Please fill all fields!"); return false; } else { - let book = new Book(title.value, author.value, pages.value, check.checked); + let book = new Book(title.value, author.value, pages.value, check.value); myLibrary.push(book); render(); } From 666c3c907e7c46188931698b464c0e6d37300789 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 12:44:38 +0100 Subject: [PATCH 4/9] Fix book submission to use checkbox checked property and update read status logic --- debugging/book-library/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 1a1ad240..7e845516 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,7 +37,7 @@ function submit() { alert("Please fill all fields!"); return false; } else { - let book = new Book(title.value, author.value, pages.value, check.value); + let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); } @@ -76,7 +76,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"; From fd972c4d2f04ca85e1628e7a9d85beb20d4ba98c Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 12:57:18 +0100 Subject: [PATCH 5/9] Fix book submission validation to ensure author field is checked --- debugging/book-library/script.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7e845516..01cec616 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -31,6 +31,8 @@ function submit() { if ( title.value == null || title.value == "" || + author.value == null || + author.value == "" || pages.value == null || pages.value == "" ) { From 3046928cbc7bc0aba25d07f8aed86db56fb01036 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 13:00:39 +0100 Subject: [PATCH 6/9] Fix form submission to clear input fields after adding a new book --- debugging/book-library/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 01cec616..b4201fe2 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -43,6 +43,12 @@ function submit() { myLibrary.push(book); render(); } + + // clear the form after submit + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; } function Book(title, author, pages, check) { From c36a497fea8b50e3882fc2539aa9b4c8882d8c74 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 13:03:26 +0100 Subject: [PATCH 7/9] Fix HTML structure and input types in book submission form --- debugging/book-library/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71..8028b55a 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ - + - + My Book Library Library
Library /> Library type="submit" value="Submit" class="btn btn-primary" - onclick="submit();" + onclick="submit()" />
From bdf03b22b680946f9438143b267388564b411a4f Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Sat, 11 Apr 2026 14:03:50 +0100 Subject: [PATCH 8/9] Add cSpell configuration to recognize custom word "Robison" --- debugging/book-library/.vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 debugging/book-library/.vscode/settings.json diff --git a/debugging/book-library/.vscode/settings.json b/debugging/book-library/.vscode/settings.json new file mode 100644 index 00000000..da2a0bdb --- /dev/null +++ b/debugging/book-library/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cSpell.words": ["Robison"] +} From dd1846f640fa7256e530c49e7917bed527cf6981 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Mon, 13 Apr 2026 14:17:01 +0100 Subject: [PATCH 9/9] Refactor HTML structure for improved semantics and consistency --- debugging/book-library/index.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 8028b55a..b9f1e43b 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,12 +1,9 @@ - + My Book Library - + +