Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
20 changes: 20 additions & 0 deletions Sprint-3/quote-generator/QuoteGeneratorApp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="style.css" rel="stylesheet" />
<title>Quote of the day page</title>
<script defer src="quotes.js"></script>
</head>

<body onload="pickNewQuoteToDisplay()">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Look up

Pros and cons between these two approaches to call a function, callback(), on page load?

  • <body onload="callback()"> in HTML code
  • windows.addEventListener("load", callback) in JS code

<h1>quote for today</h1>
<div class="contaner">
<div class="item1"><p id="quote"></p></div>
<div class="item2"><p id="author"></p></div>

<button type="button" class="item3" id="new-quote">New quote</button>
</div>
</body>
</html>
18 changes: 17 additions & 1 deletion Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
const botton = document
.getElementById("new-quote")
.addEventListener("click", pickNewQuoteToDisplay);
Comment thread
cjyuan marked this conversation as resolved.
Outdated

function pickNewQuoteToDisplay(quote) {
Comment thread
cjyuan marked this conversation as resolved.
Outdated
//gets the quote object and brakes it down to the key and value
let quoteAndAuther = pickFromArray(quotes);
let quoteForDisplay = quoteAndAuther.quote;
let authorForDisplay = quoteAndAuther.author;
Comment thread
cjyuan marked this conversation as resolved.
Outdated
// prints the values to the page
document.getElementById("quote").innerHTML = "'" + quoteForDisplay + "'";
document.getElementById("author").innerHTML = ":-" + authorForDisplay;
Comment on lines +16 to +17
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Look up

The differences between using .innerHTML, innerText, and textContent to set text content of an HTML element.

}

//function randomQuote()
Comment thread
cjyuan marked this conversation as resolved.
Outdated

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down Expand Up @@ -490,4 +506,4 @@ const quotes = [
},
];

// call pickFromArray with the quotes array to check you get a random quote
console.log(pickFromArray(quotes));
Comment thread
cjyuan marked this conversation as resolved.
Outdated
34 changes: 33 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
/** Write your CSS in here **/
h1 {
font-size: 0;
}
body {
background-color: rgb(2, 185, 176);
}
.contaner {
height: 300px;
display: grid;
grid-template-columns: 20% 20% 20% 20% 20%;
grid-template-rows: 25% 25% 25% 25%;
background-color: rgb(8, 248, 232);
}
.contaner div {
text-shadow: 4px;
padding: 10px;
}
.item1 {
font-size: 40px;
grid-row: 1/5;
grid-column: 1 / 5;
}
.item2 {
font-size: 20px;
grid-row: 3/4;
grid-column: 5/6;
}
.item3 {
border-radius: 40px;
font-size: 15px;
grid-row: 4/5;
grid-column: 5 / 6;
}
Loading