-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
105 lines (100 loc) · 2.88 KB
/
index.html
File metadata and controls
105 lines (100 loc) · 2.88 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Joke Generator</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
background: linear-gradient(135deg, #000000, #ffffff);
font-family: Arial, sans-serif;
margin: 0;
color: #333;
}
.card {
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
padding: 20px;
max-width: 400px;
width: 100%;
text-align: center;
margin-bottom: 20px;
}
.btn {
background-color: #000;
border: none;
border-radius: 5px;
color: #fff;
cursor: pointer;
padding: 10px 20px;
font-size: 16px;
transition: background-color 0.3s ease;
margin-top: 25px;
}
.btn:hover {
background-color: #333;
}
.display {
margin-top: 20px;
font-size: 18px;
color: #000;
}
/* Media Query for Tablets */
@media (max-width: 768px) {
.btn {
font-size: 14px;
padding: 8px 16px;
}
.display {
font-size: 16px;
}
}
/* Media Query for Mobile Devices */
@media (max-width: 480px) {
.card {
padding: 15px;
max-width: 90%;
}
.btn {
font-size: 12px;
padding: 6px 12px;
}
.display {
font-size: 14px;
}
}
</style>
</head>
<body>
<div class="card">
<div>Joke Generator</div>
<div class="display">Generate a joke!</div>
<button class="btn" onclick="generateJoke()">Generate Joke</button>
</div>
<script>
const display = document.querySelector(".display");
const apiCall = async () => {
try {
const response = await fetch("https://hindi-jokes-api.onrender.com/jokes?api_key=112b0bc9c07f4a3bd63d00876bee");
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
display.innerHTML = data.jokeContent;
} catch (error) {
display.innerHTML = 'Error fetching joke. Please try again.';
console.error('Error fetching data:', error);
}
}
function generateJoke() {
apiCall();
}
</script>
</body>
</html>