-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
94 lines (79 loc) · 2.62 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Useless</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Madimi+One&display=swap" rel="stylesheet">
<style>
body{
background-color:black;
font-family: "Madimi One", sans-serif;
}
h1{
color: aliceblue;
}
img{
width: 200px;
}
button{
width: 90px;
height: 30px;
position: absolute;
top:auto;
left: 10rem;
}
h3{
color: aliceblue;
}
a{
color: red;
}
p{
color: aliceblue;
position: absolute;
top: 27rem;
}
</style>
</head>
<body>
<h1 id="title">Useless Website Says Hello!</h1>
<img class="img" id="img" src="">
<h3 id="ator">author here</h3>
<a id="post" href="">Reddit Post</a>
<form>
<button type="button" onclick="fetchImage()">Click Me</button>
</form>
<script>
function fetchImage() {
fetch('https://meme-api.com/gimme')
.then(response => {
if (response.ok) {
return response.json(); // Parse the response data as JSON
} else {
throw new Error('API request failed');
}
})
.then(data => {
const imgElement = document.getElementById('img');
const title = document.getElementById('title')
console.log(data)
if (imgElement) {
// Set the src attribute of img element from the first preview URL
imgElement.src = data.preview[0];
document.getElementById('ator').textContent = "Author: " + data.author;
title.textContent = data.title;
document.getElementById('post').href = data.postLink;
console.log(data)
}
})
.catch(error => {
console.error('Error fetching image:', error);
});
}
</script>
<p>Made by © Smart Lizard</p>
</body>
</html>