-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
172 lines (147 loc) · 4.68 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>All Hindi Jokes</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Satisfy&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Original+Surfer&family=Permanent+Marker&family=Satisfy&display=swap');
* {
margin: 0;
padding: 0;
}
body {
background: #EEF2F7;
}
#container {
margin: 20px;
margin-top: 30px;
background: white;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.11),
0 2px 2px rgba(0, 0, 0, 0.11),
0 4px 4px rgba(0, 0, 0, 0.11),
0 6px 8px rgba(0, 0, 0, 0.11),
0 8px 16px rgba(0, 0, 0, 0.11);
padding: 40px;
}
#jokes {
font-family: 'Original Surfer', cursive;
font-size: 2em;
text-align: center;
font-weight: 400;
}
#title {
font-family: 'Satisfy', cursive;
text-align: center;
font-weight: 600;
margin-bottom: 10px;
text-decoration: underline;
}
#btn {
display: inline-block;
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 26px;
padding: 10px;
width: 150px;
transition: all 0.5s;
cursor: pointer;
margin-top: 40px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.25),
0 2px 2px rgba(0, 0, 0, 0.20),
0 4px 4px rgba(0, 0, 0, 0.15),
0 8px 8px rgba(0, 0, 0, 0.10),
0 16px 16px rgba(0, 0, 0, 0.05);
}
#btn:hover {
background-color: #dd3b0a;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08),
0 2px 2px rgba(0, 0, 0, 0.12),
0 4px 4px rgba(0, 0, 0, 0.16),
0 8px 8px rgba(0, 0, 0, 0.20);
}
#btn span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
#btn span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
#btn:hover span {
padding-right: 25px;
}
#btn:hover span:after {
opacity: 1;
right: 0;
}
#btn:focus {
outline: none;
}
@media screen and (min-width:1000px) {
#container {
margin: 0;
margin-top: 0;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
}
@media screen and (max-width:768px) {
#jokes {
font-size: 1.8em;
}
}
@media screen and (max-width:460px) {
#container {
padding: 20px;
}
}
</style>
</head>
<body>
<div id="container">
<h1 id="title">Loading Title...</h1>
<p id="jokes">Loading Joke...</p>
<button id="btn"><span>More</span></button>
</div>
<script>
const jokes = document.getElementById('jokes');
const title = document.getElementById('title');
const btn = document.getElementById('btn');
const generateJokes = () => {
const setHeader = {
headers: {
Accept: "application/json"
}
}
fetch('https://tattijokes.herokuapp.com/randomJokes', setHeader)
.then((res) => res.json())
.then((data) => {
jokes.innerHTML = data.joke.joke;
title.innerHTML = data.joke.title;
})
.catch((error) => console.log(error))
}
btn.addEventListener('click', generateJokes);
generateJokes();
</script>
</body>
</html>