From e7821c6fbc35f0ce61b5f7dd3a90315be6fd0096 Mon Sep 17 00:00:00 2001 From: sheida-shab Date: Thu, 17 Jul 2025 20:46:09 +0100 Subject: [PATCH 1/5] Rename the Title and try to print a qoute on console --- Sprint-3/quote-generator/index.html | 2 +- Sprint-3/quote-generator/quotes.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..5f6a720f1 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,7 +3,7 @@ - Title here + Quote generator app diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..70ae33c36 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -1,3 +1,4 @@ + // DO NOT EDIT BELOW HERE // pickFromArray is a function which will return one item, at @@ -491,3 +492,12 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote +function pickAndDisplayQuote() { + const randomQuote = pickFromArray(quotes); + console.log(randomQuote); +} + +document.getElementById("new-quote").addEventListener("click", () => { + pickAndDisplayQuote(); +}); +window.onload = pickAndDisplayQuote; \ No newline at end of file From 6ef0e31d066daeec63dcf7df5499e592cf70a22a Mon Sep 17 00:00:00 2001 From: sheida-shab Date: Thu, 17 Jul 2025 20:57:05 +0100 Subject: [PATCH 2/5] Showed qiote and autor on screen --- Sprint-3/quote-generator/quotes.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 70ae33c36..54c2c0792 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -494,10 +494,16 @@ const quotes = [ // call pickFromArray with the quotes array to check you get a random quote function pickAndDisplayQuote() { const randomQuote = pickFromArray(quotes); - console.log(randomQuote); + //console.log(randomQuote); + document.getElementById("quote").textContent = randomQuote.quote; + document.getElementById("author").textContent = randomQuote.author; } document.getElementById("new-quote").addEventListener("click", () => { pickAndDisplayQuote(); }); + + + + window.onload = pickAndDisplayQuote; \ No newline at end of file From 3e7629681feb4bc3393ba2cbfb64a05284b077d2 Mon Sep 17 00:00:00 2001 From: sheida-shab Date: Thu, 17 Jul 2025 21:26:02 +0100 Subject: [PATCH 3/5] add checkbox and work with event listener --- Sprint-3/quote-generator/index.html | 1 + Sprint-3/quote-generator/quotes.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 5f6a720f1..c742932b6 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -11,5 +11,6 @@

hello there

+ diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 54c2c0792..c7390426d 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -502,6 +502,11 @@ function pickAndDisplayQuote() { document.getElementById("new-quote").addEventListener("click", () => { pickAndDisplayQuote(); }); +document.getElementById("auto-play").addEventListener("change",(event)=>{ + if (event.target.checked){ + console.log("auto-play is on"); + } +}); From 67bb218e26d9d1ebfbdb7b63619f1cd8e2f6749a Mon Sep 17 00:00:00 2001 From: sheida-shab Date: Thu, 17 Jul 2025 21:37:29 +0100 Subject: [PATCH 4/5] display automatic when check box ticked --- Sprint-3/quote-generator/index.html | 2 +- Sprint-3/quote-generator/quotes.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index c742932b6..ef7d5183d 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -11,6 +11,6 @@

hello there

- + diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index c7390426d..6e5a3097d 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -502,9 +502,12 @@ function pickAndDisplayQuote() { document.getElementById("new-quote").addEventListener("click", () => { pickAndDisplayQuote(); }); + document.getElementById("auto-play").addEventListener("change",(event)=>{ if (event.target.checked){ - console.log("auto-play is on"); + //console.log("auto-play is on"); + document.getElementById("auto-play-label").textContent = "auto-play : ON"; + setInterval(pickAndDisplayQuote,5000); } }); From e2c71043125eb9920e16363ebdeab845e5426628 Mon Sep 17 00:00:00 2001 From: sheida-shab Date: Thu, 17 Jul 2025 21:43:56 +0100 Subject: [PATCH 5/5] stop displaying text when checkbox not ticked --- Sprint-3/quote-generator/quotes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 6e5a3097d..e2e4f1a97 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -502,12 +502,15 @@ function pickAndDisplayQuote() { document.getElementById("new-quote").addEventListener("click", () => { pickAndDisplayQuote(); }); - +let intervalId; document.getElementById("auto-play").addEventListener("change",(event)=>{ if (event.target.checked){ //console.log("auto-play is on"); document.getElementById("auto-play-label").textContent = "auto-play : ON"; - setInterval(pickAndDisplayQuote,5000); + intervalId=setInterval(pickAndDisplayQuote,5000); + }else{ + document.getElementById("auto-play-label").textContent = "auto-play : OFF"; + clearInterval(intervalId); } });