Added Quote of The Day · Athena1601/30DaysOfJavaScript@f1916ff · GitHub
Skip to content

Commit f1916ff

Browse files
committed
Added Quote of The Day
1 parent 6261f2d commit f1916ff

9 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎100 - Quote of The Day/css/bootstrap.min.css‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions

‎100 - Quote of The Day/index.html‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html>
2+
<head>
3+
<link rel="stylesheet" href="css/bootstrap.min.css">
4+
<link rel="stylesheet" href="css/main.css">
5+
</head>
6+
<body>
7+
<div class="container justify-content-center">
8+
<div class="row w-100 h-100 align-items-center justify-content-center">
9+
<div class="item d-flex justify-content-center align-items-center">
10+
<h1 class="title">Quote of the Day</h1>
11+
<p>Press the button below to get a new quote!</p>
12+
<button id="newQuote">New Quote</button>
13+
<p id="quote"></p>
14+
<p id="name"></p>
15+
</div>
16+
</div>
17+
</div>
18+
<script src="js/jquery-3.5.1.slim.min.js"></script>
19+
<script src="js/popper.min.js"></script>
20+
<script src="js/bootstrap.min.js"></script>
21+
<script src="js/main.js"></script>
22+
</body>
23+
</html>

‎100 - Quote of The Day/js/bootstrap.min.js‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎100 - Quote of The Day/js/jquery-3.5.1.slim.min.js‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎100 - Quote of The Day/js/main.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var httr = new XMLHttpRequest();
2+
var quotes = [];
3+
httr.open('GET', 'https://type.fit/api/quotes/');
4+
httr.send();
5+
httr.addEventListener('readystatechange', function(){
6+
if(httr.readyState==4)
7+
{
8+
quotes = JSON.parse(httr.response);
9+
console.log(quotes);
10+
}
11+
});
12+
var x = document.getElementById('newQuote');
13+
var y;
14+
var w = document.getElementById('quote');
15+
var z = document.getElementById('name');
16+
x.addEventListener('click',function(){
17+
display();
18+
})
19+
function display(){
20+
do{
21+
y = Math.floor(Math.random() * quotes.length);
22+
}while(quotes[y].author == null)
23+
w.innerHTML = quotes[y].text;
24+
z.innerHTML = "-- " + quotes[y].author;
25+
}

‎100 - Quote of The Day/js/popper.min.js‎

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎30DaysOfJavaScript/assets/100.PNG‎

26.6 KB
Loading

‎index.html‎

Lines changed: 6 additions & 1 deletion

0 commit comments

Comments
 (0)