Skip to content

ITP_JAN_25 | HASAN DEMIROZ | Module-Data-Groups | Quote-Generator #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
27 changes: 27 additions & 0 deletions Sprint-3/quote-generator/Quote_generator_app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quote Generator</title>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
</head>

<body>

<div id="sentence">
<h1>Hello There!!!</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
<label for="autoOnOff">
<input type="checkbox" id="autoOnOff">
<span id="onOff">Auto-play is Off</span>
</label>

</body>

</html>
15 changes: 0 additions & 15 deletions Sprint-3/quote-generator/index.html

This file was deleted.

26 changes: 26 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
// ---------------
// pickFromArray(['a','b','c','d']) // maybe returns 'c'

const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");
const newQuoteButton = document.getElementById("new-quote");
const checkBox = document.getElementById("autoOnOff");
const onOffDisplay = document.getElementById("onOff");

// You don't need to change this function
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
Expand Down Expand Up @@ -491,3 +497,23 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
function displayRandomQuote() {
const randomQuote = pickFromArray(quotes);
quoteElement.textContent = randomQuote.quote;
authorElement.textContent = `- ${randomQuote.author}`;
}

let interval;
function autoPlayer(){
if (checkBox.checked){
onOffDisplay.innerText = `Auto-play is On`;
interval = setInterval(displayRandomQuote, 60000);
} else {
onOffDisplay.innerText = `Auto-play is Off`;
clearInterval(interval)
}
}

displayRandomQuote();
newQuoteButton.addEventListener("click", displayRandomQuote);
checkBox.addEventListener("change", autoPlayer);
23 changes: 23 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
/** Write your CSS in here **/
body{
padding: 100px;
background-color: orange;
}

#sentence{
border: 40px solid whitesmoke;
background-color: whitesmoke;
font-size: 200%;
}

#author{
float: right;
margin-left: 10px;
}


button{
background-color: orange;
width: 150px;
height: 70px;
font-size: 80%;
}