From 6bc5b4c46b89369bd13ed092d8b5b092ea881a91 Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Sat, 8 Aug 2026 07:25:36 +0100 Subject: [PATCH 01/11] fix errors in html --- debugging/book-library/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71..798c22d5 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ - + Book Library Library
Library /> Date: Sat, 8 Aug 2026 07:44:48 +0100 Subject: [PATCH 02/11] fix: validate author input, correct object property references, and resolve syntax errors in rendering logic --- debugging/book-library/script.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 75ce6c1d..800e9e89 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -31,14 +31,16 @@ function submit() { if ( title.value == null || title.value == "" || + author.value == null || + author.value == "" || pages.value == null || pages.value == "" ) { 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(); } } @@ -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); } //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) { readStatus = "Yes"; } else { readStatus = "No"; @@ -90,11 +92,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 a9c4ad34442053ba2882f3bb2abdb5e5016020af Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Sat, 8 Aug 2026 07:46:04 +0100 Subject: [PATCH 03/11] add clear form inputs after adding a new book to the library --- debugging/book-library/script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 800e9e89..26cfcac9 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -41,6 +41,11 @@ function submit() { } else { let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); + // reset form values + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; render(); } } From 93ff13c981736d3057f49c16976289305d26febd Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Sat, 8 Aug 2026 13:58:57 +0100 Subject: [PATCH 04/11] fix html errors --- debugging/book-library/index.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 798c22d5..d30c03bc 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,12 +1,9 @@ - - + + Book Library - + + @@ -65,7 +62,7 @@

Library

type="submit" value="Submit" class="btn btn-primary" - onclick="submit();" + onclick="submit()" />
From 848ad9c464cbfbaff665a7688df69fb180f28b78 Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Sat, 8 Aug 2026 14:01:33 +0100 Subject: [PATCH 05/11] add required min 1 page value --- debugging/book-library/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index d30c03bc..5fb6b6b0 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -48,6 +48,7 @@

Library

class="form-control" id="pages" name="pages" + min="1" required />