From aae4c91761b6a5f238607233a58ae3fc8b820212 Mon Sep 17 00:00:00 2001 From: hailia sommerville Date: Fri, 20 Jun 2025 14:19:16 -0400 Subject: [PATCH 1/5] rows added - resolves 1 --- main.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.js b/main.js index 79a0fd1..8e1af91 100644 --- a/main.js +++ b/main.js @@ -5,3 +5,19 @@ root.addEventListener("click", (event) => { console.log(event.target.tagName); console.log(event.target); }); + +let table = document.querySelector("TABLE") +const addRowBtn = document.getElementById("add-row") +let rows = document.getElementsByTagName("TR") +let tdCount = rows[0].querySelectorAll("TD").length + +addRowBtn.addEventListener("click", function addRow(){ + let newRow = document.createElement("TR") + + for (let i = 0; i < tdCount; i++) + newRow.appendChild(document.createElement("TD")) + + table.appendChild(newRow) + +}) + From 1a692e5f3eab6bb978334a5cdf939c278e917cb7 Mon Sep 17 00:00:00 2001 From: BTBurton1 <128549369+BTBurton1@users.noreply.github.com> Date: Fri, 20 Jun 2025 15:03:23 -0400 Subject: [PATCH 2/5] Added script.js with the fillUnclrdCells function --- script.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 script.js diff --git a/script.js b/script.js new file mode 100644 index 0000000..fbcbf9b --- /dev/null +++ b/script.js @@ -0,0 +1,11 @@ +function fillUnclrdCells(){ + console.log("🟡 fillUnclrdCells triggered"); + const cells = document.querySelectorAll("td"); + const selectedClr = document.getElementById("colorSelector").value; + + cells.forEach(cell=>{ + if(!cell.style.backgroundColor||cell.style.backgroundColor === "white" ){ + cell.style.backgroundColor = selectedClr; + } + }); +} From c0aac7c5130a08ff64f063480361f3db129a42ee Mon Sep 17 00:00:00 2001 From: BTBurton1 <128549369+BTBurton1@users.noreply.github.com> Date: Fri, 20 Jun 2025 15:09:59 -0400 Subject: [PATCH 3/5] Update script.js added its event listener code --- script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script.js b/script.js index fbcbf9b..eea3521 100644 --- a/script.js +++ b/script.js @@ -9,3 +9,4 @@ function fillUnclrdCells(){ } }); } +document.getElementById("fill-grid").addEventListener("click", fillUnclrdCells); From 8ce81f78f95b18e826443a078ff6fb048b57ddf3 Mon Sep 17 00:00:00 2001 From: BTBurton1 <128549369+BTBurton1@users.noreply.github.com> Date: Fri, 20 Jun 2025 15:16:51 -0400 Subject: [PATCH 4/5] Deleted script.js so it doesnt conflict with main.js --- script.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 script.js diff --git a/script.js b/script.js deleted file mode 100644 index eea3521..0000000 --- a/script.js +++ /dev/null @@ -1,12 +0,0 @@ -function fillUnclrdCells(){ - console.log("🟡 fillUnclrdCells triggered"); - const cells = document.querySelectorAll("td"); - const selectedClr = document.getElementById("colorSelector").value; - - cells.forEach(cell=>{ - if(!cell.style.backgroundColor||cell.style.backgroundColor === "white" ){ - cell.style.backgroundColor = selectedClr; - } - }); -} -document.getElementById("fill-grid").addEventListener("click", fillUnclrdCells); From 7cca2815c713b19195d90ee74d78b9de1656c471 Mon Sep 17 00:00:00 2001 From: BTBurton1 <128549369+BTBurton1@users.noreply.github.com> Date: Fri, 20 Jun 2025 15:17:52 -0400 Subject: [PATCH 5/5] Updated main.js to have the fillunclrdcells function --- main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.js b/main.js index 8e1af91..ae9772c 100644 --- a/main.js +++ b/main.js @@ -20,4 +20,16 @@ addRowBtn.addEventListener("click", function addRow(){ table.appendChild(newRow) }) +function fillUnclrdCells(){ + console.log("🟡 fillUnclrdCells triggered"); + const cells = document.querySelectorAll("td"); + const selectedClr = document.getElementById("colorSelector").value; + + cells.forEach(cell=>{ + if(!cell.style.backgroundColor||cell.style.backgroundColor === "white" ){ + cell.style.backgroundColor = selectedClr; + } + }); +} +document.getElementById("fill-grid").addEventListener("click", fillUnclrdCells);