From 6fe2b67ff1544deebef05eaa437fa466208dea5c Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:08:47 +0100 Subject: [PATCH 01/41] missing bracket closure on line 57 --- 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..7f21dc1d 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 b64750655c20f9a8c0c1c151a8257ac54e439da4 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:14:37 +0100 Subject: [PATCH 02/41] fix syntax error on line 92 update variable --- 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 7f21dc1d..4f12dff8 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -89,7 +89,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"; From dc2969c7eeeeae1e7d6148636b0add2c2ec2f14b Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:16:09 +0100 Subject: [PATCH 03/41] add title to html file --- debugging/book-library/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71..b0705971 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ - + Book Library Date: Thu, 9 Apr 2026 19:22:20 +0100 Subject: [PATCH 04/41] update variable name to myLibrary on Line 41 --- 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 4f12dff8..7f71a0db 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -38,7 +38,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(); } } From 731ac4ccba6ea1c76516abb6f9012b8c00e872d7 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:33:43 +0100 Subject: [PATCH 05/41] return of author value on line 40 to allow correct output --- 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 7f71a0db..9298fba4 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, title.value, pages.value, check.checked); + let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); } From 377bd2401d622b367f049949ed7860518cd41a82 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:47:58 +0100 Subject: [PATCH 06/41] fix typo change click to clicks on line 92 --- 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 9298fba4..8ea75080 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -94,7 +94,7 @@ function render() { 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(); From 200d98c36adbb5fd18ea69e52f2d33ec00c228ff Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 19:53:19 +0100 Subject: [PATCH 07/41] fix result of input status of book when read is selected to YES line 80 and 82 --- 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 8ea75080..15684f71 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -77,9 +77,9 @@ function render() { wasReadCell.appendChild(changeBut); let readStatus = ""; if (myLibrary[i].check == false) { - readStatus = "Yes"; - } else { readStatus = "No"; + } else { + readStatus = "Yes"; } changeBut.innerText = readStatus; From 6d570e53a43440fef683088f79f73b70f0176119 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 20:04:40 +0100 Subject: [PATCH 08/41] update validation requiremtns on lines 36-41 --- debugging/book-library/script.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 15684f71..c5325596 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -31,10 +31,14 @@ function submit() { if ( title.value == null || title.value == "" || + author.value == null || + 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, author.value, pages.value, check.checked); From ff6b3473e77d5ddb98bf5af5e8c23320936213b1 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Thu, 9 Apr 2026 20:11:57 +0100 Subject: [PATCH 09/41] fix formatting issues in submit and render functions --- 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 c5325596..a3f5b6d1 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -36,7 +36,7 @@ function submit() { pages.value == null || pages.value == "" || pages.value <= 0 || - pages.value != parseInt() + pages.value != parseInt() ) { alert("Please fill all fields with valid input!"); return false; @@ -58,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 From 376af2fb9c4a65c4c8f65a81505862629b70cf2a Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Fri, 10 Apr 2026 12:30:51 +0100 Subject: [PATCH 10/41] update input type for title and author --- debugging/book-library/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index b0705971..d7a143f1 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,4 +1,4 @@ - + Book Library @@ -31,7 +31,7 @@

Library

Library /> Library type="submit" value="Submit" class="btn btn-primary" - onclick="submit();" + onclick="submit()" />
From 1d6d91b6c0a8d6aa83762de240eceb6964c4ff7c Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sat, 11 Apr 2026 07:36:09 +0100 Subject: [PATCH 11/41] update improper meta tag --- debugging/book-library/index.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index d7a143f1..e300b51d 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,12 +1,11 @@ - + Book Library - + + + + @@ -20,7 +19,7 @@

Library

-

Add books to your virtual library

+

Add books to your virtual library

+ +
+

Library

+

Add books to your virtual library

+
-
+ + +
+
- + - + - + - +
-
+ +
+ + + + + + + + + + + + +
TitleAuthorNumber of PagesRead
- - - - - - - - - - - -
TitleAuthorNumber of PagesRead
+ + - - - + \ No newline at end of file From 89af4d02a4dbe7b28d5bceb5817c504f36ba1bde Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 13:08:43 +0100 Subject: [PATCH 16/41] update to remove onclick submit from html --- debugging/book-library/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 8949f9c9..121c69f6 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -25,7 +25,7 @@

Add books to your virtual library

-
+
@@ -36,7 +36,7 @@

Add books to your virtual library

- +
From 1a97cd55187f99ed209d2a398d13afe1381eddc8 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 14:37:53 +0100 Subject: [PATCH 17/41] update to fix remove form and onclick --- debugging/book-library/index.html | 44 ++++++++++++++++--------------- debugging/book-library/script.js | 16 +++++------ 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 121c69f6..3f559525 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,15 +1,15 @@ - + Book Library - - - - + + + + @@ -17,7 +17,7 @@

