From 02e7240a3c73681da155b2941bd2052c8c233b7d Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 10:58:43 +0100 Subject: [PATCH 01/10] updated title to say Quote Generator --- Sprint-3/quote-generator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..18efacb07 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,7 +3,7 @@ - Title here + Quote Generator From 8dea4a5045cb988504c948eae15043fb379c8cd4 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:17:32 +0100 Subject: [PATCH 02/10] Add displayRandomQuote function and Implemented DOM elements to the function --- Sprint-3/quote-generator/quotes.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..42455ddd9 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -491,3 +491,12 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote +// console.log(pickFromArray(quotes)) + +// function to display random quote on the page +function displayRandomQuote(){ + + // get the html ID elements where we want to show author's name and quote's +const authorElements = document.getElementsById("author"); +const quoteElements = document.getElementsById("quotes") +} \ No newline at end of file From f56b4a4329a209e8d993271e1460aaf279ea5121 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:22:30 +0100 Subject: [PATCH 03/10] Implement random quote selection in displayRandomQuote function --- Sprint-3/quote-generator/quotes.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 42455ddd9..2fc981c4d 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -499,4 +499,7 @@ function displayRandomQuote(){ // get the html ID elements where we want to show author's name and quote's const authorElements = document.getElementsById("author"); const quoteElements = document.getElementsById("quotes") + +// use the "pickFromArray()" function to pick one quote randomly from the array to display each time it runs +const randomQuote = pickfromArray(quotes); } \ No newline at end of file From f22b46f8317e70342c57df95d5e8ce2e0d59e67d Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:29:29 +0100 Subject: [PATCH 04/10] Update quote display logic to show selected quote and author --- Sprint-3/quote-generator/quotes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 2fc981c4d..0585c28ad 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -502,4 +502,8 @@ const quoteElements = document.getElementsById("quotes") // use the "pickFromArray()" function to pick one quote randomly from the array to display each time it runs const randomQuote = pickfromArray(quotes); + +// update the display with the selected author and quote by setting the text into there html elements +quoteElements.textcontext = randomQuote.quote; +authorElements.textcontext = randomQuote.author; } \ No newline at end of file From 273486dd0a79c67e2495fe1e1b00962d90be151e Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:33:51 +0100 Subject: [PATCH 05/10] Fix typo in property names for quote and author display --- Sprint-3/quote-generator/quotes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 0585c28ad..1e1ee6391 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -504,6 +504,6 @@ const quoteElements = document.getElementsById("quotes") const randomQuote = pickfromArray(quotes); // update the display with the selected author and quote by setting the text into there html elements -quoteElements.textcontext = randomQuote.quote; -authorElements.textcontext = randomQuote.author; +quoteElements.textcontent = randomQuote.quote; +authorElements.textcontent = randomQuote.author; } \ No newline at end of file From d6f3e7257f643077988f3c583d0dca026cabd4ca Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:35:09 +0100 Subject: [PATCH 06/10] fixed typo in const randomQuote --- Sprint-3/quote-generator/quotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 1e1ee6391..f4090a012 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -501,7 +501,7 @@ const authorElements = document.getElementsById("author"); const quoteElements = document.getElementsById("quotes") // use the "pickFromArray()" function to pick one quote randomly from the array to display each time it runs -const randomQuote = pickfromArray(quotes); +const randomQuote = pickFromArray(quotes); // update the display with the selected author and quote by setting the text into there html elements quoteElements.textcontent = randomQuote.quote; From 92652f0992e63c8bd677fb536b62fe959a7f94e6 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:36:20 +0100 Subject: [PATCH 07/10] fixed typo in quoteElements ID --- Sprint-3/quote-generator/quotes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index f4090a012..dd2741a7d 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -498,7 +498,7 @@ function displayRandomQuote(){ // get the html ID elements where we want to show author's name and quote's const authorElements = document.getElementsById("author"); -const quoteElements = document.getElementsById("quotes") +const quoteElements = document.getElementsById("quote") // use the "pickFromArray()" function to pick one quote randomly from the array to display each time it runs const randomQuote = pickFromArray(quotes); From d8e4d625734157d0d9eb75825cb4d4287ef6b8e9 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Thu, 17 Jul 2025 14:38:52 +0100 Subject: [PATCH 08/10] Fix typos in getElementsById and textcontent properties in displayRandomQuote function --- Sprint-3/quote-generator/quotes.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index dd2741a7d..80100843a 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -497,13 +497,13 @@ const quotes = [ function displayRandomQuote(){ // get the html ID elements where we want to show author's name and quote's -const authorElements = document.getElementsById("author"); -const quoteElements = document.getElementsById("quote") +const authorElements = document.getElementById("author"); +const quoteElements = document.getElementById("quote") // use the "pickFromArray()" function to pick one quote randomly from the array to display each time it runs const randomQuote = pickFromArray(quotes); // update the display with the selected author and quote by setting the text into there html elements -quoteElements.textcontent = randomQuote.quote; -authorElements.textcontent = randomQuote.author; +quoteElements.textContent = randomQuote.quote; +authorElements.textContent = randomQuote.author; } \ No newline at end of file From f3dac2dc032d336b5759e0eaa5e4533255b4dfc2 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 19 Jul 2025 13:59:11 +0100 Subject: [PATCH 09/10] Add event listener for DOMContentLoaded to initialize quote button functionality --- Sprint-3/quote-generator/quotes.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 80100843a..aec7c2bac 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -506,4 +506,9 @@ const randomQuote = pickFromArray(quotes); // update the display with the selected author and quote by setting the text into there html elements quoteElements.textContent = randomQuote.quote; authorElements.textContent = randomQuote.author; -} \ No newline at end of file +} +// use "DOMContentloaded" to ensure all html elements are loaded before updating the DOM to prevent returning null +document.addEventListener("DOMContentLoaded", function(){ + const newQuoteButton = document.getElementById("new-quote"); // gets the html element for the button new-quote + newQuoteButton.addEventListener("click", displayRandomQuote); // shows a a random new quote each time the buttons clicked +}); \ No newline at end of file From 628a2dd578aa0184fb4df67829c8bd6270665486 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 19 Jul 2025 14:14:28 +0100 Subject: [PATCH 10/10] Add displayRandomQuote call on DOMContentLoaded to show a random quote on page load --- Sprint-3/quote-generator/quotes.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index aec7c2bac..74ffdc8be 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -509,6 +509,9 @@ authorElements.textContent = randomQuote.author; } // use "DOMContentloaded" to ensure all html elements are loaded before updating the DOM to prevent returning null document.addEventListener("DOMContentLoaded", function(){ + + displayRandomQuote(); // calls a random quote on page load + const newQuoteButton = document.getElementById("new-quote"); // gets the html element for the button new-quote newQuoteButton.addEventListener("click", displayRandomQuote); // shows a a random new quote each time the buttons clicked }); \ No newline at end of file