From d7e7b4c954ca733135bda1a2bccde2af14f645de Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 17:47:07 +0100 Subject: [PATCH 1/7] fix error in render function for loo closing missing closing bracket --- 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 75ce6c1d..222d0b76 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -1,5 +1,5 @@ let myLibrary = []; - +it window.addEventListener("load", function (e) { populateStorage(); render(); @@ -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 11e500e7c6063c51b7ec3bfdec3880e682efff97 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 19:15:19 +0100 Subject: [PATCH 2/7] update delete button --- debugging/book-library/script.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 222d0b76..21e79ebf 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -1,5 +1,4 @@ let myLibrary = []; -it window.addEventListener("load", function (e) { populateStorage(); render(); @@ -38,7 +37,7 @@ function submit() { return false; } else { let book = new Book(title.value, title.value, pages.value, check.checked); - library.push(book); + myLibrary.push(book); render(); } } @@ -89,7 +88,7 @@ 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"; @@ -101,3 +100,18 @@ function render() { }); } } +// My website should be able to: + +// - View a list of books that I've read +// - Add books to a list of books that I've read +// - Including title, author, number of pages and if I've read it +// - If any of the information is missing it shouldn't add the book and should show an alert +// - Remove books from my list + +// ## Bugs to be fixed + +// 1. Website loads but doesn't show any books +// 2. Error in console when you try to add a book +// 3. It uses the title name as the author name +// 4. Delete button is broken +// 5. When I add a book that I say I've read - it saves the wrong answer \ No newline at end of file From de9d89d280d60bb2fd874de45fb9e66cff2f9ff0 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 20:55:46 +0100 Subject: [PATCH 3/7] update add book function and inputs --- debugging/book-library/index.html | 2 +- debugging/book-library/script.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71..e24a68f3 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -65,7 +65,7 @@

Library

type="submit" value="Submit" class="btn btn-primary" - onclick="submit();" + id ="submit-btn" /> diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 21e79ebf..2c35bb52 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -15,7 +15,6 @@ function populateStorage() { ); myLibrary.push(book1); myLibrary.push(book2); - render(); } } @@ -23,6 +22,12 @@ const title = document.getElementById("title"); const author = document.getElementById("author"); const pages = document.getElementById("pages"); const check = document.getElementById("check"); +const submitBtn = document.getElementById("submit-btn"); + +submitBtn.addEventListener("click", function (event) { + event.preventDefault(); + submit(); +}); //check the right input from forms and if its ok -> add the new book (object in array) //via Book function and start render function @@ -36,7 +41,7 @@ function submit() { alert("Please fill all fields!"); return false; } else { - let book = new Book(title.value, title.value, pages.value, check.checked); + let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); } @@ -55,7 +60,7 @@ function render() { //delete old table for (let n = rowsNumber - 1; n > 0; n--){ table.deleteRow(n); - } + } //insert updated row and cells let length = myLibrary.length; for (let i = 0; i < length; i++) { @@ -110,7 +115,7 @@ function render() { // ## Bugs to be fixed -// 1. Website loads but doesn't show any books +// 1. Website loads but doesn't show any books => fixed // 2. Error in console when you try to add a book // 3. It uses the title name as the author name // 4. Delete button is broken From 3dadc55f78fa39a9b252720f0bb2844aa4c32133 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 21:35:49 +0100 Subject: [PATCH 4/7] fixed delete button --- 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 2c35bb52..31ec0fd4 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -81,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; @@ -98,7 +98,7 @@ function render() { deleteCell.appendChild(delBut); delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delBut.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); @@ -116,7 +116,7 @@ function render() { // ## Bugs to be fixed // 1. Website loads but doesn't show any books => fixed -// 2. Error in console when you try to add a book -// 3. It uses the title name as the author name -// 4. Delete button is broken -// 5. When I add a book that I say I've read - it saves the wrong answer \ No newline at end of file +// 2. Error in console when you try to add a book => fixed +// 3. It uses the title name as the author name => fixed +// 4. Delete button is broken =>git +// 5. When I add a book that I say I've read - it saves the wrong answer => \ No newline at end of file From 9fb77a91e8f2ff8478f497b30d537693bdc99d04 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 21:37:23 +0100 Subject: [PATCH 5/7] removed unused comment --- debugging/book-library/script.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 31ec0fd4..9537130d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -105,18 +105,3 @@ function render() { }); } } -// My website should be able to: - -// - View a list of books that I've read -// - Add books to a list of books that I've read -// - Including title, author, number of pages and if I've read it -// - If any of the information is missing it shouldn't add the book and should show an alert -// - Remove books from my list - -// ## Bugs to be fixed - -// 1. Website loads but doesn't show any books => fixed -// 2. Error in console when you try to add a book => fixed -// 3. It uses the title name as the author name => fixed -// 4. Delete button is broken =>git -// 5. When I add a book that I say I've read - it saves the wrong answer => \ No newline at end of file From da350c1b05e012bd77dcc1db519b2fb3838225ea Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 22:06:37 +0100 Subject: [PATCH 6/7] unco changes in html --- debugging/book-library/script.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 9537130d..a8b24945 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -105,3 +105,21 @@ function render() { }); } } +<<<<<<< HEAD +======= +// My website should be able to: + +// - View a list of books that I've read +// - Add books to a list of books that I've read +// - Including title, author, number of pages and if I've read it +// - If any of the information is missing it shouldn't add the book and should show an alert +// - Remove books from my list + +// ## Bugs to be fixed + +// 1. Website loads but doesn't show any books => fixed +// 2. Error in console when you try to add a book => fixed +// 3. It uses the title name as the author name => fixed +// 4. Delete button is broken =>git +// 5. When I add a book that I say I've read - it saves the wrong answer => +>>>>>>> c637046 (unco changes in html) From 2132c95b8f03a4960604cb1e437d4973ec040b62 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 15 Apr 2026 22:56:11 +0100 Subject: [PATCH 7/7] removed unused comment --- debugging/book-library/script.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index a8b24945..c7da752c 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -105,21 +105,4 @@ function render() { }); } } -<<<<<<< HEAD -======= -// My website should be able to: -// - View a list of books that I've read -// - Add books to a list of books that I've read -// - Including title, author, number of pages and if I've read it -// - If any of the information is missing it shouldn't add the book and should show an alert -// - Remove books from my list - -// ## Bugs to be fixed - -// 1. Website loads but doesn't show any books => fixed -// 2. Error in console when you try to add a book => fixed -// 3. It uses the title name as the author name => fixed -// 4. Delete button is broken =>git -// 5. When I add a book that I say I've read - it saves the wrong answer => ->>>>>>> c637046 (unco changes in html)