Library

-

Add books to your virtual library

+

Add books to your virtual library

-
-
- - - - - - - - -
-
+
+ + + + + + + + + + + + + + +
@@ -54,7 +56,7 @@

Add books to your virtual library

- + \ No newline at end of file diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index a3f5b6d1..11c1c7fc 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -7,7 +7,7 @@ window.addEventListener("load", function (e) { function populateStorage() { if (myLibrary.length == 0) { - let book1 = new Book("Robison Crusoe", "Daniel Defoe", "252", true); + let book1 = new Book("Robinson Crusoe", "Daniel Defoe", "252", true); let book2 = new Book( "The Old Man and the Sea", "Ernest Hemingway", @@ -30,13 +30,13 @@ const check = document.getElementById("check"); function submit() { if ( title.value == null || - title.value == "" || - author.value == null || - author.value == "" || - pages.value == null || - pages.value == "" || - pages.value <= 0 || - pages.value != parseInt() + title.value == "" || + author.value == null || + author.value == "" || + pages.value == null || + pages.value == "" || + parseInt(pages.value) <= 0 || + isNaN(parseInt(pages.value)) ) { alert("Please fill all fields with valid input!"); return false; From 682294760b91bf640577612691658e6c3a71e519 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 14:39:19 +0100 Subject: [PATCH 18/41] update to remove invalid css in form-group --- debugging/book-library/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 302950cb..39ce176f 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -1,7 +1,6 @@ .form-group { width: 400px; height: 300px; - align-self: left; padding-left: 20px; } From 5350f6e96fe64ca4a5c3efc60ba2c9f8f8e27b6c Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 15:03:03 +0100 Subject: [PATCH 19/41] update code to clear fields after submission --- debugging/book-library/index.html | 104 ++++++++++++++++-------------- debugging/book-library/script.js | 20 ++++-- 2 files changed, 68 insertions(+), 56 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 3f559525..3658510f 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,62 +1,68 @@ - + + + Book Library + + - - Book Library - - + + + - - - + + + - - - - - -
-

Library

-

Add books to your virtual library

-
+ +
+

Library

+

Add books to your virtual library

+
- + -
-
- - +
+
+ + - - + + - - + + - - + + - - + + +
-
- - - - - - - - - - - - -
TitleAuthorNumber of PagesRead
- - - + + + + + + + + + + + +
TitleAuthorNumber of PagesRead
+ + + \ No newline at end of file diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 11c1c7fc..5daf7cc7 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -30,13 +30,13 @@ const check = document.getElementById("check"); function submit() { if ( title.value == null || - title.value == "" || - author.value == null || - author.value == "" || - pages.value == null || - pages.value == "" || - parseInt(pages.value) <= 0 || - isNaN(parseInt(pages.value)) + title.value == "" || + author.value == null || + author.value == "" || + pages.value == null || + pages.value == "" || + parseInt(pages.value) <= 0 || + isNaN(parseInt(pages.value)) ) { alert("Please fill all fields with valid input!"); return false; @@ -44,6 +44,12 @@ function submit() { let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); + + //clears the form for new entries + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; } } From 9228c2f1881980e94475c8f84bdfd59704cb86e1 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 18:09:30 +0100 Subject: [PATCH 20/41] update main container in html --- debugging/book-library/index.html | 79 ++++++++++++++++--------------- debugging/book-library/style.css | 33 +++++++++++++ 2 files changed, 73 insertions(+), 39 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 3658510f..65b4b88f 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -17,52 +17,53 @@ -
-

Library

-

Add books to your virtual library

-
+
+
+

Library

+

Add books to your virtual library

+
- + -
-
- - +
+
+ + - - + + - - + + - - + + - - + + +
-
- - - - - - - - - - - - -
TitleAuthorNumber of PagesRead
+ + + + + + + + + + + +
TitleAuthorNumber of PagesRead
+
- \ No newline at end of file + diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 39ce176f..d35215c5 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -7,6 +7,10 @@ .btn { display: block; } +.form-control { + border-style: solid; + border-color: lightslategrey; +} .form-check-label { padding-left: 20px; @@ -14,5 +18,34 @@ } button.btn-info { + background-color: blue; + border-color: blue; + color: #fff; margin: 20px; } + +.btn-success { + background-color: #0d4a0d; + border-color: #0d4a0d; + color: #fff; +} + +.btn-success:hover, +.btn-success:focus { + background-color: #1f6e1f; + border-color: #1f6e1f; + color: #fff; +} + +.btn-warning { + background-color: #9f6000; + border-color: #9f6000; + color: #fff; +} + +.btn-warning:hover, +.btn-warning:focus { + background-color: #b76e01; + border-color: #b76e01; + color: #fff; +} From 5062215f06291fdb6ff68c3c4f381089f4735ee7 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 18:10:45 +0100 Subject: [PATCH 21/41] update css to meet accessibility requirements --- debugging/book-library/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index d35215c5..ee50fd18 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -7,6 +7,7 @@ .btn { display: block; } + .form-control { border-style: solid; border-color: lightslategrey; From 10ae61fb0c689f5a79da3305766f5c2ceabd4431 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 18:30:22 +0100 Subject: [PATCH 22/41] update spacing for form --- debugging/book-library/style.css | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index ee50fd18..8381be2a 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -1,7 +1,12 @@ +.jumbotron { + padding: 1.5rem 2rem; + margin-bottom: 1rem; +} + .form-group { width: 400px; height: 300px; - padding-left: 20px; + padding-left: 50px; } .btn { From ece0823a207fb15f10ca0197c781333b195f5660 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Sun, 12 Apr 2026 19:18:01 +0100 Subject: [PATCH 23/41] update css for h1, h2 and update changeBut and deleteBut to ..Btn --- debugging/book-library/index.html | 2 +- debugging/book-library/script.js | 24 ++++++++++++------------ debugging/book-library/style.css | 15 +++++++++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 65b4b88f..424a6e83 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -20,7 +20,7 @@

Library

-

Add books to your virtual library

+

Add books to your virtual library

From e29da3471be6ced9b924d64b017dd59ed239cb97 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 15:30:21 +0100 Subject: [PATCH 33/41] update function for toast when item is deleted --- debugging/book-library/script.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index ba84529d..7593112c 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -61,7 +61,15 @@ function Book(title, author, pages, check) { this.pages = Number(pages); this.check = check; } +function alertDeleteToast(message) { + const toast = document.getElementById("toast"); + toast.textContent = message; + toast.classList.add("show"); + setTimeout(() => { + toast.classList.remove("show"); + }, 2000); +} function render() { let table = document.getElementById("display"); let rowsNumber = table.rows.length; From d89ea46ec056b67d76c1b1a81146f739fb0d01a0 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 15:33:42 +0100 Subject: [PATCH 34/41] update alert message with function call --- debugging/book-library/script.js | 2 +- debugging/book-library/style.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7593112c..f1f7e3be 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -113,7 +113,7 @@ function render() { const deleteTitle = myLibrary[i].title; myLibrary.splice(i, 1); render(); - alert(`You've deleted title: ${deleteTitle}`); + alertDeleteToast(`You've deleted title: ${deleteTitle}`); }); } } diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 5dd0767f..208d531c 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -66,3 +66,4 @@ border-color: #b76e01; color: #fff; } + From 6fff30cde1545a3db1c0119f67145fd9283b0f5e Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 15:46:43 +0100 Subject: [PATCH 35/41] update toast css and change show to visible --- debugging/book-library/script.js | 4 ++-- debugging/book-library/style.css | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index f1f7e3be..58711b7b 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -64,10 +64,10 @@ function Book(title, author, pages, check) { function alertDeleteToast(message) { const toast = document.getElementById("toast"); toast.textContent = message; - toast.classList.add("show"); + toast.classList.add("visible"); setTimeout(() => { - toast.classList.remove("show"); + toast.classList.remove("visible"); }, 2000); } function render() { diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 208d531c..4a2ff721 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -67,3 +67,12 @@ color: #fff; } +.toast{ + opacity: 0; + transition: opacity 0.3s ease; +} + +.toast.visible { + opacity: 1; +} + From eab8a1ff057665a2f36e787932ffc6c26e335427 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 16:07:32 +0100 Subject: [PATCH 36/41] update toast style in css, remove inline style in jumbotron --- debugging/book-library/index.html | 2 +- debugging/book-library/style.css | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index eb4f5104..f72aec74 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -18,7 +18,7 @@
-
+

Library

Add books to your virtual library

diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 4a2ff721..d3076bee 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -1,6 +1,7 @@ .jumbotron { padding: 1.5rem 2rem; margin-bottom: 1rem; + text-align: center; } .jumbotron h2 { @@ -67,9 +68,18 @@ color: #fff; } -.toast{ +.toast { + position: fixed; + top: 120px; + left: 50%; + transform: translateX(-50%); + background: #a84600; + color: white; + padding: 10px 15px; + border-radius: 5px; opacity: 0; transition: opacity 0.3s ease; + pointer-events: none; } .toast.visible { From 851e2ced857c9f7da27265d006ebb46203a9be24 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 16:47:09 +0100 Subject: [PATCH 37/41] update style text in alert --- debugging/book-library/index.html | 3 +-- debugging/book-library/script.js | 6 +++--- debugging/book-library/style.css | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index f72aec74..1d8f771f 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -22,7 +22,7 @@

Library

Add books to your virtual library

- +
@@ -63,7 +63,6 @@

Add books to your virtual library

-
diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 58711b7b..943d9d01 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -63,12 +63,12 @@ function Book(title, author, pages, check) { } function alertDeleteToast(message) { const toast = document.getElementById("toast"); - toast.textContent = message; + toast.innerHTML = message; toast.classList.add("visible"); setTimeout(() => { toast.classList.remove("visible"); - }, 2000); + }, 4000); } function render() { let table = document.getElementById("display"); @@ -113,7 +113,7 @@ function render() { const deleteTitle = myLibrary[i].title; myLibrary.splice(i, 1); render(); - alertDeleteToast(`You've deleted title: ${deleteTitle}`); + alertDeleteToast(`You've deleted title:
${deleteTitle}`); }); } } diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index d3076bee..1d25f14a 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -70,8 +70,9 @@ .toast { position: fixed; - top: 120px; + top: 130px; left: 50%; + font-size: 1rem; transform: translateX(-50%); background: #a84600; color: white; @@ -83,6 +84,7 @@ } .toast.visible { + min-width: 170px; opacity: 1; } From 4e49d1dab1a5992856e273af911856b208961a1a Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 17:01:34 +0100 Subject: [PATCH 38/41] update toast style --- debugging/book-library/style.css | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index 1d25f14a..e782ee41 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -68,6 +68,7 @@ color: #fff; } +/* for delete alert */ .toast { position: fixed; top: 130px; @@ -76,6 +77,11 @@ transform: translateX(-50%); background: #a84600; color: white; + min-width: 300px; + width: fit-content; + white-space: normal; + word-wrap: break-word; + text-align: center; padding: 10px 15px; border-radius: 5px; opacity: 0; @@ -84,7 +90,6 @@ } .toast.visible { - min-width: 170px; opacity: 1; } From c96752da3f47d9f2352681cfb545ab324cdbd625 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Mon, 13 Apr 2026 17:37:58 +0100 Subject: [PATCH 39/41] update formatting with prettier --- debugging/book-library/script.js | 4 +++- debugging/book-library/style.css | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 943d9d01..7bc170c8 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -113,7 +113,9 @@ function render() { const deleteTitle = myLibrary[i].title; myLibrary.splice(i, 1); render(); - alertDeleteToast(`You've deleted title:
${deleteTitle}`); + alertDeleteToast( + `You've deleted title:
${deleteTitle}` + ); }); } } diff --git a/debugging/book-library/style.css b/debugging/book-library/style.css index e782ee41..187711fc 100644 --- a/debugging/book-library/style.css +++ b/debugging/book-library/style.css @@ -92,4 +92,3 @@ .toast.visible { opacity: 1; } - From dc383b112f193c20ebe471f77020fc7a659532aa Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Tue, 14 Apr 2026 21:10:38 +0100 Subject: [PATCH 40/41] update validation and and trim inputs --- debugging/book-library/script.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7bc170c8..de95fe25 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -28,20 +28,24 @@ const check = document.getElementById("check"); //check the right input from forms and if its ok -> add the new book (object in array) //via Book function and start render function function submit() { + const titleValue = title.value.trim(); + const authorValue = author.value.trim(); + const pagesValue = pages.value.trim(); if ( - !title.value || - !author.value || - !pages.value || - Number(pages.value) <= 0 || - Number.isNaN(Number(pages.value)) + !titleValue || + !authorValue || + !pagesValue || + Number(pagesValue) <= 0 || + Number.isNaN(Number(pagesValue)) || + !/^[1-9]\d*$/.test(pagesValue) ) { alert("Please fill all fields with valid input!"); return false; } else { let book = new Book( - title.value, - author.value, - Number(pages.value), + titleValue, + authorValue, + Number(pagesValue), check.checked ); myLibrary.push(book); From 2474cd9876d0ea8af3f193bcd8dfb97f138c2692 Mon Sep 17 00:00:00 2001 From: Angela McLeary Date: Tue, 14 Apr 2026 21:33:07 +0100 Subject: [PATCH 41/41] update to prevent HTML injection issues --- debugging/book-library/script.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index de95fe25..77a6c933 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -65,6 +65,15 @@ function Book(title, author, pages, check) { this.pages = Number(pages); this.check = check; } + +function escapeSpecialCharacters(str) { + return str + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); +} function alertDeleteToast(message) { const toast = document.getElementById("toast"); toast.innerHTML = message; @@ -118,7 +127,7 @@ function render() { myLibrary.splice(i, 1); render(); alertDeleteToast( - `You've deleted title:
${deleteTitle}` + `You've deleted title:
${escapeSpecialCharacters(deleteTitle)}` ); }); }