-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (91 loc) · 2.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quotes Api Integration</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@100;200;300;400;500;600;700&display=swap');
body{
text-align: right;
font-family: 'Josefin Sans', sans-serif;
}
h1{
text-align: center;
color: #40128B;
}
#author{
text-align: right;
}
.main-container {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #E4A5FF;
}
.inner-container{
height: 50%;
width: 700px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #FFAAC9;
box-shadow: 0px 0px 9px 6px #dd58d681;
border-radius: 35px 0px 35px 35px;
padding: 30px;
}
#changing-quotes{
background-color: #E4A5FF;
outline: none;
border: none;
padding: 15px 25px;
border-radius: 10px 0px 10px 10px;
color: #40128B;
font-weight: 600;
font-size: 15px;
box-shadow: 0px 0px 15px #dd58d681;
font-family: 'Josefin Sans', sans-serif;
cursor: pointer;
}
#changing-quotes:hover{
background-color: #40128B;
transition: all 0.3s ease;
color: #fff;
}
</style>
</head>
<body>
<div class="main-container">
<div class="inner-container">
<div><h1 id="quotes"></h1></div>
<div><p id="author"></p></div>
<button id="changing-quotes">Change Quote</button>
</div>
</div>
<script>
const getApi = async () => {
const api = "https://type.fit/api/quotes";
const randomNumbers = Math.floor(Math.random() * 1643);
const quotesOfTheDay = document.getElementById('quotes');
const authorOfTheQuotes = document.getElementById('author');
const changingTheQuotes = document.getElementById('changing-quotes').addEventListener("click", getApi);
try {
let data = await fetch(api);
const getNewApi = await data.json();
const quotes = (getNewApi[randomNumbers].text);
const author = (getNewApi[randomNumbers].author);
quotesOfTheDay.innerText = quotes;
authorOfTheQuotes.innerText = author;
} catch (error) {
}
}
// Running Functions
getApi();
</script>
</body>
</html>