Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote Generator</title>
<link rel="stylesheet" href="style.css" />
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<h1>Quote Generator</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
Expand Down
30 changes: 30 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,33 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const newQuote = document.querySelector("#new-quote");
const quoteTxt = document.querySelector("#quote");
const quoteAuthor = document.querySelector("#author");
const autoPlay = document.querySelector("#auto-play");
const autoPlayTxt = document.querySelector("#auto-play-txt");
const autoPlayTime = 60000;
let autoPlayInterval = null;
newQuote.addEventListener("click", displayQuote);

initaliseSite();
autoPlay.addEventListener("change", () => {
if (autoPlay.checked) {
console.log("ON");
autoPlayTxt.textContent = `Auto-Play: ON, changing quote every ${autoPlayTime / 1000} seconds.`;
autoPlayInterval = setInterval(displayQuote, autoPlayTime);
} else {
console.log("OFF");
autoPlayTxt.textContent = "Auto-Play: OFF";
clearInterval(autoPlayInterval);
}
});
function initaliseSite() {
displayQuote();
}

function displayQuote() {
const quote = pickFromArray(quotes);
quoteTxt.innerHTML = `${quote.quote}`;
quoteAuthor.textContent = `- ${quote.author}`;
};
22 changes: 22 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
text-align: center;
padding: 20px;
background-color: aqua;
}
#quote {
font-size: 1.5em;
margin: 20px 0;
border: #160303 3px dotted;
}
#author {
font-size: 1.2em;
color: #555;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
font-size: 1em;
cursor: pointer;
background-color: aquamarine;
}
Loading